1
1

Redo in cleaner form: Per request from Andy Rieb, add ability to pass PATH and LD_LIBRARY_PATH elements to ssh command

Этот коммит содержится в:
Ralph Castain 2015-04-16 17:18:37 -06:00
родитель 790edd404c
Коммит 12bfb27161
3 изменённых файлов: 86 добавлений и 32 удалений

Просмотреть файл

@ -13,6 +13,7 @@
* reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2011 IBM Corporation. All rights reserved.
* Copyright (c) 2015 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -62,6 +63,8 @@ struct orte_plm_rsh_component_t {
char *agent;
bool assume_same_shell;
bool pass_environ_mca_params;
char *ssh_args;
char *pass_libpath;
};
typedef struct orte_plm_rsh_component_t orte_plm_rsh_component_t;

Просмотреть файл

@ -16,6 +16,7 @@
* reserved.
* Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011 IBM Corporation. All rights reserved.
* Copyright (c) 2015 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -201,6 +202,21 @@ static int rsh_component_register(void)
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_plm_rsh_component.pass_environ_mca_params);
mca_plm_rsh_component.ssh_args = NULL;
(void) mca_base_component_var_register (c, "args",
"Arguments to add to rsh/ssh",
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_plm_rsh_component.ssh_args);
mca_plm_rsh_component.pass_libpath = NULL;
(void) mca_base_component_var_register (c, "pass_libpath",
"Prepend the specified library path to the remote shell's LD_LIBRARY_PATH",
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_plm_rsh_component.pass_libpath);
return ORTE_SUCCESS;
}

Просмотреть файл

