root/opal/mca/pmix/pmix4x/pmix/src/mca/psec/none/psec_none.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. none_init
  2. none_finalize
  3. create_cred
  4. validate_cred

   1 /*
   2  * Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
   3  * Copyright (c) 2016      IBM Corporation.  All rights reserved.
   4  * Copyright (c) 2017      Research Organization for Information Science
   5  *                         and Technology (RIST). All rights reserved.
   6  *
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #include <src/include/pmix_config.h>
  15 
  16 #include <pmix_common.h>
  17 
  18 #include "src/include/pmix_socket_errno.h"
  19 #include "src/include/pmix_globals.h"
  20 #include "src/util/argv.h"
  21 #include "src/util/error.h"
  22 #include "src/util/output.h"
  23 
  24 #include <unistd.h>
  25 #ifdef HAVE_SYS_TYPES_H
  26 #include <sys/types.h>
  27 #endif
  28 
  29 #include "src/mca/psec/psec.h"
  30 #include "psec_none.h"
  31 
  32 static pmix_status_t none_init(void);
  33 static void none_finalize(void);
  34 static pmix_status_t create_cred(struct pmix_peer_t *peer,
  35                                  const pmix_info_t directives[], size_t ndirs,
  36                                  pmix_info_t **info, size_t *ninfo,
  37                                  pmix_byte_object_t *cred);
  38 static pmix_status_t validate_cred(struct pmix_peer_t *peer,
  39                                    const pmix_info_t directives[], size_t ndirs,
  40                                    pmix_info_t **info, size_t *ninfo,
  41                                    const pmix_byte_object_t *cred);
  42 
  43 pmix_psec_module_t pmix_none_module = {
  44     .name = "none",
  45     .init = none_init,
  46     .finalize = none_finalize,
  47     .create_cred = create_cred,
  48     .validate_cred = validate_cred
  49 };
  50 
  51 static pmix_status_t none_init(void)
  52 {
  53     pmix_output_verbose(2, pmix_globals.debug_output,
  54                         "psec: none init");
  55     return PMIX_SUCCESS;
  56 }
  57 
  58 static void none_finalize(void)
  59 {
  60     pmix_output_verbose(2, pmix_globals.debug_output,
  61                         "psec: none finalize");
  62 }
  63 
  64 static pmix_status_t create_cred(struct pmix_peer_t *peer,
  65                                  const pmix_info_t directives[], size_t ndirs,
  66                                  pmix_info_t **info, size_t *ninfo,
  67                                  pmix_byte_object_t *cred)
  68 {
  69     /* ensure initialization */
  70     PMIX_BYTE_OBJECT_CONSTRUCT(cred);
  71 
  72     return PMIX_SUCCESS;
  73 }
  74 
  75 static pmix_status_t validate_cred(struct pmix_peer_t *peer,
  76                                    const pmix_info_t directives[], size_t ndirs,
  77                                    pmix_info_t **info, size_t *ninfo,
  78                                    const pmix_byte_object_t *cred)
  79 {
  80     size_t n, m;
  81     char **types;
  82     bool takeus;
  83 
  84     pmix_output_verbose(2, pmix_globals.debug_output,
  85                         "psec: none always reports valid");
  86 
  87     /* if we are responding to a local request to validate a credential,
  88      * then see if they specified a mechanism */
  89     if (NULL != directives && 0 < ndirs) {
  90         for (n=0; n < ndirs; n++) {
  91             if (0 == strncmp(directives[n].key, PMIX_CRED_TYPE, PMIX_MAX_KEYLEN)) {
  92                 /* split the specified string */
  93                 types = pmix_argv_split(directives[n].value.data.string, ',');
  94                 takeus = false;
  95                 for (m=0; NULL != types[m]; m++) {
  96                     if (0 == strcmp(types[m], "none")) {
  97                         /* it's us! */
  98                         takeus = true;
  99                         break;
 100                     }
 101                 }
 102                 pmix_argv_free(types);
 103                 if (!takeus) {
 104                     return PMIX_ERR_NOT_SUPPORTED;
 105                 }
 106             }
 107         }
 108     }
 109 
 110     /* mark that this came from us */
 111     if (NULL != info) {
 112         /* mark that this came from us */
 113         PMIX_INFO_CREATE(*info, 1);
 114         if (NULL == *info) {
 115             return PMIX_ERR_NOMEM;
 116         }
 117         *ninfo = 1;
 118         PMIX_INFO_LOAD(info[0], PMIX_CRED_TYPE, "none", PMIX_STRING);
 119     }
 120     return PMIX_SUCCESS;
 121 }

/* [<][>][^][v][top][bottom][index][help] */