[pve-devel] [PATCH 06/09] Explicite use user root when making ssh call.

mir at datanom.net mir at datanom.net
Sun Aug 25 01:29:45 CEST 2013


From: Michael Rasmussen <mir at datanom.net>

Signed-off-by: Michael Rasmussen <mir at datanom.net>
---
 PVE/Storage/ZFSPlugin.pm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 0ec6632..a562635 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -19,6 +19,7 @@ sub zfs_request {
 	my $cmd;
 	my $msg = '';
 	my $zfs;
+	my $target;
 	
 	my $output = sub {
 		my $line = shift;
@@ -39,9 +40,14 @@ sub zfs_request {
 		die 'unknown iscsi provider. Available [comstar]';
 	}
 	
-	$luncmd->{cmd} = 'sudo ' . $luncmd->{cmd} if ($scfg->{sudo});
+	if ($scfg->{sudo}) {
+			$luncmd->{cmd} = 'sudo ' . $luncmd->{cmd};
+			$target = $scfg->{portal};
+	} else {
+			$target = 'root@' . $scfg->{portal};
+	}
 	if ($luncmd->{$method}) {
-		$cmd = [@ssh_cmd, $scfg->{portal}, $luncmd->{cmd}, $luncmd->{$method}, @params];
+		$cmd = [@ssh_cmd, $target, $luncmd->{cmd}, $luncmd->{$method}, @params];
 	} else {
 		if ($method =~ /^zpool-list$/) {
 			$zfs = 'zpool';
@@ -49,7 +55,7 @@ sub zfs_request {
 		} else {
 			$zfs = 'zfs';
 		}
-		$cmd = [@ssh_cmd, $scfg->{portal}, $zfs, $method, @params];
+		$cmd = [@ssh_cmd, $target, $zfs, $method, @params];
 	}
 	
 	eval {
-- 
1.8.4.rc3




More information about the pve-devel mailing list