Skip to content

Commit 55ddd6d

Browse files
author
rhc54
committed
Merge pull request #539 from rhc54/topic/rsh
Redo in cleaner form: update capabilities of ssh launch
2 parents 9392bb5 + 12bfb27 commit 55ddd6d

File tree

3 files changed

+86
-32
lines changed

3 files changed

+86
-32
lines changed

orte/mca/plm/rsh/plm_rsh.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* reserved.
1414
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
1515
* Copyright (c) 2011 IBM Corporation. All rights reserved.
16+
* Copyright (c) 2015 Intel, Inc. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -62,6 +63,8 @@ struct orte_plm_rsh_component_t {
6263
char *agent;
6364
bool assume_same_shell;
6465
bool pass_environ_mca_params;
66+
char *ssh_args;
67+
char *pass_libpath;
6568
};
6669
typedef struct orte_plm_rsh_component_t orte_plm_rsh_component_t;
6770

orte/mca/plm/rsh/plm_rsh_component.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
1818
* Copyright (c) 2011 IBM Corporation. All rights reserved.
19+
* Copyright (c) 2015 Intel, Inc. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -201,6 +202,21 @@ static int rsh_component_register(void)
201202
OPAL_INFO_LVL_9,
202203
MCA_BASE_VAR_SCOPE_READONLY,
203204
&mca_plm_rsh_component.pass_environ_mca_params);
205+
mca_plm_rsh_component.ssh_args = NULL;
206+
(void) mca_base_component_var_register (c, "args",
207+
"Arguments to add to rsh/ssh",
208+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
209+
OPAL_INFO_LVL_9,
210+
MCA_BASE_VAR_SCOPE_READONLY,
211+
&mca_plm_rsh_component.ssh_args);
212+
213+
mca_plm_rsh_component.pass_libpath = NULL;
214+
(void) mca_base_component_var_register (c, "pass_libpath",
215+
"Prepend the specified library path to the remote shell's LD_LIBRARY_PATH",
216+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
217+
OPAL_INFO_LVL_9,
218+
MCA_BASE_VAR_SCOPE_READONLY,
219+
&mca_plm_rsh_component.pass_libpath);
204220

205221
return ORTE_SUCCESS;
206222
}

