]> xenbits.xensource.com Git - people/royger/osstest.git/commitdiff
PDU: ipmi: Use arrays rather than strings for cmd
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 11 Jul 2018 14:26:45 +0000 (14:26 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 11 Jul 2018 14:53:53 +0000 (15:53 +0100)
This allows arguments with spaces, etc.

No functional change with the existing configurations I know about.
It would be good to fix this before any configurations are created
where this would make a difference...

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/PDU/ipmi.pm

index dbf211f7d7b6bb5d8fa36dfa14da7bacbb907da7..f3a50c9ac57bb09bc5c94302365440dc0e787338 100644 (file)
@@ -49,11 +49,17 @@ sub pdu_power_state {
     my ($mo, $on) = @_;
     my $onoff= $on ? "on" : "off";
 
-    my $cmd = "ipmitool -H $mo->{Mgmt} -U $mo->{User} -P $mo->{Pass}";
+    my @cmd = (qw(ipmitool -H), $mo->{Mgmt},
+               '-U',$mo->{User}, '-P',$mo->{Pass});
 
     my $getstatus = sub {
-        my $status = `$cmd power status`
-            or die "Cannot retrieve current power status";
+        my @scmd = (@cmd, qw(power status));
+        logm("PDU IMPI: @scmd");
+        open IPMI, "-|", @scmd or die $!;
+        my $status = do { local $/=undef; <IPMI>; };
+        $?=0; $!=0;
+        close IPMI and $status or
+            die "Cannot retrieve current power status ($? $!)";
         chomp($status);
         logm("$status (want $onoff)");
         $status =~ s/^Chassis Power is (on|off)$/$1/
@@ -66,7 +72,7 @@ sub pdu_power_state {
        return;
     }
 
-    system_checked("$cmd power $onoff");
+    system_checked((@cmd, qw(power), $onoff));
 
     my $count = 60;
     for (;;) {