- Add support for "sh" handling. Instead of detecting of bash we now
check for bourne shell, because bourne shell is the smallest common divisor for bash/ksh/sh. - Make some shell expressions sh compatible This commit was SVN r12509.
Этот коммит содержится в:
родитель
a82ce427e4
Коммит
9ba4c4a7ee
@ -5,7 +5,7 @@
|
|||||||
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
||||||
* of Tennessee Research Foundation. All rights
|
* of Tennessee Research Foundation. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
|
||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -113,6 +113,7 @@ enum {
|
|||||||
ORTE_PLS_RSH_SHELL_TCSH,
|
ORTE_PLS_RSH_SHELL_TCSH,
|
||||||
ORTE_PLS_RSH_SHELL_CSH,
|
ORTE_PLS_RSH_SHELL_CSH,
|
||||||
ORTE_PLS_RSH_SHELL_KSH,
|
ORTE_PLS_RSH_SHELL_KSH,
|
||||||
|
ORTE_PLS_RSH_SHELL_SH,
|
||||||
ORTE_PLS_RSH_SHELL_UNKNOWN
|
ORTE_PLS_RSH_SHELL_UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -123,6 +124,7 @@ static const char * orte_pls_rsh_shell_name[] = {
|
|||||||
"tcsh", /* tcsh has to be first otherwise strstr finds csh */
|
"tcsh", /* tcsh has to be first otherwise strstr finds csh */
|
||||||
"csh",
|
"csh",
|
||||||
"ksh",
|
"ksh",
|
||||||
|
"sh",
|
||||||
"unknown"
|
"unknown"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -240,13 +242,25 @@ static int orte_pls_rsh_probe(orte_mapped_node_t * node, orte_pls_rsh_shell * sh
|
|||||||
/* Search for the substring of known shell-names */
|
/* Search for the substring of known shell-names */
|
||||||
for (i = 0; i < (int)(sizeof (orte_pls_rsh_shell_name)/
|
for (i = 0; i < (int)(sizeof (orte_pls_rsh_shell_name)/
|
||||||
sizeof(orte_pls_rsh_shell_name[0])); i++) {
|
sizeof(orte_pls_rsh_shell_name[0])); i++) {
|
||||||
if (NULL != strstr (outbuf, orte_pls_rsh_shell_name[i])) {
|
char *sh_name = NULL;
|
||||||
*shell = i;
|
|
||||||
break;
|
sh_name = rindex(outbuf, '/');
|
||||||
|
if ( sh_name != NULL ) {
|
||||||
|
sh_name++; /* skip '/' */
|
||||||
|
|
||||||
|
/* We cannot use "echo -n $SHELL" because -n is not portable. Therefore
|
||||||
|
* we have to remove the "\n" */
|
||||||
|
if ( sh_name[strlen(sh_name)-1] == '\n' ) {
|
||||||
|
sh_name[strlen(sh_name)-1] = '\0';
|
||||||
|
}
|
||||||
|
if ( 0 == strcmp(sh_name, orte_pls_rsh_shell_name[i]) ) {
|
||||||
|
*shell = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mca_pls_rsh_component.debug) {
|
if (mca_pls_rsh_component.debug) {
|
||||||
opal_output(0, "pls:rsh: node:%s has SHELL:%s\n",
|
opal_output(0, "pls:rsh: node:%s has SHELL: %s\n",
|
||||||
node->nodename, orte_pls_rsh_shell_name[*shell]);
|
node->nodename, orte_pls_rsh_shell_name[*shell]);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
@ -380,7 +394,6 @@ static void orte_pls_rsh_wait_daemon(pid_t pid, int status, void* cbdata)
|
|||||||
maxtime = deltat;
|
maxtime = deltat;
|
||||||
maxiter = (unsigned long)info->name->vpid;
|
maxiter = (unsigned long)info->name->vpid;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,8 +451,8 @@ int orte_pls_rsh_launch(orte_jobid_t jobid)
|
|||||||
int rc;
|
int rc;
|
||||||
sigset_t sigs;
|
sigset_t sigs;
|
||||||
struct passwd *p;
|
struct passwd *p;
|
||||||
bool remote_bash = false, remote_csh = false;
|
bool remote_sh = false, remote_csh = false;
|
||||||
bool local_bash = false, local_csh = false;
|
bool local_sh = false, local_csh = false;
|
||||||
char *lib_base = NULL, *bin_base = NULL;
|
char *lib_base = NULL, *bin_base = NULL;
|
||||||
orte_pls_daemon_info_t *dmn;
|
orte_pls_daemon_info_t *dmn;
|
||||||
|
|
||||||
@ -527,22 +540,43 @@ int orte_pls_rsh_launch(orte_jobid_t jobid)
|
|||||||
/* What is our local shell? */
|
/* What is our local shell? */
|
||||||
p = getpwuid(getuid());
|
p = getpwuid(getuid());
|
||||||
if (NULL != p) {
|
if (NULL != p) {
|
||||||
local_csh = (strstr(p->pw_shell, "csh") != 0) ? true : false;
|
int i = 0;
|
||||||
if ((strstr(p->pw_shell, "bash") != 0) ||
|
char *sh_name = NULL;
|
||||||
(strstr(p->pw_shell, "zsh") != 0)) {
|
|
||||||
local_bash = true;
|
sh_name = rindex(p->pw_shell, '/');
|
||||||
} else {
|
sh_name++;
|
||||||
local_bash = false;
|
for (i = 0; i < (int)(sizeof (orte_pls_rsh_shell_name)/
|
||||||
|
sizeof(orte_pls_rsh_shell_name[0])); i++) {
|
||||||
|
if ( 0 == strcmp(sh_name, orte_pls_rsh_shell_name[i]) ) {
|
||||||
|
switch (i) {
|
||||||
|
case ORTE_PLS_RSH_SHELL_SH: /* fall through */
|
||||||
|
case ORTE_PLS_RSH_SHELL_KSH: /* fall through */
|
||||||
|
case ORTE_PLS_RSH_SHELL_BASH: local_sh = true; break;
|
||||||
|
case ORTE_PLS_RSH_SHELL_TCSH: /* fall through */
|
||||||
|
case ORTE_PLS_RSH_SHELL_CSH: local_csh = true; break;
|
||||||
|
default:
|
||||||
|
opal_output(0, "WARNING: local probe returned unhandled shell:%s assuming bash\n",
|
||||||
|
orte_pls_rsh_shell_name[i]);
|
||||||
|
remote_sh = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if ( i == ORTE_PLS_RSH_SHELL_UNKNOWN ) {
|
||||||
|
opal_output(0, "WARNING: local probe returned unhandled shell:%s assuming bash\n",
|
||||||
|
orte_pls_rsh_shell_name[i]);
|
||||||
|
remote_sh = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mca_pls_rsh_component.debug) {
|
if (mca_pls_rsh_component.debug) {
|
||||||
opal_output(0, "pls:rsh: local csh: %d, local bash: %d\n",
|
opal_output(0, "pls:rsh: local csh: %d, local sh: %d\n",
|
||||||
local_csh, local_bash);
|
local_csh, local_sh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* What is our remote shell? */
|
/* What is our remote shell? */
|
||||||
if (mca_pls_rsh_component.assume_same_shell) {
|
if (mca_pls_rsh_component.assume_same_shell) {
|
||||||
remote_bash = local_bash;
|
remote_sh = local_sh;
|
||||||
remote_csh = local_csh;
|
remote_csh = local_csh;
|
||||||
if (mca_pls_rsh_component.debug) {
|
if (mca_pls_rsh_component.debug) {
|
||||||
opal_output(0, "pls:rsh: assuming same remote shell as local shell");
|
opal_output(0, "pls:rsh: assuming same remote shell as local shell");
|
||||||
@ -558,19 +592,20 @@ int orte_pls_rsh_launch(orte_jobid_t jobid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (shell) {
|
switch (shell) {
|
||||||
|
case ORTE_PLS_RSH_SHELL_SH: /* fall through */
|
||||||
case ORTE_PLS_RSH_SHELL_KSH: /* fall through */
|
case ORTE_PLS_RSH_SHELL_KSH: /* fall through */
|
||||||
case ORTE_PLS_RSH_SHELL_BASH: remote_bash = true; break;
|
case ORTE_PLS_RSH_SHELL_BASH: remote_sh = true; break;
|
||||||
case ORTE_PLS_RSH_SHELL_TCSH: /* fall through */
|
case ORTE_PLS_RSH_SHELL_TCSH: /* fall through */
|
||||||
case ORTE_PLS_RSH_SHELL_CSH: remote_csh = true; break;
|
case ORTE_PLS_RSH_SHELL_CSH: remote_csh = true; break;
|
||||||
default:
|
default:
|
||||||
opal_output(0, "WARNING: rsh probe returned unhandled shell:%s assuming bash\n",
|
opal_output(0, "WARNING: rsh probe returned unhandled shell:%s assuming bash\n",
|
||||||
orte_pls_rsh_shell_name[shell]);
|
orte_pls_rsh_shell_name[shell]);
|
||||||
remote_bash = true;
|
remote_sh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mca_pls_rsh_component.debug) {
|
if (mca_pls_rsh_component.debug) {
|
||||||
opal_output(0, "pls:rsh: remote csh: %d, remote bash: %d\n",
|
opal_output(0, "pls:rsh: remote csh: %d, remote sh: %d\n",
|
||||||
remote_csh, remote_bash);
|
remote_csh, remote_sh);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -583,9 +618,9 @@ int orte_pls_rsh_launch(orte_jobid_t jobid)
|
|||||||
|
|
||||||
/* Do we need to source .profile on the remote side? */
|
/* Do we need to source .profile on the remote side? */
|
||||||
|
|
||||||
if (!(remote_csh || remote_bash)) {
|
if (!(remote_csh || remote_sh)) {
|
||||||
int i;
|
int i;
|
||||||
tmp = opal_argv_split("( ! [ -e ./.profile ] || . ./.profile;", ' ');
|
tmp = opal_argv_split("( test ! -e ./.profile || . ./.profile;", ' ');
|
||||||
if (NULL == tmp) {
|
if (NULL == tmp) {
|
||||||
return ORTE_ERR_OUT_OF_RESOURCE;
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
||||||
}
|
}
|
||||||
@ -653,7 +688,7 @@ int orte_pls_rsh_launch(orte_jobid_t jobid)
|
|||||||
free(param);
|
free(param);
|
||||||
|
|
||||||
local_exec_index_end = argc;
|
local_exec_index_end = argc;
|
||||||
if (!(remote_csh || remote_bash)) {
|
if (!(remote_csh || remote_sh)) {
|
||||||
opal_argv_append(&argc, &argv, ")");
|
opal_argv_append(&argc, &argv, ")");
|
||||||
}
|
}
|
||||||
if (mca_pls_rsh_component.debug) {
|
if (mca_pls_rsh_component.debug) {
|
||||||
@ -913,7 +948,7 @@ int orte_pls_rsh_launch(orte_jobid_t jobid)
|
|||||||
exec_path = strdup(mca_pls_rsh_component.agent_path);
|
exec_path = strdup(mca_pls_rsh_component.agent_path);
|
||||||
|
|
||||||
if (NULL != prefix_dir) {
|
if (NULL != prefix_dir) {
|
||||||
if (remote_bash) {
|
if (remote_sh) {
|
||||||
asprintf (&argv[local_exec_index],
|
asprintf (&argv[local_exec_index],
|
||||||
"PATH=%s/%s:$PATH ; export PATH ; "
|
"PATH=%s/%s:$PATH ; export PATH ; "
|
||||||
"LD_LIBRARY_PATH=%s/%s:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
|
"LD_LIBRARY_PATH=%s/%s:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user