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