← Back to team overview

touch-packages team mailing list archive

[Bug 1321854] Re: useradd doesn't add the default shell to /etc/passwd entry

 

I found a possible culprit. Patch debian/patches/1000_configure_userns
swaps the order of `get_defaults`* and `process_flags`, but it's the job
of `process_flags` to read the defaults if they weren't overridden on
the command line. For instance, `process_flags` contains

```
        if (!gflg) {
                user_gid = def_group;
        }

        if (!sflg) {
                user_shell = def_shell;
        }
```

In fact, `process_flags` will end up doing that, but with the compiled-
in defaults. I'm not 100% sure I understand the patched code, but
***maybe*** the fix is as simple as restoring the order of instructions,
including of `is_sub_gid`; but I haven't read the logic for
`is_sub_gid`.

Here's the guilty patch fragment (not applicable):
```
--- shadow.orig/src/useradd.c   2014-02-16 19:31:38.934898148 -0500
+++ shadow/src/useradd.c        2014-02-16 19:31:38.926898149 -0500
[...]
-
-       get_defaults ();

        process_flags (argc, argv);

+       is_sub_uid = sub_uid_file_present () && !rflg &&
+           (!user_id || (user_id <= uid_max && user_id >= uid_min));
+       is_sub_gid = sub_gid_file_present () && !rflg &&
+           (!user_id || (user_id <= uid_max && user_id >= uid_min));
+
+       get_defaults ();
+
```

*I'm using Markdown syntax to distinguish code and text.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to shadow in Ubuntu.
https://bugs.launchpad.net/bugs/1321854

Title:
  useradd doesn't add the default shell to /etc/passwd entry

Status in shadow package in Ubuntu:
  Triaged
Status in shadow source package in Trusty:
  Triaged

Bug description:
  useradd is not honoring the default shell listed in
  /etc/defaults/useradd when creating new users.

  useradd -D showing the defaults. SHELL=/bin/bash

  # useradd -D
  GROUP=100
  HOME=/home
  INACTIVE=-1
  EXPIRE=
  SHELL=/bin/bash
  SKEL=/etc/skel
  CREATE_MAIL_SPOOL=no

  Using useradd to create user test1. The /etc/passwd entry has a blank
  shell field:

  # useradd test1
  # grep test1 /etc/passwd
  test1:x:2080:2080::/home/test1:

  Using useradd -s does populate the shell field:
  # useradd -s /bin/bash test2
  #grep test2 /etc/passwd
  test2:x:2081:2081::/home/test2:/bin/bash

  Why useradd instead of adduser: puppet uses useradd to do user
  creation.

  ProblemType: Bug
  DistroRelease: Ubuntu 14.04
  Package: passwd 1:4.1.5.1-1ubuntu9
  ProcVersionSignature: Ubuntu 3.13.0-24.47-generic 3.13.9
  Uname: Linux 3.13.0-24-generic x86_64
  ApportVersion: 2.14.1-0ubuntu3
  Architecture: amd64
  Date: Wed May 21 17:51:57 2014
  Ec2AMI: ami-42dc302a
  Ec2AMIManifest: (unknown)
  Ec2AvailabilityZone: us-east-1d
  Ec2InstanceType: m3.large
  Ec2Kernel: aki-919dcaf8
  Ec2Ramdisk: unavailable
  ProcEnviron:
   TERM=xterm
   PATH=(custom, no user)
   LANG=en_US.UTF-8
   SHELL=/bin/bash
  SourcePackage: shadow
  UpgradeStatus: No upgrade log present (probably fresh install)
  mtime.conffile..etc.default.useradd: 2014-05-21T17:36:05.208686

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1321854/+subscriptions