]> git.ipfire.org Git - thirdparty/shadow.git/commit
usermod: Update passwd entry when shadowing entry
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 15 Mar 2026 23:31:47 +0000 (00:31 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 16 Mar 2026 11:03:04 +0000 (12:03 +0100)
commitfef30561bf497fc3b6241acdeb31fbc6b5407b20
treef5571b0a87b6e1301d1ac49153376ec134275c6c
parentd7164fc5998d461342b78aa722df1a2c6bf71e3b
usermod: Update passwd entry when shadowing entry

If a new shadow entry is created, the passwd entry's password hash is
moved into shadow file and replaced with an "x". If this happens, update
the passwd file as well, otherwise the "x" is not written to disk.

Resolves: https://github.com/shadow-maint/shadow/issues/1580

Reproducer (as root):
```
BASE=$(mktemp -d)
mkdir -p $BASE/etc
useradd -P $BASE user
touch $BASE/etc/shadow
usermod -P $BASE -e 0 user
cat $BASE/etc/passwd
```

Incorrect output (before):
```
user:!:1000:1000::/home/user:/bin/bash
```

Correct output (after):
```
user:x:1000:1000::/home/user:/bin/bash
```

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/usermod.c