Skip to content

Commit c1b8599

Browse files
author
Scott Miller
committed
plm/rsh: Add chdir option to change directory before orted exec
Signed-off-by: Scott Miller <[email protected]>
1 parent b6c4d5c commit c1b8599

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

orte/mca/plm/rsh/plm_rsh.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011 Los Alamos National Security, LLC. All rights
1313
* reserved.
1414
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
15-
* Copyright (c) 2011 IBM Corporation. All rights reserved.
15+
* Copyright (c) 2011-2019 IBM Corporation. All rights reserved.
1616
* Copyright (c) 2015-2018 Intel, Inc. All rights reserved.
1717
* $COPYRIGHT$
1818
*
@@ -66,6 +66,7 @@ struct orte_plm_rsh_component_t {
6666
bool pass_environ_mca_params;
6767
char *ssh_args;
6868
char *pass_libpath;
69+
char *chdir;
6970
};
7071
typedef struct orte_plm_rsh_component_t orte_plm_rsh_component_t;
7172

orte/mca/plm/rsh/plm_rsh_component.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copyright (c) 2010 Oracle and/or its affiliates. All rights
1717
* reserved.
1818
* Copyright (c) 2009-2018 Cisco Systems, Inc. All rights reserved
19-
* Copyright (c) 2011 IBM Corporation. All rights reserved.
19+
* Copyright (c) 2011-2019 IBM Corporation. All rights reserved.
2020
* Copyright (c) 2015-2018 Intel, Inc. All rights reserved.
2121
* $COPYRIGHT$
2222
*
@@ -223,6 +223,14 @@ static int rsh_component_register(void)
223223
MCA_BASE_VAR_SCOPE_READONLY,
224224
&mca_plm_rsh_component.pass_libpath);
225225

226+
mca_plm_rsh_component.chdir = NULL;
227+
(void) mca_base_component_var_register (c, "chdir",
228+
"Change working directory after rsh/ssh, but before exec of orted",
229+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
230+
OPAL_INFO_LVL_2,
231+
MCA_BASE_VAR_SCOPE_READONLY,
232+
&mca_plm_rsh_component.chdir);
233+
226234
return ORTE_SUCCESS;
227235
}
228236

orte/mca/plm/rsh/plm_rsh_module.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2007-2012 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
16-
* Copyright (c) 2011-2017 IBM Corporation. All rights reserved.
16+
* Copyright (c) 2011-2019 IBM Corporation. All rights reserved.
1717
* Copyright (c) 2014-2019 Intel, Inc. All rights reserved.
1818
* Copyright (c) 2015-2018 Research Organization for Information Science
1919
* and Technology (RIST). All rights reserved.
@@ -497,10 +497,13 @@ static int setup_launch(int *argcptr, char ***argvptr,
497497
* we have to insert the orted_prefix in the right place
498498
*/
499499
opal_asprintf (&final_cmd,
500-
"%s%s%s PATH=%s%s$PATH ; export PATH ; "
500+
"%s%s%s%s%s%s PATH=%s%s$PATH ; export PATH ; "
501501
"LD_LIBRARY_PATH=%s%s$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
502502
"DYLD_LIBRARY_PATH=%s%s$DYLD_LIBRARY_PATH ; export DYLD_LIBRARY_PATH ; "
503503
"%s %s",
504+
(NULL != mca_plm_rsh_component.chdir ? "cd " : " "),
505+
(NULL != mca_plm_rsh_component.chdir ? mca_plm_rsh_component.chdir : " "),
506+
(NULL != mca_plm_rsh_component.chdir ? " ; " : " "),
504507
(opal_prefix != NULL ? "OPAL_PREFIX=" : " "),
505508
(opal_prefix != NULL ? opal_prefix : " "),
506509
(opal_prefix != NULL ? " ; export OPAL_PREFIX;" : " "),
@@ -527,7 +530,7 @@ static int setup_launch(int *argcptr, char ***argvptr,
527530
* we have to insert the orted_prefix in the right place
528531
*/
529532
opal_asprintf (&final_cmd,
530-
"%s%s%s set path = ( %s $path ) ; "
533+
"%s%s%s%s%s%s set path = ( %s $path ) ; "
531534
"if ( $?LD_LIBRARY_PATH == 1 ) "
532535
"set OMPI_have_llp ; "
533536
"if ( $?LD_LIBRARY_PATH == 0 ) "
@@ -541,6 +544,9 @@ static int setup_launch(int *argcptr, char ***argvptr,
541544
"if ( $?OMPI_have_dllp == 1 ) "
542545
"setenv DYLD_LIBRARY_PATH %s%s$DYLD_LIBRARY_PATH ; "
543546
"%s %s",
547+
(NULL != mca_plm_rsh_component.chdir ? "cd " : " "),
548+
(NULL != mca_plm_rsh_component.chdir ? mca_plm_rsh_component.chdir : " "),
549+
(NULL != mca_plm_rsh_component.chdir ? " ; " : " "),
544550
(opal_prefix != NULL ? "setenv OPAL_PREFIX " : " "),
545551
(opal_prefix != NULL ? opal_prefix : " "),
546552
(opal_prefix != NULL ? " ;" : " "),

0 commit comments

Comments
 (0)