@ -14,7 +14,7 @@
* reserved.
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2011 IBM Corporation. All rights reserved.
* Copyright (c) 2014 Intel Corporation. All rights reserved.
* Copyright (c) 2014-2015 Intel Corporation. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
@ -339,7 +339,10 @@ static int setup_launch(int *argcptr, char ***argvptr,
int rc;
int i, j;
bool found;
char *lib_base=NULL, *bin_base=NULL;
char *opal_prefix = getenv("OPAL_PREFIX");
char* full_orted_cmd = NULL;
/* Figure out the basenames for the libdir and bindir. This
requires some explanation:
@ -372,6 +375,15 @@ static int setup_launch(int *argcptr, char ***argvptr,
*/
argv = opal_argv_copy(rsh_agent_argv);
argc = opal_argv_count(rsh_agent_argv);
/* if any ssh args were provided, now is the time to add them */
if (NULL != mca_plm_rsh_component.ssh_args) {
char **ssh_argv;
ssh_argv = opal_argv_split(mca_plm_rsh_component.ssh_args, ' ');
for (i=0; NULL != ssh_argv[i]; i++) {
opal_argv_append(&argc, &argv, ssh_argv[i]);
}
opal_argv_free(ssh_argv);
}
*node_name_index1 = argc;
opal_argv_append(&argc, &argv, "<template>");
@ -431,7 +443,19 @@ static int setup_launch(int *argcptr, char ***argvptr,
orted_cmd = opal_argv_join_range(orted_argv, orted_index, opal_argv_count(orted_argv), ' ');
}
opal_argv_free(orted_argv); /* done with this */
/* if the user specified a library path to pass, set it up now */
param = opal_basename(opal_install_dirs.libdir);
if (NULL != mca_plm_rsh_component.pass_libpath) {
if (NULL != prefix_dir) {
asprintf(&lib_base, "%s:%s/%s", mca_plm_rsh_component.pass_libpath, prefix_dir, param);
} else {
asprintf(&lib_base, "%s:%s", mca_plm_rsh_component.pass_libpath, param);
}
} else if (NULL != prefix_dir) {
asprintf(&lib_base, "%s/%s", prefix_dir, param);
}
/* we now need to assemble the actual cmd that will be executed - this depends
* upon whether or not a prefix directory is being used
*/
@ -440,25 +464,23 @@ static int setup_launch(int *argcptr, char ***argvptr,
* LD_LIBRARY_PATH on the remote node, and prepend just the orted_cmd
* with the prefix directory
*/
char *opal_prefix = getenv("OPAL_PREFIX");
char* full_orted_cmd = NULL;
char *lib_base, *bin_base;
bin_base = opal_basename(opal_install_dirs.bindir);
value = opal_basename(opal_install_dirs.bindir);
asprintf(&bin_base, "%s/%s", prefix_dir, value);
if (NULL != orted_cmd) {
if (0 == strcmp(orted_cmd, "orted")) {
/* if the cmd is our standard one, then add the prefix */
(void)asprintf(&full_orted_cmd, "%s/%s/%s", prefix_dir, bin_base, orted_cmd);
(void)asprintf(&full_orted_cmd, "%s/%s", bin_base, orted_cmd);
} else {
/* someone specified something different, so don't prefix it */
full_orted_cmd = strdup(orted_cmd);
}
free(orted_cmd);
}
lib_base = opal_basename(opal_install_dirs.libdir);
}
if (NULL != lib_base || NULL != bin_base) {
if (ORTE_PLM_RSH_SHELL_SH == remote_shell ||
ORTE_PLM_RSH_SHELL_KSH == remote_shell ||
ORTE_PLM_RSH_SHELL_ZSH == remote_shell ||
@ -468,16 +490,19 @@ static int setup_launch(int *argcptr, char ***argvptr,
* we have to insert the orted_prefix in the right place
*/
(void)asprintf (&final_cmd,
"%s%s%s PATH=%s/%s:$PATH ; export PATH ; "
"LD_LIBRARY_PATH=%s/%s:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
"DYLD_LIBRARY_PATH=%s/%s:$DYLD_LIBRARY_PATH ; export DYLD_LIBRARY_PATH ; "
"%s%s%s PATH=%s%s$PATH ; export PATH ; "
"LD_LIBRARY_PATH=%s%s$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
"DYLD_LIBRARY_PATH=%s%s$DYLD_LIBRARY_PATH ; export DYLD_LIBRARY_PATH ; "
"%s %s",
(opal_prefix != NULL ? "OPAL_PREFIX=" : " "),
(opal_prefix != NULL ? opal_prefix : " "),
(opal_prefix != NULL ? " ; export OPAL_PREFIX;" : " "),
prefix_dir, bin_base,
prefix_dir, lib_base,
prefix_dir, lib_base,
(NULL != bin_base ? bin_base : " "),
(NULL != bin_base ? ":" : " "),
(NULL != lib_base ? lib_base : " "),
(NULL != lib_base ? ":" : " "),
(NULL != lib_base ? lib_base : " "),
(NULL != lib_base ? ":" : " "),
(orted_prefix != NULL ? orted_prefix : " "),
(full_orted_cmd != NULL ? full_orted_cmd : " "));
} else if (ORTE_PLM_RSH_SHELL_TCSH == remote_shell ||
@ -495,42 +520,52 @@ static int setup_launch(int *argcptr, char ***argvptr,
* we have to insert the orted_prefix in the right place
*/
(void)asprintf (&final_cmd,
"%s%s%s set path = ( %s/%s $path ) ; "
"%s%s%s set path = ( %s $path ) ; "
"if ( $?LD_LIBRARY_PATH == 1 ) "
"set OMPI_have_llp ; "
"if ( $?LD_LIBRARY_PATH == 0 ) "
"setenv LD_LIBRARY_PATH %s/%s ; "
"setenv LD_LIBRARY_PATH %s ; "
"if ( $?OMPI_have_llp == 1 ) "
"setenv LD_LIBRARY_PATH %s/%s:$LD_LIBRARY_PATH ; "
"setenv LD_LIBRARY_PATH %s%s$LD_LIBRARY_PATH ; "
"if ( $?DYLD_LIBRARY_PATH == 1 ) "
"set OMPI_have_dllp ; "
"if ( $?DYLD_LIBRARY_PATH == 0 ) "
"setenv DYLD_LIBRARY_PATH %s/%s ; "
"setenv DYLD_LIBRARY_PATH %s ; "
"if ( $?OMPI_have_dllp == 1 ) "
"setenv DYLD_LIBRARY_PATH %s/%s:$DYLD_LIBRARY_PATH ; "
"setenv DYLD_LIBRARY_PATH %s%s$DYLD_LIBRARY_PATH ; "
"%s %s",
(opal_prefix != NULL ? "setenv OPAL_PREFIX " : " "),
(opal_prefix != NULL ? opal_prefix : " "),
(opal_prefix != NULL ? " ;" : " "),
prefix_dir, bin_base,
prefix_dir, lib_base,
prefix_dir, lib_base,
prefix_dir, lib_base,
prefix_dir, lib_base,
(NULL != bin_base ? bin_base : " "),
(NULL != lib_base ? lib_base : " "),
(NULL != lib_base ? lib_base : " "),
(NULL != lib_base ? ":" : " "),
(NULL != lib_base ? lib_base : " "),
(NULL != lib_base ? lib_base : " "),
(NULL != lib_base ? ":" : " "),
(orted_prefix != NULL ? orted_prefix : " "),
(full_orted_cmd != NULL ? full_orted_cmd : " "));
} else {
orte_show_help("help-plm-rsh.txt", "cannot-resolve-shell-with-prefix", true,
(NULL == opal_prefix) ? "NULL" : opal_prefix,
prefix_dir);
free(bin_base);
free(lib_base);
if (NULL != bin_base) {
free(bin_base);
}
if (NULL != lib_base) {
free(lib_base);
}
if (NULL != orted_prefix) free(orted_prefix);
if (NULL != full_orted_cmd) free(full_orted_cmd);
return ORTE_ERR_SILENT;
}
free(bin_base);
free(lib_base);
if (NULL != bin_base) {
free(bin_base);
}
if (NULL != lib_base) {
free(lib_base);
}
if( NULL != full_orted_cmd ) {
free(full_orted_cmd);
}
@ -589,7 +624,7 @@ static int setup_launch(int *argcptr, char ***argvptr,
continue;
}
if (0 == strncmp(OPAL_MCA_PREFIX, environ[i], 9)) {
/* check for duplicate in app->env - this
/* check for duplicate in app->env - this
* would have been placed there by the
* cmd line processor. By convention, we
* always let the cmd line override the