Grant Nathan his wish - add an --disable-getpwuid to the configure options and protect all users of that code so it disappears if disabled.
cmr=v1.7.5:reviewer=hjelmn:subject=disable getpwuid if requested This commit was SVN r30413.
Этот коммит содержится в:
родитель
b32556e6dc
Коммит
e3cb4b4a5b
@ -464,4 +464,19 @@ AC_ARG_WITH([libltdl],
|
||||
AC_DEFINE_UNQUOTED([OPAL_ENABLE_CRDEBUG], [0],
|
||||
[Whether we want checkpoint/restart enabled debugging functionality or not])
|
||||
|
||||
# some systems don't want/like getpwuid
|
||||
AC_MSG_CHECKING([if want getpwuid support])
|
||||
AC_ARG_ENABLE([getpwuid],
|
||||
[AC_HELP_STRING([--disable-getpwuid],
|
||||
[Disable getpwuid support (default: enabled)])])
|
||||
if test "$enable_getpwuid" = "no"; then
|
||||
AC_MSG_RESULT([no])
|
||||
opal_want_getpwuid=0
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
opal_want_getpwuid=1
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([OPAL_ENABLE_GETPWUID], [$opal_want_getpwuid],
|
||||
[Disable getpwuid support (default: enabled)])
|
||||
|
||||
])dnl
|
||||
|
@ -1492,26 +1492,32 @@ static int setup_shell(orte_plm_rsh_shell_t *rshell,
|
||||
char *nodename, int *argc, char ***argv)
|
||||
{
|
||||
orte_plm_rsh_shell_t remote_shell, local_shell;
|
||||
struct passwd *p;
|
||||
char *param;
|
||||
int rc;
|
||||
|
||||
|
||||
/* What is our local shell? */
|
||||
local_shell = ORTE_PLM_RSH_SHELL_UNKNOWN;
|
||||
p = getpwuid(getuid());
|
||||
if( NULL == p ) {
|
||||
/* This user is unknown to the system. Therefore, there is no reason we
|
||||
* spawn whatsoever in his name. Give up with a HUGE error message.
|
||||
*/
|
||||
orte_show_help( "help-plm-rsh.txt", "unknown-user", true, (int)getuid() );
|
||||
return ORTE_ERR_FATAL;
|
||||
|
||||
#if OPAL_ENABLE_GETPWUID
|
||||
{
|
||||
struct passwd *p;
|
||||
|
||||
p = getpwuid(getuid());
|
||||
if( NULL == p ) {
|
||||
/* This user is unknown to the system. Therefore, there is no reason we
|
||||
* spawn whatsoever in his name. Give up with a HUGE error message.
|
||||
*/
|
||||
orte_show_help( "help-plm-rsh.txt", "unknown-user", true, (int)getuid() );
|
||||
return ORTE_ERR_FATAL;
|
||||
}
|
||||
param = p->pw_shell;
|
||||
local_shell = find_shell(p->pw_shell);
|
||||
}
|
||||
param = p->pw_shell;
|
||||
local_shell = find_shell(p->pw_shell);
|
||||
|
||||
#endif
|
||||
|
||||
/* If we didn't find it in getpwuid(), try looking at the $SHELL
|
||||
environment variable (see https://svn.open-mpi.org/trac/ompi/ticket/1060)
|
||||
*/
|
||||
environment variable (see https://svn.open-mpi.org/trac/ompi/ticket/1060)
|
||||
*/
|
||||
if (ORTE_PLM_RSH_SHELL_UNKNOWN == local_shell &&
|
||||
NULL != (param = getenv("SHELL"))) {
|
||||
local_shell = find_shell(param);
|
||||
@ -1554,12 +1560,12 @@ static int setup_shell(orte_plm_rsh_shell_t *rshell,
|
||||
remote_shell, orte_plm_rsh_shell_name[remote_shell]));
|
||||
|
||||
/* Do we need to source .profile on the remote side?
|
||||
- sh: yes (see bash(1))
|
||||
- ksh: yes (see ksh(1))
|
||||
- bash: no (see bash(1))
|
||||
- [t]csh: no (see csh(1) and tcsh(1))
|
||||
- zsh: no (see http://zsh.sourceforge.net/FAQ/zshfaq03.html#l19)
|
||||
*/
|
||||
- sh: yes (see bash(1))
|
||||
- ksh: yes (see ksh(1))
|
||||
- bash: no (see bash(1))
|
||||
- [t]csh: no (see csh(1) and tcsh(1))
|
||||
- zsh: no (see http://zsh.sourceforge.net/FAQ/zshfaq03.html#l19)
|
||||
*/
|
||||
|
||||
if (ORTE_PLM_RSH_SHELL_SH == remote_shell ||
|
||||
ORTE_PLM_RSH_SHELL_KSH == remote_shell) {
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include "opal/util/show_help.h"
|
||||
|
||||
#include "orte/util/proc_info.h"
|
||||
#include "orte/util/show_help.h"
|
||||
|
||||
#include "opal/runtime/opal.h"
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
@ -268,7 +269,6 @@ void kill_procs(void) {
|
||||
char *inputline;
|
||||
char *this_user;
|
||||
int uid;
|
||||
struct passwd *pwdent;
|
||||
char *separator = " \t"; /* output can be delimited by space or tab */
|
||||
|
||||
/*
|
||||
@ -303,18 +303,31 @@ void kill_procs(void) {
|
||||
|
||||
/* get the name of the user */
|
||||
uid = getuid();
|
||||
#if OPAL_ENABLE_GETPWUID
|
||||
{
|
||||
struct passwd *pwdent;
|
||||
|
||||
#ifdef HAVE_GETPWUID
|
||||
pwdent = getpwuid(uid);
|
||||
pwdent = getpwuid(uid);
|
||||
if (NULL == pwdent) {
|
||||
/* this indicates a problem with the passwd system,
|
||||
* so pretty-print a message just for info
|
||||
*/
|
||||
orte_show_help("help-orte-runtime.txt",
|
||||
"orte:session:dir:nopwname", true);
|
||||
}
|
||||
#else
|
||||
pwdent = NULL;
|
||||
pwdent = NULL;
|
||||
#endif
|
||||
if (NULL != pwdent) {
|
||||
this_user = strdup(pwdent->pw_name);
|
||||
} else {
|
||||
if (0 > asprintf(&this_user, "%d", uid)) {
|
||||
return;
|
||||
if (NULL != pwdent) {
|
||||
this_user = strdup(pwdent->pw_name);
|
||||
} else {
|
||||
asprintf(&this_user, "%d", uid);
|
||||
}
|
||||
}
|
||||
#else
|
||||
asprintf(&this_user, "%d", uid);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There is a race condition here. The problem is that we are looking
|
||||
|
@ -132,23 +132,38 @@ orte_session_dir_get_name(char **fulldirpath,
|
||||
int exit_status = ORTE_SUCCESS;
|
||||
size_t len;
|
||||
int uid;
|
||||
struct passwd *pwdent;
|
||||
|
||||
/* Ensure that system info is set */
|
||||
orte_proc_info();
|
||||
|
||||
/* get the name of the user */
|
||||
/* get the name of the user */
|
||||
uid = getuid();
|
||||
#if OPAL_ENABLE_GETPWUID
|
||||
{
|
||||
struct passwd *pwdent;
|
||||
|
||||
#ifdef HAVE_GETPWUID
|
||||
pwdent = getpwuid(uid);
|
||||
pwdent = getpwuid(uid);
|
||||
if (NULL == pwdent) {
|
||||
/* this indicates a problem with the passwd system,
|
||||
* so pretty-print a message just for info
|
||||
*/
|
||||
orte_show_help("help-orte-runtime.txt",
|
||||
"orte:session:dir:nopwname", true);
|
||||
}
|
||||
#else
|
||||
pwdent = NULL;
|
||||
pwdent = NULL;
|
||||
#endif
|
||||
if (NULL != pwdent) {
|
||||
user = strdup(pwdent->pw_name);
|
||||
} else {
|
||||
asprintf(&user, "%d", uid);
|
||||
if (NULL != pwdent) {
|
||||
user = strdup(pwdent->pw_name);
|
||||
} else {
|
||||
asprintf(&user, "%d", uid);
|
||||
}
|
||||
}
|
||||
#else
|
||||
asprintf(&user, "%d", uid);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* set the 'hostname'
|
||||
@ -253,7 +268,7 @@ orte_session_dir_get_name(char **fulldirpath,
|
||||
}
|
||||
|
||||
} /* If we were not given a proc at all, then we just set it to frontend
|
||||
*/
|
||||
*/
|
||||
else {
|
||||
sessions = strdup(frontend); /* must dup this to avoid double-free later */
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user