← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1354694] Re: useradd crashes if group list contains whitespace

 

This bug was fixed in the package cloud-init - 0.7.9-0ubuntu1~16.04.2

---------------
cloud-init (0.7.9-0ubuntu1~16.04.2) xenial-proposed; urgency=medium

  * debian/update-grub-legacy-ec2: fix shell syntax error. (LP:
#1662221)

cloud-init (0.7.9-0ubuntu1~16.04.1) xenial-proposed; urgency=medium

  * debian/copyright: update License field to include Apache.
  * debian/update-grub-legacy-ec2: fix to include kernels whose config
    has CONFIG_XEN=y (LP: #1379080).
  * debian/patches/azure-use-walinux-agent.patch: continue relying on
    walinux agent in stable release.
  * New upstream release.
    - doc: adjust headers in tests documentation for consistency.
    - pep8: fix issue found in zesty build with pycodestyle.
    - integration test: initial commit of integration test framework
      [Wesley Wiedenmeier]
    - LICENSE: Allow dual licensing GPL-3 or Apache 2.0 [Jon Grimm]
    - Fix config order of precedence, putting kernel command line over system.
      [Wesley Wiedenmeier] (LP: #1582323)
    - pep8: whitespace fix [Scott Moser]
    - Update the list of valid ssh keys. [Michael Felt]
    - network: add ENI unit test for statically rendered routes.
    - set_hostname: avoid erroneously appending domain to fqdn
      [Lars Kellogg-Stedman] (LP: #1647910)
    - doc: change 'nobootwait' to 'nofail' in docs [Anhad Jai Singh]
    - Replace an expired bit.ly link in code comment. [Joshua Harlow]
    - user-groups: fix bug when groups was provided as string and had spaces
      [Scott Moser] (LP: #1354694)
    - when adding a user, strip whitespace from group list
      [Lars Kellogg-Stedman] (LP: #1354694)
    - fix decoding of utf-8 chars in yaml test
    - Replace usage of sys_netdev_info with read_sys_net
      [Joshua Harlow] (LP: #1625766)
    - fix problems found in python2.6 test. [Joshua Harlow]
    - Just use file logging by default [Joshua Harlow] (LP: #1643990)
    - Improve formatting for ProcessExecutionError [Wesley Wiedenmeier]
    - flake8: fix trailing white space
    - Doc: various documentation fixes [Sean Bright]
    - cloudinit/config/cc_rh_subscription.py: Remove repos before adding
      [Brent Baude]
    - packages/redhat: fix rpm spec file.
    - main: set TZ in environment if not already set. [Ryan Harper]

 -- Scott Moser <smoser@xxxxxxxxxx>  Mon, 06 Feb 2017 16:18:28 -0500

** Changed in: cloud-init (Ubuntu Xenial)
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1354694

Title:
  useradd crashes if group list contains whitespace

Status in cloud-init:
  Fix Released
Status in cloud-init package in Ubuntu:
  Fix Released
Status in cloud-init source package in Xenial:
  Fix Released
Status in cloud-init source package in Yakkety:
  Fix Released

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.util.ProcessExecutionError: Unexpected error while running command.
  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="$release-1354694"

  $ lxc launch "ubuntu-daily:$release" "$name" \
       "--config=user.user-data=$(cat user-data)"

  $ 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/cloud-init.log || echo "no warn"
  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_home=True.
      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.debug("created group %s for user %s", name, group)
     LOG.debug("created group '%s' for user '%s'", group, name)

  [Other Info]
  Upstream commit at
    https://git.launchpad.net/cloud-init/commit/?id=ca3ae67211d907b4cfdcd685c0ae4f9530cb7da1

  === End SRU Template ===

  See downstream: https://bugzilla.redhat.com/show_bug.cgi?id=1126365

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1354694/+subscriptions


References