From 7670572578b4d1e86167e6818f857a2cc855e589 Mon Sep 17 00:00:00 2001 From: Antti Rasinen Date: Tue, 16 Jul 2013 13:49:19 +0300 Subject: [PATCH 1/2] Fix zfs property parsing Current property parser breaks when values contain spaces. Since zfs get -H returns tab separated lines, it is better to explicitly split on tabs than on whitespace. --- library/system/zfs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/system/zfs b/library/system/zfs index 2428320313e..162ac797418 100644 --- a/library/system/zfs +++ b/library/system/zfs @@ -316,9 +316,9 @@ class Zfs(object): cmd.append('get -H all') cmd.append(self.name) rc, out, err = self.module.run_command(' '.join(cmd)) - properties=dict() + properties = dict() for l in out.splitlines(): - p, v = l.split()[1:3] + p, v = l.split('\t')[1:3] properties[p] = v return properties From 7b8f24addab89a588a72c768a2e8df9c83d5493f Mon Sep 17 00:00:00 2001 From: Antti Rasinen Date: Tue, 16 Jul 2013 14:01:14 +0300 Subject: [PATCH 2/2] Make zfs set_property accept values with embedded spaces Converting the argument list to a string with ' '.join causes the shell interpreter to misparse spaces in property values. Since the zfs command does not need shell anywhere, using a list instead of a string works just as well with run_command. Fixes #3545. --- library/system/zfs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/library/system/zfs b/library/system/zfs index 162ac797418..a981f13e44e 100644 --- a/library/system/zfs +++ b/library/system/zfs @@ -292,11 +292,9 @@ class Zfs(object): if self.module.check_mode: self.changed = True return - cmd = [self.module.get_bin_path('zfs', True)] - cmd.append('set') - cmd.append(prop + '=' + value) - cmd.append(self.name) - (rc, err, out) = self.module.run_command(' '.join(cmd)) + cmd = self.module.get_bin_path('zfs', True) + args = [cmd, 'set', prop + '=' + value, self.name] + (rc, err, out) = self.module.run_command(args) if rc == 0: self.changed = True else: