useradd crashes if group list contains whitespace
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Medium
|
Unassigned | ||
cloud-init (Ubuntu) |
Fix Released
|
Low
|
Unassigned | ||
Xenial |
Fix Released
|
Low
|
Unassigned | ||
Yakkety |
Fix Released
|
Low
|
Unassigned |
Bug Description
=== Begin SRU Template ===
[Impact]
A specific usage of user data to cloud-init will fail to add a user.
This cloud-config:
#cloud-config
users:
- default
- name: foobar
gecos: "My User"
groups: sudo, adm
Will fail with information in the cloud-init log showing:
2016-12-19 21:39:32,713 - util.py[WARNING]: Failed to create group adm
2016-12-19 21:39:32,713 - util.py[DEBUG]: Failed to create group adm
Traceback (most recent call last):
...
cloudinit.
Command: ['groupadd', ' adm']
Exit code: 3
Reason: -
Stdout: ''
Stderr: "groupadd: ' adm' is not a valid group name\n"
While changing the last line to the following would work:
groups: [sudo, adm]
[Test Case]
$ cat > user-data <<"EOF"
#cloud-config
users:
- default
- name: foobar
gecos: "My User"
groups: sudo, adm
- name: wark
groups: [sudo, adm]
EOF
$ release=yakkety
$ name="$
$ lxc launch "ubuntu-
"-
$ sleep 10
## Check foobar is in expected groups
$ lxc exec $name -- groups foobar
foobar : foobar adm sudo
$ lxc exec $name -- groups wark
wark : wark adm sudo
$ lxc exec $name -- grep WARN /var/log/
no warn
[Regression Potential]
There are 3 changes in this commit
a.) if 'groups' entry is a string, split on "," and strip pieces
The most likely path to failure here is if previously a non-string
(possibly bytes) was being passed in and now will be ignored.
That seems unlikely and clearly wrong input.
b.) fix and unit tests to explicitly set system=False or no_create_
Previously those paths did not test the value of the entry, only the
presense of the entry.
This meant that these 2 configs were the same:
users: {name: bob, system: True}
and
users: {name: bob, system: False}
That bug is fixed here so that 'system: False' is just explicitly
disabling the '--system' flag to adduser.
c.) debug message cleanup:
LOG.
LOG.
[Other Info]
Upstream commit at
https:/
=== End SRU Template ===
See downstream: https:/
Related branches
- Scott Moser: Needs Resubmitting
-
Diff: 202 lines (+160/-9)2 files modifiedcloudinit/distros/__init__.py (+13/-9)
tests/unittests/test_distros/test_create_users.py (+147/-0)
- Scott Moser: Pending requested
-
Diff: 13 lines (+1/-1)1 file modifiedcloudinit/distros/__init__.py (+1/-1)
Changed in cloud-init: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
Changed in cloud-init: | |
status: | Confirmed → Fix Committed |
Changed in cloud-init (Ubuntu): | |
status: | New → Fix Released |
importance: | Undecided → Low |
Changed in cloud-init (Ubuntu Yakkety): | |
status: | New → Confirmed |
importance: | Undecided → Low |
Changed in cloud-init (Ubuntu Xenial): | |
status: | New → Confirmed |
importance: | Undecided → Low |
description: | updated |
Changed in cloud-init: | |
status: | Confirmed → Fix Committed |
description: | updated |
Hi Scott,
I have now signed the contributor agreement.