From 8eae54fd27ed460af9530bebbe34ddd9ea2efc59 Mon Sep 17 00:00:00 2001 From: Scott Miller Date: Mon, 14 Oct 2019 12:46:24 -0400 Subject: [PATCH] plm/rsh: Add chdir option to change directory before orted exec Signed-off-by: Scott Miller (cherry picked from commit c1b8599528feaac3c1d9ad44f0113f65eb7cc97f) Conflicts: orte/mca/plm/rsh/plm_rsh_module.c --- orte/mca/plm/rsh/plm_rsh.h | 3 ++- orte/mca/plm/rsh/plm_rsh_component.c | 10 +++++++++- orte/mca/plm/rsh/plm_rsh_module.c | 12 +++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/orte/mca/plm/rsh/plm_rsh.h b/orte/mca/plm/rsh/plm_rsh.h index c523b99c55..1b858e8921 100644 --- a/orte/mca/plm/rsh/plm_rsh.h +++ b/orte/mca/plm/rsh/plm_rsh.h @@ -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 Intel, Inc. All rights reserved. * $COPYRIGHT$ * @@ -65,6 +65,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; diff --git a/orte/mca/plm/rsh/plm_rsh_component.c b/orte/mca/plm/rsh/plm_rsh_component.c index bb87725bef..c78f0c0251 100644 --- a/orte/mca/plm/rsh/plm_rsh_component.c +++ b/orte/mca/plm/rsh/plm_rsh_component.c @@ -16,7 +16,7 @@ * Copyright (c) 2010 Oracle and/or its affiliates. All rights * reserved. * Copyright (c) 2009-2016 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-2017 Intel, Inc. All rights reserved. * $COPYRIGHT$ * @@ -222,6 +222,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; } diff --git a/orte/mca/plm/rsh/plm_rsh_module.c b/orte/mca/plm/rsh/plm_rsh_module.c index d022fe51c2..0a795f077d 100644 --- a/orte/mca/plm/rsh/plm_rsh_module.c +++ b/orte/mca/plm/rsh/plm_rsh_module.c @@ -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-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -501,10 +501,13 @@ 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 ; " + "%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;" : " "), @@ -531,7 +534,7 @@ 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 $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 ) " @@ -545,6 +548,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 ? " ;" : " "),