Bug 1126365 - cloud-init does not work with whitespace in user: directive for multiple groups
Summary: cloud-init does not work with whitespace in user: directive for multiple groups
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: cloud-init
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Garrett Holmstrom
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-04 09:38 UTC by Brian (bex) Exelbierd
Modified: 2015-03-12 17:49 UTC (History)
9 users (show)

Fixed In Version: cloud-init-0.7.6-3.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-12 17:49:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Launchpad 1354694 0 None None None Never

Description Brian (bex) Exelbierd 2014-08-04 09:38:49 UTC
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 10:07:39 UTC
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 10:15:20 UTC
*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 11:38:29 UTC
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 11:46:27 UTC
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 19:02:45 UTC
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 13:43:39 UTC
Upstream bug with tested patch:

https://bugs.launchpad.net/cloud-init/+bug/1354694

Comment 7 Garrett Holmstrom 2015-02-23 22:28:49 UTC
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 22:39:15 UTC
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 17:18:54 UTC
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.