diff options
author | Anton D. Kachalov <rnouse@google.com> | 2020-09-29 23:20:57 +0200 |
---|---|---|
committer | Tomáš Mráz <tmraz@redhat.com> | 2020-09-30 18:37:00 +0200 |
commit | e21fd1f344a67844925ab9a06b0f54299c94b56c (patch) | |
tree | bd24ad22b46c997d5e18be8c14374b295e2d0436 /modules/pam_unix/unix_chkpwd.c | |
parent | a3a5cbf86083c43026b558e2023f597530626267 (diff) | |
download | pam-e21fd1f344a67844925ab9a06b0f54299c94b56c.tar.gz pam-e21fd1f344a67844925ab9a06b0f54299c94b56c.tar.bz2 pam-e21fd1f344a67844925ab9a06b0f54299c94b56c.zip |
Prevent SEGFAULT for unknown UID
When running systemd service with DynamicUser being set, the dynamic UID
might be not mapped to user name (/etc/nsswitch.conf is not configured
with systemd nss module).
The getuidname() routine might return NULL and this is not checked by callee.
Signed-off-by: Anton D. Kachalov <rnouse@google.com>
Diffstat (limited to 'modules/pam_unix/unix_chkpwd.c')
-rw-r--r-- | modules/pam_unix/unix_chkpwd.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/pam_unix/unix_chkpwd.c b/modules/pam_unix/unix_chkpwd.c index 15a1c2a8..3931bab2 100644 --- a/modules/pam_unix/unix_chkpwd.c +++ b/modules/pam_unix/unix_chkpwd.c @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) user = getuidname(getuid()); /* if the caller specifies the username, verify that user matches it */ - if (strcmp(user, argv[1])) { + if (user == NULL || strcmp(user, argv[1])) { user = argv[1]; /* no match -> permanently change to the real user and proceed */ if (setuid(getuid()) != 0) |