[cloud-init/f22: 5/9] Fix handling of user group lists that contain spaces

gholms gholms at fedoraproject.org
Fri Feb 20 02:22:03 UTC 2015


commit a510c9bf0974a1a81bbc826bd3dac4d46537cdbb
Author: Garrett Holmstrom <gholms at devzero.com>
Date:   Thu Feb 19 16:24:11 2015 -0800

    Fix handling of user group lists that contain spaces
    
    https://bugs.launchpad.net/cloud-init/+bug/1354694
    https://bugzilla.redhat.com/show_bug.cgi?id=1126365

 cloud-init-0.7.6-groupadd-list.patch | 31 +++++++++++++++++++++++++++++++
 cloud-init.spec                      |  6 ++++++
 2 files changed, 37 insertions(+)
---
diff --git a/cloud-init-0.7.6-groupadd-list.patch b/cloud-init-0.7.6-groupadd-list.patch
new file mode 100644
index 0000000..ea71034
--- /dev/null
+++ b/cloud-init-0.7.6-groupadd-list.patch
@@ -0,0 +1,31 @@
+Index: cloud-init-0.7.6/cloudinit/distros/__init__.py
+===================================================================
+--- cloud-init-0.7.6.orig/cloudinit/distros/__init__.py
++++ cloud-init-0.7.6/cloudinit/distros/__init__.py
+@@ -328,11 +328,16 @@ class Distro(object):
+         }
+ 
+         redact_opts = ['passwd']
++        # Options that are comma separated lists which we need to parse
++        list_stripped_opts = ['groups']
+ 
+         # Check the values and create the command
+         for key, val in kwargs.iteritems():
+ 
+             if key in adduser_opts and val and isinstance(val, str):
++                if key in list_stripped_opts:
++                    values = [x.strip() for x in val.split(',')]
++                    val = ','.join(values)
+                 adduser_cmd.extend([adduser_opts[key], val])
+ 
+                 # Redact certain fields from the logs
+@@ -612,6 +617,9 @@ def _normalize_groups(grp_cfg):
+                             raise TypeError("Bad group member type %s" %
+                                             type_utils.obj_name(v))
+             elif isinstance(i, (str, basestring)):
++                # Common to have leading whitespace in string lists,
++                # but not all useradd tools will support it.-
++                i = i.strip()
+                 if i not in c_grp_cfg:
+                     c_grp_cfg[i] = []
+             else:
diff --git a/cloud-init.spec b/cloud-init.spec
index 1883267..68246ce 100644
--- a/cloud-init.spec
+++ b/cloud-init.spec
@@ -32,6 +32,11 @@ Patch2:         cloud-init-0.7.5-udevadm-quiet.patch
 # https://bugzilla.redhat.com/show_bug.cgi?id=1151824
 Patch3:         cloud-init-0.7.6-ecdsa.patch
 
+# Handle whitespace in lists of groups to add new users to
+# https://bugs.launchpad.net/cloud-init/+bug/1354694
+# https://bugzilla.redhat.com/show_bug.cgi?id=1126365
+Patch4:         cloud-init-0.7.6-groupadd-list.patch
+
 # Deal with noarch -> arch
 # https://bugzilla.redhat.com/show_bug.cgi?id=1067089
 Obsoletes:      cloud-init < 0.7.5-3
@@ -162,6 +167,7 @@ fi
 - Stopped depending on git to build
 - Stopped implicitly listing doc files twice
 - Added recognition of 3 ecdsa-sha2-nistp* ssh key types [RH:1151824]
+- Fixed handling of user group lists that contain spaces [RH:1126365 LP:1354694]
 
 * Fri Nov 14 2014 Colin Walters <walters at redhat.com> - 0.7.6-2
 - New upstream version [RH:974327]


More information about the scm-commits mailing list