]> git.ipfire.org Git - thirdparty/shadow.git/commit
passwd: handle NULL pw_passwd when printing password status 398/head
authorJaroslav Jindrak <dzejrou@gmail.com>
Tue, 3 Aug 2021 18:03:46 +0000 (20:03 +0200)
committerJaroslav Jindrak <dzejrou@gmail.com>
Tue, 3 Aug 2021 18:03:46 +0000 (20:03 +0200)
commit05388f748d650208f25f135d56a296afed0bea28
treeac37875c98ba64f866f503ace34ad23b0c0d99d8
parent065aae682c264fbd0bf6cad4a021e64304367365
passwd: handle NULL pw_passwd when printing password status

When the -S and -a options are used for passwd to list the status
of all passwords, there is a chance the pw_passwd field of struct
passwd will be NULL. This can be due to 'files compat' being set
for passwd in /etc/nsswitch.conf and the usage of some features
not available in the 'files' mode (e.g. a plus sign at the start
of a line).

Example:

germ161:~ # grep passwd /etc/nsswitch.conf
passwd: files compat
germ161:~ # rpm -qa shadow
shadow-4.2.1-34.20.x86_64
germ161:~ # grep passwd /etc/nsswitch.conf
passwd: files compat
germ161:~ # grep + /etc/passwd
+@nisgroup
germ161:~ # passwd -S -a > /dev/null
Segmentation fault (core dumped)

With this commit:

germ161:~ # passwd -S -a > /dev/null
passwd: malformed password data obtained for user +@nisgroup
src/passwd.c