]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r322678: pw useradd: Validate the user name before creating the entry
authoremaste <emaste@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 8 Sep 2017 21:02:15 +0000 (21:02 +0000)
committeremaste <emaste@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 8 Sep 2017 21:02:15 +0000 (21:02 +0000)
commitf8cab4de53e9528998653b5e49d9b32340a115bf
tree31699ba7da871e65dd4210f79450c965564d9d75
parent93a9c0336c117cbe573448260ecb456efe9655ea
MFC r322678: pw useradd: Validate the user name before creating the entry

Previouly it was possible to create users with spaces in the name with:
pw useradd -u 1234 -g 1234 -n 'test user'

The "-g 1234" is relevant, without it the name was already rejected
as expected:

[fk@test ~]$ sudo pw useradd -u 1234 -n 'test user'
pw: invalid character ` ' at position 4 in userid/group name

Bug unintentionally found with a salt config without explicit name entry:

test user:
  user.present:
    - uid: 1234
    - gid: 1234
    - fullname: Test user
    - shell: /usr/local/bin/bash
    - home: /home/test
    - groups:
      - wheel
      - salt

"Luckily" salt modules rarely bother with input validation either ...

PR: 221416
Submitted by: Fabian Keil
Approved by: re (kib)
Obtained from: ElectroBSD

git-svn-id: svn://svn.freebsd.org/base/stable/10@323332 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
usr.sbin/pw/pw_user.c
usr.sbin/pw/tests/pw_useradd_test.sh