Skip to content

Commit

Permalink
plm/rsh: Add chdir option to change directory before orted exec
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Miller <scott.miller1@ibm.com>
  • Loading branch information
Scott Miller committed Oct 15, 2019
1 parent b6c4d5c commit c1b8599
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion orte/mca/plm/rsh/plm_rsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2011 IBM Corporation. All rights reserved.
* Copyright (c) 2011-2019 IBM Corporation. All rights reserved.
* Copyright (c) 2015-2018 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -66,6 +66,7 @@ struct orte_plm_rsh_component_t {
bool pass_environ_mca_params;
char *ssh_args;
char *pass_libpath;
char *chdir;
};
typedef struct orte_plm_rsh_component_t orte_plm_rsh_component_t;

Expand Down
10 changes: 9 additions & 1 deletion orte/mca/plm/rsh/plm_rsh_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Copyright (c) 2010 Oracle and/or its affiliates. All rights
* reserved.
* Copyright (c) 2009-2018 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2011 IBM Corporation. All rights reserved.
* Copyright (c) 2011-2019 IBM Corporation. All rights reserved.
* Copyright (c) 2015-2018 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -223,6 +223,14 @@ static int rsh_component_register(void)
MCA_BASE_VAR_SCOPE_READONLY,
&mca_plm_rsh_component.pass_libpath);

mca_plm_rsh_component.chdir = NULL;
(void) mca_base_component_var_register (c, "chdir",
"Change working directory after rsh/ssh, but before exec of orted",
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
OPAL_INFO_LVL_2,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_plm_rsh_component.chdir);

return ORTE_SUCCESS;
}

Expand Down
12 changes: 9 additions & 3 deletions orte/mca/plm/rsh/plm_rsh_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Copyright (c) 2007-2012 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2011-2017 IBM Corporation. All rights reserved.
* Copyright (c) 2011-2019 IBM Corporation. All rights reserved.
* Copyright (c) 2014-2019 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
Expand Down Expand Up @@ -497,10 +497,13 @@ static int setup_launch(int *argcptr, char ***argvptr,
* we have to insert the orted_prefix in the right place
*/
opal_asprintf (&final_cmd,
"%s%s%s PATH=%s%s$PATH ; export PATH ; "
"%s%s%s%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",
(NULL != mca_plm_rsh_component.chdir ? "cd " : " "),
(NULL != mca_plm_rsh_component.chdir ? mca_plm_rsh_component.chdir : " "),
(NULL != mca_plm_rsh_component.chdir ? " ; " : " "),
(opal_prefix != NULL ? "OPAL_PREFIX=" : " "),
(opal_prefix != NULL ? opal_prefix : " "),
(opal_prefix != NULL ? " ; export OPAL_PREFIX;" : " "),
Expand All @@ -527,7 +530,7 @@ static int setup_launch(int *argcptr, char ***argvptr,
* we have to insert the orted_prefix in the right place
*/
opal_asprintf (&final_cmd,
"%s%s%s set path = ( %s $path ) ; "
"%s%s%s%s%s%s set path = ( %s $path ) ; "
"if ( $?LD_LIBRARY_PATH == 1 ) "
"set OMPI_have_llp ; "
"if ( $?LD_LIBRARY_PATH == 0 ) "
Expand All @@ -541,6 +544,9 @@ static int setup_launch(int *argcptr, char ***argvptr,
"if ( $?OMPI_have_dllp == 1 ) "
"setenv DYLD_LIBRARY_PATH %s%s$DYLD_LIBRARY_PATH ; "
"%s %s",
(NULL != mca_plm_rsh_component.chdir ? "cd " : " "),
(NULL != mca_plm_rsh_component.chdir ? mca_plm_rsh_component.chdir : " "),
(NULL != mca_plm_rsh_component.chdir ? " ; " : " "),
(opal_prefix != NULL ? "setenv OPAL_PREFIX " : " "),
(opal_prefix != NULL ? opal_prefix : " "),
(opal_prefix != NULL ? " ;" : " "),
Expand Down

0 comments on commit c1b8599

Please sign in to comment.