Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions opal/mca/pmix/pmix2x/pmix/config/pmix.m4
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl reserved.
dnl Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved.
dnl Copyright (c) 2011-2013 NVIDIA Corporation. All rights reserved.
dnl Copyright (c) 2013-2015 Intel, Inc. All rights reserved
dnl Copyright (c) 2015 Research Organization for Information Science
dnl Copyright (c) 2015-2016 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl Copyright (c) 2016 Mellanox Technologies, Inc.
dnl All rights reserved.
Expand Down Expand Up @@ -301,7 +301,8 @@ AC_DEFUN([PMIX_SETUP_CORE],[
time.h unistd.h dirent.h \
crt_externs.h signal.h \
ioLib.h sockLib.h hostLib.h limits.h \
sys/statfs.h sys/statvfs.h])
sys/statfs.h sys/statvfs.h \
netdb.h ucred.h])

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

AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid strnlen])
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid getpeerucred strnlen])

# On some hosts, htonl is a define, so the AC_CHECK_FUNC will get
# confused. On others, it's in the standard library, but stubbed with
Expand Down
3 changes: 3 additions & 0 deletions opal/mca/pmix/pmix2x/pmix/src/dstore/pmix_esh.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Copyright (c) 2015-2016 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -12,6 +14,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/file.h>

#include <src/include/pmix_config.h>
Expand Down
25 changes: 25 additions & 0 deletions opal/mca/pmix/pmix2x/pmix/src/sec/pmix_native.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* Copyright (c) 2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
*
* $COPYRIGHT$
*
Expand All @@ -24,6 +26,9 @@
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_UCRED_H
#include <ucred.h>
#endif

#include "pmix_sec.h"
#include "pmix_native.h"
Expand Down Expand Up @@ -65,6 +70,9 @@ static pmix_status_t validate_cred(pmix_peer_t *peer, char *cred)
struct ucred ucred;
#endif
socklen_t crlen = sizeof (ucred);
#endif
#ifdef HAVE_GETPEERUCRED
ucred_t *ucred = NULL;
#endif
uid_t euid;
gid_t gid;
Expand Down Expand Up @@ -99,7 +107,24 @@ static pmix_status_t validate_cred(pmix_peer_t *peer, char *cred)
strerror (pmix_socket_errno));
return PMIX_ERR_INVALID_CRED;
}
#elif defined(HAVE_GETPEERUCRED)
pmix_output_verbose(2, pmix_globals.debug_output,
"sec:native checking getpeerucred for peer credentials");
if (0 != getpeerucred(peer->sd, &ucred)) {
pmix_output_verbose(2, pmix_globals.debug_output,
"sec: getsockopt getpeerucred failed: %s",
strerror (pmix_socket_errno));
pmix_output_verbose(2, pmix_globals.debug_output,
"sec: getsockopt getpeerucred failed: %s",
strerror (errno));
return PMIX_ERR_INVALID_CRED;
}
euid = ucred_geteuid(ucred);
gid = ucred_getrgid(ucred);
ucred_free(ucred);
#else
pmix_output_verbose(2, pmix_globals.debug_output,
"sec: native cannot validate_cred on this system");
return PMIX_ERR_NOT_SUPPORTED;
#endif

Expand Down