Skip to content

Commit b12e43f

Browse files
author
rhc54
authored
Merge pull request #2001 from ggouaillardet/topic/pmix2x_sec_native
fix sec/native module under Solaris and other misc issues
2 parents a439afc + 02847d9 commit b12e43f

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

opal/mca/pmix/pmix2x/pmix/config/pmix.m4

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dnl reserved.
1818
dnl Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved.
1919
dnl Copyright (c) 2011-2013 NVIDIA Corporation. All rights reserved.
2020
dnl Copyright (c) 2013-2015 Intel, Inc. All rights reserved
21-
dnl Copyright (c) 2015 Research Organization for Information Science
21+
dnl Copyright (c) 2015-2016 Research Organization for Information Science
2222
dnl and Technology (RIST). All rights reserved.
2323
dnl Copyright (c) 2016 Mellanox Technologies, Inc.
2424
dnl All rights reserved.
@@ -301,7 +301,8 @@ AC_DEFUN([PMIX_SETUP_CORE],[
301301
time.h unistd.h dirent.h \
302302
crt_externs.h signal.h \
303303
ioLib.h sockLib.h hostLib.h limits.h \
304-
sys/statfs.h sys/statvfs.h])
304+
sys/statfs.h sys/statvfs.h \
305+
netdb.h ucred.h])
305306

306307
# Note that sometimes we have <stdbool.h>, but it doesn't work (e.g.,
307308
# have both Portland and GNU installed; using pgcc will find GNU's
@@ -507,7 +508,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[
507508
# Darwin doesn't need -lm, as it's a symlink to libSystem.dylib
508509
PMIX_SEARCH_LIBS_CORE([ceil], [m])
509510

510-
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid strnlen])
511+
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid getpeerucred strnlen])
511512

512513
# On some hosts, htonl is a define, so the AC_CHECK_FUNC will get
513514
# confused. On others, it's in the standard library, but stubbed with

opal/mca/pmix/pmix2x/pmix/src/dstore/pmix_esh.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* Copyright (c) 2015-2016 Mellanox Technologies, Inc.
33
* All rights reserved.
4+
* Copyright (c) 2016 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
46
* $COPYRIGHT$
57
*
68
* Additional copyrights may follow
@@ -12,6 +14,7 @@
1214
#include <stdio.h>
1315
#include <sys/types.h>
1416
#include <sys/stat.h>
17+
#include <fcntl.h>
1518
#include <sys/file.h>
1619

1720
#include <src/include/pmix_config.h>

opal/mca/pmix/pmix2x/pmix/src/sec/pmix_native.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
33
* Copyright (c) 2016 IBM Corporation. All rights reserved.
4+
* Copyright (c) 2016 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
46
*
57
* $COPYRIGHT$
68
*
@@ -24,6 +26,9 @@
2426
#ifdef HAVE_SYS_TYPES_H
2527
#include <sys/types.h>
2628
#endif
29+
#ifdef HAVE_UCRED_H
30+
#include <ucred.h>
31+
#endif
2732

2833
#include "pmix_sec.h"
2934
#include "pmix_native.h"
@@ -65,6 +70,9 @@ static pmix_status_t validate_cred(pmix_peer_t *peer, char *cred)
6570
struct ucred ucred;
6671
#endif
6772
socklen_t crlen = sizeof (ucred);
73+
#endif
74+
#ifdef HAVE_GETPEERUCRED
75+
ucred_t *ucred = NULL;
6876
#endif
6977
uid_t euid;
7078
gid_t gid;
@@ -99,7 +107,24 @@ static pmix_status_t validate_cred(pmix_peer_t *peer, char *cred)
99107
strerror (pmix_socket_errno));
100108
return PMIX_ERR_INVALID_CRED;
101109
}
110+
#elif defined(HAVE_GETPEERUCRED)
111+
pmix_output_verbose(2, pmix_globals.debug_output,
112+
"sec:native checking getpeerucred for peer credentials");
113+
if (0 != getpeerucred(peer->sd, &ucred)) {
114+
pmix_output_verbose(2, pmix_globals.debug_output,
115+
"sec: getsockopt getpeerucred failed: %s",
116+
strerror (pmix_socket_errno));
117+
pmix_output_verbose(2, pmix_globals.debug_output,
118+
"sec: getsockopt getpeerucred failed: %s",
119+
strerror (errno));
120+
return PMIX_ERR_INVALID_CRED;
121+
}
122+
euid = ucred_geteuid(ucred);
123+
gid = ucred_getrgid(ucred);
124+
ucred_free(ucred);
102125
#else
126+
pmix_output_verbose(2, pmix_globals.debug_output,
127+
"sec: native cannot validate_cred on this system");
103128
return PMIX_ERR_NOT_SUPPORTED;
104129
#endif
105130

0 commit comments

Comments
 (0)