From a7afa869afe2bf2b7d3d068164b83bee34cf5adb Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Wed, 8 Oct 2008 14:21:42 +0000 Subject: [PATCH] Bring Jeff's changes over from v1.2 that restores the automatic source of .profile for bash and ksh shells. This commit was SVN r19709. --- orte/mca/plm/rsh/plm_rsh_module.c | 100 +++++++++++++++--------------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/orte/mca/plm/rsh/plm_rsh_module.c b/orte/mca/plm/rsh/plm_rsh_module.c index b44d45c32b..6c579b3ae4 100644 --- a/orte/mca/plm/rsh/plm_rsh_module.c +++ b/orte/mca/plm/rsh/plm_rsh_module.c @@ -342,15 +342,13 @@ static void orte_plm_rsh_wait_daemon(pid_t pid, int status, void* cbdata) static int setup_launch(int *argcptr, char ***argvptr, char *nodename, int *node_name_index1, - int *proc_vpid_index, char *prefix_dir, - bool *remote_sh, bool *remote_csh) + int *proc_vpid_index, char *prefix_dir) { struct passwd *p; int argc; char **argv; char *param; - orte_plm_rsh_shell_t shell; - bool local_sh = false, local_csh = false; + orte_plm_rsh_shell_t remote_shell, local_shell; char *lib_base, *bin_base; int orted_argc; char **orted_argv; @@ -359,6 +357,7 @@ static int setup_launch(int *argcptr, char ***argvptr, 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 @@ -368,69 +367,51 @@ static int setup_launch(int *argcptr, char ***argvptr, return ORTE_ERR_FATAL; } else { param = p->pw_shell; - shell = find_shell(p->pw_shell); + local_shell = find_shell(p->pw_shell); } /* 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) */ - if (ORTE_PLM_RSH_SHELL_UNKNOWN == shell && + if (ORTE_PLM_RSH_SHELL_UNKNOWN == local_shell && NULL != (param = getenv("SHELL"))) { - shell = find_shell(param); + local_shell = find_shell(param); } - switch (shell) { - case ORTE_PLM_RSH_SHELL_SH: /* fall through */ - case ORTE_PLM_RSH_SHELL_KSH: /* fall through */ - case ORTE_PLM_RSH_SHELL_ZSH: /* fall through */ - case ORTE_PLM_RSH_SHELL_BASH: local_sh = true; break; - case ORTE_PLM_RSH_SHELL_TCSH: /* fall through */ - case ORTE_PLM_RSH_SHELL_CSH: local_csh = true; break; - default: - opal_output(0, "WARNING: local probe returned unhandled shell:%s assuming bash\n", - (NULL != param) ? param : "unknown"); - *remote_sh = true; - break; + if (ORTE_PLM_RSH_SHELL_UNKNOWN == local_shell) { + opal_output(0, "WARNING: local probe returned unhandled shell:%s assuming bash\n", + (NULL != param) ? param : "unknown"); + local_shell = ORTE_PLM_RSH_SHELL_BASH; } OPAL_OUTPUT_VERBOSE((1, orte_plm_globals.output, - "%s plm:rsh: local csh: %s, local sh: %s", + "%s plm:rsh: local shell: %d (%s)", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - (local_csh ? "TRUE" : "FALSE"), - (local_sh ? "TRUE" : "FALSE"))); + local_shell, orte_plm_rsh_shell_name[local_shell])); /* What is our remote shell? */ if (mca_plm_rsh_component.assume_same_shell) { - *remote_sh = local_sh; - *remote_csh = local_csh; + remote_shell = local_shell; OPAL_OUTPUT_VERBOSE((1, orte_plm_globals.output, "%s plm:rsh: assuming same remote shell as local shell", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME))); } else { - orte_plm_rsh_shell_t shell; - rc = orte_plm_rsh_probe(nodename, &shell); + rc = orte_plm_rsh_probe(nodename, &remote_shell); if (ORTE_SUCCESS != rc) { ORTE_ERROR_LOG(rc); return rc; } - switch (shell) { - case ORTE_PLM_RSH_SHELL_SH: /* fall through */ - case ORTE_PLM_RSH_SHELL_KSH: /* fall through */ - case ORTE_PLM_RSH_SHELL_ZSH: /* fall through */ - case ORTE_PLM_RSH_SHELL_BASH: *remote_sh = true; break; - case ORTE_PLM_RSH_SHELL_TCSH: /* fall through */ - case ORTE_PLM_RSH_SHELL_CSH: *remote_csh = true; break; - default: + if (ORTE_PLM_RSH_SHELL_UNKNOWN == remote_shell) { opal_output(0, "WARNING: rsh probe returned unhandled shell; assuming bash\n"); - *remote_sh = true; + remote_shell = ORTE_PLM_RSH_SHELL_BASH; } } OPAL_OUTPUT_VERBOSE((1, orte_plm_globals.output, - "%s plm:rsh: remote csh: %d, remote sh: %d", + "%s plm:rsh: remote shell: %d (%s)", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - *remote_csh, *remote_sh)); + remote_shell, orte_plm_rsh_shell_name[remote_shell])); /* Figure out the basenames for the libdir and bindir. This requires some explanation: @@ -470,6 +451,28 @@ static int setup_launch(int *argcptr, char ***argvptr, *node_name_index1 = argc; opal_argv_append(&argc, &argv, "