1
1
openmpi/opal/mca/sec/keystone/sec_keystone.c
Ralph Castain 780c93ee57 Per the PR and discussion on today's telecon, extend the process name definition as a two-field struct of uint32_t's down to the OPAL layer. This resolves issues created by prior commits that impacted both heterogeneous and SPARC support. This also simplifies the OMPI code base by removing the need for frequent memcpy's when transitioning between the OMPI/ORTE layers and OPAL.
We recognize that this means other users of OPAL will need to "wrap" the opal_process_name_t if they desire to abstract it in some fashion. This is regrettable, and we are looking at possible alternatives that might mitigate that requirement. Meantime, however, we have to put the needs of the OMPI community first, and are taking this step to restore hetero and SPARC support.
2014-11-11 17:00:42 -08:00

106 строки
2.4 KiB
C

/*
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#include "opal_config.h"
#include "opal/constants.h"
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#include <stdio.h>
#include <curl/curl.h>
#include "opal_stdint.h"
#include "opal/dss/dss_types.h"
#include "opal/util/error.h"
#include "opal/util/output.h"
#include "opal/util/show_help.h"
#include "opal/mca/sec/base/base.h"
#include "sec_basic.h"
static int init(void);
static void finalize(void);
static int get_my_cred(int dstorehandle,
opal_process_name_t *my_id,
opal_sec_cred_t **cred);
static int authenticate(opal_sec_cred_t *cred);
opal_sec_base_module_t opal_sec_keystone_module = {
init,
finalize,
get_my_cred,
authenticate
};
static int init(void)
{
/* init libcurl */
curl_global_init(CURL_GLOBAL_ALL);
return OPAL_SUCCESS;
}
static void finalize(void)
{
/* cleanup libcurl */
curl_global_cleanup();
}
static size_t op_cbfunc(void *ptr, size_t size, size_t count, void *stream)
{
opal_output(0, "CURL RETURNED: %s", (char*)stream);
return size;
}
static int get_my_cred(int dstorehandle,
opal_process_name_t *my_id,
opal_sec_cred_t **cred)
{
char *cmd;
CURL *curl;
CURLcode rc;
opal_output_verbose(5, opal_sec_base_framework.framework_output,
"keystone:get_my_cred");
/* ensure we return at least a NULL */
*cred = NULL;
/* query the keystone server */
asprintf(&cmd, "%sget_cred", mca_sec_keystone_component.url);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, cmd);
/* send the data to this function */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, op_cbfunc);
/* execute it */
if (CURLE_OK != (rc = curl_easy_perform(curl))) {
opal_output(0, "Error while fetching '%s' : %s",
cmd, curl_easy_strerror(rc));
}
/* the data will have been returned in the callback
* function when easy_perform completes
*/
curl_easy_cleanup(curl);
free(cmd);
return OPAL_ERR_NOT_IMPLEMENTED;
}
static int authenticate(opal_sec_cred_t *cred)
{
return OPAL_ERR_NOT_IMPLEMENTED;
}