orte/mca/plm/rsh/plm_rsh_module.c

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* reserved.
1515
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
1616
* Copyright (c) 2011 IBM Corporation. All rights reserved.
17-
* Copyright (c) 2014 Intel Corporation. All rights reserved.
17+
* Copyright (c) 2014-2015 Intel Corporation. All rights reserved.
1818
* Copyright (c) 2015 Research Organization for Information Science
1919
* and Technology (RIST). All rights reserved.
2020
* $COPYRIGHT$
@@ -339,7 +339,10 @@ static int setup_launch(int *argcptr, char ***argvptr,
339339
int rc;
340340
int i, j;
341341
bool found;
342-
342+
char *lib_base=NULL, *bin_base=NULL;
343+
char *opal_prefix = getenv("OPAL_PREFIX");
344+
char* full_orted_cmd = NULL;
345+
343346
/* Figure out the basenames for the libdir and bindir. This
344347
requires some explanation:
345348
@@ -372,6 +375,15 @@ static int setup_launch(int *argcptr, char ***argvptr,
372375
*/
373376
argv = opal_argv_copy(rsh_agent_argv);
374377
argc = opal_argv_count(rsh_agent_argv);
378+
/* if any ssh args were provided, now is the time to add them */
379+
if (NULL != mca_plm_rsh_component.ssh_args) {
380+
char **ssh_argv;
381+
ssh_argv = opal_argv_split(mca_plm_rsh_component.ssh_args, ' ');
382+
for (i=0; NULL != ssh_argv[i]; i++) {
383+
opal_argv_append(&argc, &argv, ssh_argv[i]);
384+
}
385+
opal_argv_free(ssh_argv);
386+
}
375387
*node_name_index1 = argc;
376388
opal_argv_append(&argc, &argv, "<template>");
377389

@@ -431,7 +443,19 @@ static int setup_launch(int *argcptr, char ***argvptr,
431443
orted_cmd = opal_argv_join_range(orted_argv, orted_index, opal_argv_count(orted_argv), ' ');
432444
}
433445
opal_argv_free(orted_argv); /* done with this */
434-
446+
447+
/* if the user specified a library path to pass, set it up now */
448+
param = opal_basename(opal_install_dirs.libdir);
449+
if (NULL != mca_plm_rsh_component.pass_libpath) {
450+
if (NULL != prefix_dir) {
451+
asprintf(&lib_base, "%s:%s/%s", mca_plm_rsh_component.pass_libpath, prefix_dir, param);
452+
} else {
453+
asprintf(&lib_base, "%s:%s", mca_plm_rsh_component.pass_libpath, param);
454+
}
455+
} else if (NULL != prefix_dir) {
456+
asprintf(&lib_base, "%s/%s", prefix_dir, param);
457+
}
458+
435459
/* we now need to assemble the actual cmd that will be executed - this depends
436460
* upon whether or not a prefix directory is being used
437461
*/
@@ -440,25 +464,23 @@ static int setup_launch(int *argcptr, char ***argvptr,
440464
* LD_LIBRARY_PATH on the remote node, and prepend just the orted_cmd
441465
* with the prefix directory
442466
*/
443-
char *opal_prefix = getenv("OPAL_PREFIX");
444-
char* full_orted_cmd = NULL;
445-
char *lib_base, *bin_base;
446-
447-
bin_base = opal_basename(opal_install_dirs.bindir);
448467

468+
value = opal_basename(opal_install_dirs.bindir);
469+
asprintf(&bin_base, "%s/%s", prefix_dir, value);
470+
449471
if (NULL != orted_cmd) {
450472
if (0 == strcmp(orted_cmd, "orted")) {
451473
/* if the cmd is our standard one, then add the prefix */
452-
(void)asprintf(&full_orted_cmd, "%s/%s/%s", prefix_dir, bin_base, orted_cmd);
474+
(void)asprintf(&full_orted_cmd, "%s/%s", bin_base, orted_cmd);
453475
} else {
454476
/* someone specified something different, so don't prefix it */
455477
full_orted_cmd = strdup(orted_cmd);
456478
}
457479
free(orted_cmd);
458480
}
459-
460-
lib_base = opal_basename(opal_install_dirs.libdir);
481+
}
461482

483+
if (NULL != lib_base || NULL != bin_base) {
462484
if (ORTE_PLM_RSH_SHELL_SH == remote_shell ||
463485
ORTE_PLM_RSH_SHELL_KSH == remote_shell ||
464486
ORTE_PLM_RSH_SHELL_ZSH == remote_shell ||
@@ -468,16 +490,19 @@ static int setup_launch(int *argcptr, char ***argvptr,
468490
* we have to insert the orted_prefix in the right place
469491
*/
470492
(void)asprintf (&final_cmd,
471-
"%s%s%s PATH=%s/%s:$PATH ; export PATH ; "
472-
"LD_LIBRARY_PATH=%s/%s:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
473-
"DYLD_LIBRARY_PATH=%s/%s:$DYLD_LIBRARY_PATH ; export DYLD_LIBRARY_PATH ; "
493+
"%s%s%s PATH=%s%s$PATH ; export PATH ; "
494+
"LD_LIBRARY_PATH=%s%s$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH ; "
495+
"DYLD_LIBRARY_PATH=%s%s$DYLD_LIBRARY_PATH ; export DYLD_LIBRARY_PATH ; "
474496
"%s %s",
475497
(opal_prefix != NULL ? "OPAL_PREFIX=" : " "),
476498
(opal_prefix != NULL ? opal_prefix : " "),
477499
(opal_prefix != NULL ? " ; export OPAL_PREFIX;" : " "),
478-
prefix_dir, bin_base,
479-
prefix_dir, lib_base,
480-
prefix_dir, lib_base,
500+
(NULL != bin_base ? bin_base : " "),
501+
(NULL != bin_base ? ":" : " "),
502+
(NULL != lib_base ? lib_base : " "),
503+
(NULL != lib_base ? ":" : " "),
504+
(NULL != lib_base ? lib_base : " "),
505+
(NULL != lib_base ? ":" : " "),
481506
(orted_prefix != NULL ? orted_prefix : " "),
482507
(full_orted_cmd != NULL ? full_orted_cmd : " "));
483508
} else if (ORTE_PLM_RSH_SHELL_TCSH == remote_shell ||
@@ -495,42 +520,52 @@ static int setup_launch(int *argcptr, char ***argvptr,
495520
* we have to insert the orted_prefix in the right place
496521
*/
497522
(void)asprintf (&final_cmd,
498-
"%s%s%s set path = ( %s/%s $path ) ; "
523+
"%s%s%s set path = ( %s $path ) ; "
499524
"if ( $?LD_LIBRARY_PATH == 1 ) "
500525
"set OMPI_have_llp ; "
501526
"if ( $?LD_LIBRARY_PATH == 0 ) "
502-
"setenv LD_LIBRARY_PATH %s/%s ; "
527+
"setenv LD_LIBRARY_PATH %s ; "
503528
"if ( $?OMPI_have_llp == 1 ) "
504-
"setenv LD_LIBRARY_PATH %s/%s:$LD_LIBRARY_PATH ; "
529+
"setenv LD_LIBRARY_PATH %s%s$LD_LIBRARY_PATH ; "
505530
"if ( $?DYLD_LIBRARY_PATH == 1 ) "
506531
"set OMPI_have_dllp ; "
507532
"if ( $?DYLD_LIBRARY_PATH == 0 ) "
508-
"setenv DYLD_LIBRARY_PATH %s/%s ; "
533+
"setenv DYLD_LIBRARY_PATH %s ; "
509534
"if ( $?OMPI_have_dllp == 1 ) "
510-
"setenv DYLD_LIBRARY_PATH %s/%s:$DYLD_LIBRARY_PATH ; "
535+
"setenv DYLD_LIBRARY_PATH %s%s$DYLD_LIBRARY_PATH ; "
511536
"%s %s",
512537
(opal_prefix != NULL ? "setenv OPAL_PREFIX " : " "),
513538
(opal_prefix != NULL ? opal_prefix : " "),
514539
(opal_prefix != NULL ? " ;" : " "),
515-
prefix_dir, bin_base,
516-
prefix_dir, lib_base,
517-
prefix_dir, lib_base,
518-
prefix_dir, lib_base,
519-
prefix_dir, lib_base,
540+
(NULL != bin_base ? bin_base : " "),
541+
(NULL != lib_base ? lib_base : " "),
542+
(NULL != lib_base ? lib_base : " "),
543+
(NULL != lib_base ? ":" : " "),
544+
(NULL != lib_base ? lib_base : " "),
545+
(NULL != lib_base ? lib_base : " "),
546+
(NULL != lib_base ? ":" : " "),
520547
(orted_prefix != NULL ? orted_prefix : " "),
521548
(full_orted_cmd != NULL ? full_orted_cmd : " "));
522549
} else {
523550
orte_show_help("help-plm-rsh.txt", "cannot-resolve-shell-with-prefix", true,
524551
(NULL == opal_prefix) ? "NULL" : opal_prefix,
525552
prefix_dir);
526-
free(bin_base);
527-
free(lib_base);
553+
if (NULL != bin_base) {
554+
free(bin_base);
555+
}
556+
if (NULL != lib_base) {
557+
free(lib_base);
558+
}
528559
if (NULL != orted_prefix) free(orted_prefix);
529560
if (NULL != full_orted_cmd) free(full_orted_cmd);
530561
return ORTE_ERR_SILENT;
531562
}
532-
free(bin_base);
533-
free(lib_base);
563+
if (NULL != bin_base) {
564+
free(bin_base);
565+
}
566+
if (NULL != lib_base) {
567+
free(lib_base);
568+
}
534569
if( NULL != full_orted_cmd ) {
535570
free(full_orted_cmd);
536571
}
@@ -589,7 +624,7 @@ static int setup_launch(int *argcptr, char ***argvptr,
589624
continue;
590625
}
591626
if (0 == strncmp(OPAL_MCA_PREFIX, environ[i], 9)) {
592-
/* check for duplicate in app->env - this
627+
/* check for duplicate in app->env - this
593628
* would have been placed there by the
594629
* cmd line processor. By convention, we
595630
* always let the cmd line override the

0 commit comments

Comments
 (0)