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
This commit is contained in:
Garrett Holmstrom 2015-02-19 16:24:11 -08:00
parent 0a23a4d1f9
commit a510c9bf09
2 changed files with 37 additions and 0 deletions

View File

@ -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:

View File

@ -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@redhat.com> - 0.7.6-2
- New upstream version [RH:974327]