diff options
author | Shreenidhi Shedi <sshedi@vmware.com> | 2022-07-01 12:00:23 +0530 |
---|---|---|
committer | Shreenidhi Shedi <53473811+sshedi@users.noreply.github.com> | 2022-07-01 16:16:04 +0530 |
commit | df0d27720e578a37b46ec938efff4f7ec4cdcb6c (patch) | |
tree | 343e1d78411f36870f0e3a5f0fff888c1dbeda30 | |
parent | 42404548721c653317c911c83d885e2fc7fbca70 (diff) | |
download | pam-df0d27720e578a37b46ec938efff4f7ec4cdcb6c.tar.gz pam-df0d27720e578a37b46ec938efff4f7ec4cdcb6c.tar.bz2 pam-df0d27720e578a37b46ec938efff4f7ec4cdcb6c.zip |
faillock: error out if user does not exist
No need to do any further processing if a non existent username is given
to faillock.
For first time successful login, failure field should be 0 and faillock
should show something like pam_tally2 did.
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
-rw-r--r-- | modules/pam_faillock/main.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/pam_faillock/main.c b/modules/pam_faillock/main.c index 35208870..a5e2cd60 100644 --- a/modules/pam_faillock/main.c +++ b/modules/pam_faillock/main.c @@ -137,8 +137,12 @@ do_user(struct options *opts, const char *user) const char *dir = get_tally_dir(opts); pwd = getpwnam(user); + if (pwd == NULL) { + fprintf(stderr, "%s: Error no such user: %s\n", opts->progname, user); + return 1; + } - fd = open_tally(dir, user, pwd != NULL ? pwd->pw_uid : 0, 0); + fd = open_tally(dir, user, pwd->pw_uid, 1); if (fd == -1) { if (errno == ENOENT) { |