Changeset 1952 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Mar 5, 2015, 3:37:57 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r1943 r1952 2870 2870 next; 2871 2871 } 2872 2872 2873 2873 2874 $pm->finish if (defined $pbparallel); … … 3047 3048 } 3048 3049 pb_log(2,"DEBUG: pb_launchv returns ($vexist,$vpid)\n"); 3050 3051 # After the VM is launched, then setup the SSH access 3052 pb_ssh_setup($vtype,$nport); 3049 3053 3050 # Skip that VM /RMif something went wrong3054 # Skip that VM if something went wrong 3051 3055 return($vexist,$vpid) if (($vpid == 0) && ($vexist == 0)); 3052 3056 … … 3064 3068 } else { 3065 3069 # Get RM context 3066 my ($ptr,$rmpath ) = pb_conf_get("rmtype","rmpath");3070 my ($ptr,$rmpath,$rmport) = pb_conf_get("rmtype","rmpath","rmport"); 3067 3071 3068 3072 # Nothing more to do for RM. No real launch … … 3071 3075 $vexist = 0; 3072 3076 $vpid = 0; 3077 3078 # After the RM is launched, then setup the SSH access 3079 my $nport = pb_get_port($rmport,$pbos,$vtype); 3080 pb_ssh_setup($vtype,$nport); 3073 3081 } 3074 3082 … … 3491 3499 # Do not use the one passed potentially with -a 3492 3500 my ($pbac) = pb_conf_get($vtype."login"); 3493 my ($key,$zero0,$zero1,$zero2);3501 my $key = ""; 3494 3502 3495 3503 # Prepare the script to be executed on the VM/VE/RM … … 3530 3538 EOF 3531 3539 3532 my $keyfile; 3533 my $nport; 3534 my $vmhost; 3535 3536 # Prepare the key to be used and transfered remotely 3537 $keyfile = pb_ssh_get(1); 3538 3539 if ($vtype =~ /(v|r)m/) { 3540 my ($vmport); 3541 ($vmhost,$vmport) = pb_conf_get($vtype."host",$vtype."port"); 3542 $nport = pb_get_port($vmport,$pbos,$vtype); 3543 3544 # Store the pub key part in a variable 3545 open(FILE,"$keyfile.pub") || die "Unable to open $keyfile.pub"; 3546 ($zero0,$zero1,$zero2) = split(/ /,<FILE>); 3547 close(FILE); 3548 3549 $key = "\Q$zero1"; 3550 3551 # We call true to avoid problems if SELinux is not activated, but chcon is present and returns in that case 1 3552 pb_system("cat $keyfile.pub | ssh -q -o UserKnownHostsFile=/dev/null -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir -p .ssh ; chmod 700 .ssh ; cat >> .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys ; if [ -x /usr/bin/chcon ]; then /usr/bin/chcon -Rt home_ssh_t .ssh 2> /dev/null; /bin/true; fi\"","Copying local keys to $vtype. This may require the root password"); 3553 # once this is done, we can do what we need on the VM/RM remotely 3554 } elsif ($vtype eq "ve") { 3540 if ($vtype eq "ve") { 3555 3541 $vetype = pb_ve_get_type($vetype); 3556 3542 if ($vetype ne "docker") { … … 3565 3551 EOF 3566 3552 print SCRIPT "pb_system('rm -f /dev/null; mknod /dev/null c 1 3; chmod 777 /dev/null');\n" unless (($pbos->{'name'} =~ /^redhat/) && ($pbos->{'version'} =~ /^6/)); 3553 } elsif ($vtype =~ /(v|r)m/) { 3554 my $keyfile; 3555 my ($zero0,$zero1,$zero2); 3556 3557 # Prepare the key to be used and transfered remotely 3558 $keyfile = pb_ssh_get(1); 3559 3560 # Store the pub key part in a variable 3561 open(FILE,"$keyfile.pub") || die "Unable to open $keyfile.pub"; 3562 ($zero0,$zero1,$zero2) = split(/ /,<FILE>); 3563 close(FILE); 3564 3565 $key = "\Q$zero1"; 3567 3566 } else { 3568 3567 die "Unknown virtual type $vtype"; … … 3728 3727 print SCRIPT << "EOF"; 3729 3728 # Some distro force requiretty at compile time, so disable here 3730 print PBOUT "Defaults:$pbac->{$ENV{'PBPROJ'}} !requiretty\ n";3731 print PBOUT "Defaults:root !requiretty\ n";3729 print PBOUT "Defaults:$pbac->{$ENV{'PBPROJ'}} !requiretty\\n"; 3730 print PBOUT "Defaults:root !requiretty\\n"; 3732 3731 EOF 3733 3732 # RH 6.2 sudo doesn't support env_keep … … 3735 3734 print SCRIPT << "EOF"; 3736 3735 # Keep proxy configuration while using sudo 3737 print PBOUT "Defaults:$pbac->{$ENV{'PBPROJ'}} env_keep += \\\"http_proxy ftp_proxy\\\"\ n";3738 print PBOUT "Defaults:root env_keep += \\\"http_proxy ftp_proxy\\\"\ n";3736 print PBOUT "Defaults:$pbac->{$ENV{'PBPROJ'}} env_keep += \\\"http_proxy ftp_proxy\\\"\\n"; 3737 print PBOUT "Defaults:root env_keep += \\\"http_proxy ftp_proxy\\\"\\n"; 3739 3738 EOF 3740 3739 } … … 3930 3929 pb_log(2,"DEBUG: before parallel launch, pbscript hash is:".Dumper(%pbscript)."\n"); 3931 3930 pb_parallel_launchv(\%pbscript,$vtype,uc($vtype)."Script".$sbx,$pbstep,$pbforce); 3931 3932 3932 return; 3933 3933 } … … 4891 4891 } 4892 4892 4893 sub pb_ssh_setup { 4894 4895 my $vtype = shift; 4896 my $nport = shift; 4897 4898 my $keyfile; 4899 my $vmhost; 4900 4901 ($vmhost) = pb_conf_get($vtype."host"); 4902 # Prepare the key to be used and transfered remotely 4903 $keyfile = pb_ssh_get(1); 4904 4905 # We call true to avoid problems if SELinux is not activated, but chcon is present and returns in that case 1 4906 pb_system("cat $keyfile.pub | ssh -q -o UserKnownHostsFile=/dev/null -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir -p .ssh ; chmod 700 .ssh ; cat >> .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys ; if [ -x /usr/bin/chcon ]; then /usr/bin/chcon -Rt home_ssh_t .ssh 2> /dev/null; /bin/true; fi\"","Copying local keys to $vtype. This may require the root password"); 4907 # once this is done, we can do what we need on the VM/RM remotely 4908 return; 4909 } 4893 4910 4894 4911 1;
Note:
See TracChangeset
for help on using the changeset viewer.