Bug 1126365 - cloud-init does not work with whitespace in user: directive for multiple groups
cloud-init does not work with whitespace in user: directive for multiple groups
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: cloud-init (Show other bugs)
22
Unspecified Unspecified
unspecified Severity high
: ---
: ---
Assigned To: Garrett Holmstrom
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-08-04 05:38 EDT by Brian (bex) Exelbierd
Modified: 2015-03-12 13:49 EDT (History)
9 users (show)

See Also:
Fixed In Version: cloud-init-0.7.6-3.fc22
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-12 13:49:43 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Launchpad 1354694 None None None Never

  None (edit)
Description Brian (bex) Exelbierd 2014-08-04 05:38:49 EDT
Description of problem:

When creating a new user, I cannot specify multiple groups:

users:
  - default
  - name: foobar
    gecos: User N. Ame
    groups: wheel, adm

Version-Release number of selected component (if applicable):

Fedora-Atomic based on rawhide

cloud-init - 9.7.5

How reproducible:

Everytime

Steps to Reproduce:
1. use above user-data snippet
2. boot VM
3. cat /etc/group and see nothing added for user foobar

Actual results:

No groups for user foobar, other than default group

Expected results:

user foobar in default group, wheel, and adm

Additional info:

This works for a single group specified as:

group: wheel

This also fails for

group: wheel adm
group: [wheel adm]
group: [wheel, adm]

Not having this makes it hard to add sudoers
Comment 1 Matthew Miller 2014-08-04 06:07:39 EDT
Does

  groups: wheel,adm

*no space* work?

It does for me, although I'm not using atomic. *Not* having a space does fail, though, on F20. (I think this is a general cloud-init bug. What's happening is that it's passing the data to useradd as a string, so with a space useradd gets

  --groups "wheel, adm"

and then complains that there is no " adm" group. 

So, cloud-init should probably strip those spaces.
Comment 2 Brian (bex) Exelbierd 2014-08-04 06:15:20 EDT
*no space* works.

Upstream shows it with a space: 

http://cloudinit.readthedocs.org/en/latest/topics/examples.html

I support having cloud-init strip those spaces.
Comment 3 Matthew Miller 2014-08-04 07:38:29 EDT
I suspect that it works on Ubuntu/Debian because of differences in the user creation command-line tool called. This is possibly actually a useradd bug -- since groupadd won't create groups with spaces, it's kind of silly for useradd to try and add people to them.
Comment 4 Matthew Miller 2014-08-04 07:46:27 EDT
I filed bug #1126411 as an RFE for useradd, but I think this should still be fixed in cloud-init. (I notice that the useradd man page documents that spaces aren't allowed.)
Comment 5 Colin Walters 2014-08-04 15:02:45 EDT
Testing this patch now:

$ bzr diff
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py	2014-02-12 19:56:55 +0000
+++ cloudinit/distros/__init__.py	2014-08-04 18:58:51 +0000
@@ -612,6 +612,9 @@
                             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:


An updated RPM should show up in http://copr.fedoraproject.org/coprs/walters/atomic-next/build/24544/
Comment 6 Colin Walters 2014-08-09 09:43:39 EDT
Upstream bug with tested patch:

https://bugs.launchpad.net/cloud-init/+bug/1354694
Comment 7 Garrett Holmstrom 2015-02-23 17:28:49 EST
This should be fixed in cloud-init-0.7.6-3.fc22.  cloud-init-0.7.6-4.20140218bzr1060.fc22 will be pushed shortly with some major changes, so it may be worth testing against that instead.
Comment 8 Garrett Holmstrom 2015-02-23 17:39:15 EST
Update:  cloud-init-0.7.6-4.20140218bzr1060.fc22 isn't going to make it into F22 due to bug 1194577.  If you're testing rawhide it will appear there, but otherwise feel free to go ahead and test cloud-init-0.7.6-3.fc22.  Sorry about the confusion.
Comment 9 Jaroslav Reznik 2015-03-03 12:18:54 EST
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Note You need to log in before you can comment on or make changes to this bug.