Skip to content

Commit 55527ab

Browse files
authored
Merge pull request open-mpi#7125 from sam6258/smiller_rsh_chdir_v4.0.x
plm/rsh: Add chdir option to change directory before orted exec
2 parents 3dba9ec + 8eae54f commit 55527ab

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 Intel, Inc. All rights reserved.
1717
* $COPYRIGHT$
1818
*
@@ -65,6 +65,7 @@ struct orte_plm_rsh_component_t {
6565
bool pass_environ_mca_params;
6666
char *ssh_args;
6767
char *pass_libpath;
68+
char *chdir;
6869
};
6970
typedef struct orte_plm_rsh_component_t orte_plm_rsh_component_t;
7071

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-2016 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-2017 Intel, Inc. All rights reserved.
2121
* $COPYRIGHT$
2222
*
@@ -222,6 +222,14 @@ static int rsh_component_register(void)
222222
MCA_BASE_VAR_SCOPE_READONLY,
223223
&mca_plm_rsh_component.pass_libpath);
224224

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

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-2018 Intel, Inc. All rights reserved.
1818
* Copyright (c) 2015-2018 Research Organization for Information Science
1919
* and Technology (RIST). All rights reserved.
@@ -501,10 +501,13 @@ static int setup_launch(int *argcptr, char ***argvptr,
501501
* we have to insert the orted_prefix in the right place
502502
*/
503503
(void)asprintf (&final_cmd,
504-
"%s%s%s PATH=%s%s$PATH ; export PATH ; "
504+
"%s%s%s%s%s%s PATH=%s%s$PATH ; export PATH ; "
505505
"LD_LIBRARY_PATH=%s%s$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
506506
"DYLD_LIBRARY_PATH=%s%s$DYLD_LIBRARY_PATH ; export DYLD_LIBRARY_PATH ; "
507507
"%s %s",
508+
(NULL != mca_plm_rsh_component.chdir ? "cd " : " "),
509+
(NULL != mca_plm_rsh_component.chdir ? mca_plm_rsh_component.chdir : " "),
510+
(NULL != mca_plm_rsh_component.chdir ? " ; " : " "),
508511
(opal_prefix != NULL ? "OPAL_PREFIX=" : " "),
509512
(opal_prefix != NULL ? opal_prefix : " "),
510513
(opal_prefix != NULL ? " ; export OPAL_PREFIX;" : " "),
@@ -531,7 +534,7 @@ static int setup_launch(int *argcptr, char ***argvptr,
531534
* we have to insert the orted_prefix in the right place
532535
*/
533536
(void)asprintf (&final_cmd,
534-
"%s%s%s set path = ( %s $path ) ; "
537+
"%s%s%s%s%s%s set path = ( %s $path ) ; "
535538
"if ( $?LD_LIBRARY_PATH == 1 ) "
536539
"set OMPI_have_llp ; "
537540
"if ( $?LD_LIBRARY_PATH == 0 ) "
@@ -545,6 +548,9 @@ static int setup_launch(int *argcptr, char ***argvptr,
545548
"if ( $?OMPI_have_dllp == 1 ) "
546549
"setenv DYLD_LIBRARY_PATH %s%s$DYLD_LIBRARY_PATH ; "
547550
"%s %s",
551+
(NULL != mca_plm_rsh_component.chdir ? "cd " : " "),
552+
(NULL != mca_plm_rsh_component.chdir ? mca_plm_rsh_component.chdir : " "),
553+
(NULL != mca_plm_rsh_component.chdir ? " ; " : " "),
548554
(opal_prefix != NULL ? "setenv OPAL_PREFIX " : " "),
549555
(opal_prefix != NULL ? opal_prefix : " "),
550556
(opal_prefix != NULL ? " ;" : " "),

0 commit comments

Comments
 (0)