14
14
* reserved.
15
15
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
16
16
* 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.
18
18
* Copyright (c) 2015 Research Organization for Information Science
19
19
* and Technology (RIST). All rights reserved.
20
20
* $COPYRIGHT$
@@ -339,7 +339,10 @@ static int setup_launch(int *argcptr, char ***argvptr,
339
339
int rc ;
340
340
int i , j ;
341
341
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
+
343
346
/* Figure out the basenames for the libdir and bindir. This
344
347
requires some explanation:
345
348
@@ -372,6 +375,15 @@ static int setup_launch(int *argcptr, char ***argvptr,
372
375
*/
373
376
argv = opal_argv_copy (rsh_agent_argv );
374
377
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
+ }
375
387
* node_name_index1 = argc ;
376
388
opal_argv_append (& argc , & argv , "<template>" );
377
389
@@ -431,7 +443,19 @@ static int setup_launch(int *argcptr, char ***argvptr,
431
443
orted_cmd = opal_argv_join_range (orted_argv , orted_index , opal_argv_count (orted_argv ), ' ' );
432
444
}
433
445
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
+
435
459
/* we now need to assemble the actual cmd that will be executed - this depends
436
460
* upon whether or not a prefix directory is being used
437
461
*/
@@ -440,25 +464,23 @@ static int setup_launch(int *argcptr, char ***argvptr,
440
464
* LD_LIBRARY_PATH on the remote node, and prepend just the orted_cmd
441
465
* with the prefix directory
442
466
*/
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 );
448
467
468
+ value = opal_basename (opal_install_dirs .bindir );
469
+ asprintf (& bin_base , "%s/%s" , prefix_dir , value );
470
+
449
471
if (NULL != orted_cmd ) {
450
472
if (0 == strcmp (orted_cmd , "orted" )) {
451
473
/* 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 );
453
475
} else {
454
476
/* someone specified something different, so don't prefix it */
455
477
full_orted_cmd = strdup (orted_cmd );
456
478
}
457
479
free (orted_cmd );
458
480
}
459
-
460
- lib_base = opal_basename (opal_install_dirs .libdir );
481
+ }
461
482
483
+ if (NULL != lib_base || NULL != bin_base ) {
462
484
if (ORTE_PLM_RSH_SHELL_SH == remote_shell ||
463
485
ORTE_PLM_RSH_SHELL_KSH == remote_shell ||
464
486
ORTE_PLM_RSH_SHELL_ZSH == remote_shell ||
@@ -468,16 +490,19 @@ static int setup_launch(int *argcptr, char ***argvptr,
468
490
* we have to insert the orted_prefix in the right place
469
491
*/
470
492
(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 ; "
474
496
"%s %s" ,
475
497
(opal_prefix != NULL ? "OPAL_PREFIX=" : " " ),
476
498
(opal_prefix != NULL ? opal_prefix : " " ),
477
499
(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 ? ":" : " " ),
481
506
(orted_prefix != NULL ? orted_prefix : " " ),
482
507
(full_orted_cmd != NULL ? full_orted_cmd : " " ));
483
508
} else if (ORTE_PLM_RSH_SHELL_TCSH == remote_shell ||
@@ -495,42 +520,52 @@ static int setup_launch(int *argcptr, char ***argvptr,
495
520
* we have to insert the orted_prefix in the right place
496
521
*/
497
522
(void )asprintf (& final_cmd ,
498
- "%s%s%s set path = ( %s/%s $path ) ; "
523
+ "%s%s%s set path = ( %s $path ) ; "
499
524
"if ( $?LD_LIBRARY_PATH == 1 ) "
500
525
"set OMPI_have_llp ; "
501
526
"if ( $?LD_LIBRARY_PATH == 0 ) "
502
- "setenv LD_LIBRARY_PATH %s/%s ; "
527
+ "setenv LD_LIBRARY_PATH %s ; "
503
528
"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 ; "
505
530
"if ( $?DYLD_LIBRARY_PATH == 1 ) "
506
531
"set OMPI_have_dllp ; "
507
532
"if ( $?DYLD_LIBRARY_PATH == 0 ) "
508
- "setenv DYLD_LIBRARY_PATH %s/%s ; "
533
+ "setenv DYLD_LIBRARY_PATH %s ; "
509
534
"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 ; "
511
536
"%s %s" ,
512
537
(opal_prefix != NULL ? "setenv OPAL_PREFIX " : " " ),
513
538
(opal_prefix != NULL ? opal_prefix : " " ),
514
539
(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 ? ":" : " " ),
520
547
(orted_prefix != NULL ? orted_prefix : " " ),
521
548
(full_orted_cmd != NULL ? full_orted_cmd : " " ));
522
549
} else {
523
550
orte_show_help ("help-plm-rsh.txt" , "cannot-resolve-shell-with-prefix" , true,
524
551
(NULL == opal_prefix ) ? "NULL" : opal_prefix ,
525
552
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
+ }
528
559
if (NULL != orted_prefix ) free (orted_prefix );
529
560
if (NULL != full_orted_cmd ) free (full_orted_cmd );
530
561
return ORTE_ERR_SILENT ;
531
562
}
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
+ }
534
569
if ( NULL != full_orted_cmd ) {
535
570
free (full_orted_cmd );
536
571
}
@@ -589,7 +624,7 @@ static int setup_launch(int *argcptr, char ***argvptr,
589
624
continue ;
590
625
}
591
626
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
593
628
* would have been placed there by the
594
629
* cmd line processor. By convention, we
595
630
* always let the cmd line override the
0 commit comments