summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@fedoraproject.org>2014-01-20 17:12:53 +0100
committerTomas Mraz <tmraz@fedoraproject.org>2014-01-20 17:12:53 +0100
commit4eb04f3974b9245e31a59b0910c7b81ac5bc0496 (patch)
tree5e73d4af58a79bb79855741fa0b09598357176a6 /modules
parent2e62d5aea3f5ac267cfa54f0ea1f8c07ac85a95a (diff)
pam_limits: detect and ignore stale utmp entries
Original idea by Christopher Hailey * modules/pam_limits/pam_limits.c (check_logins): Use kill() to detect if pid of the utmp entry is still running and ignore the entry if it is not.
Diffstat (limited to 'modules')
-rw-r--r--modules/pam_limits/pam_limits.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/pam_limits/pam_limits.c b/modules/pam_limits/pam_limits.c
index 8bf3b9bb..e2bc8e18 100644
--- a/modules/pam_limits/pam_limits.c
+++ b/modules/pam_limits/pam_limits.c
@@ -27,6 +27,7 @@
#include <errno.h>
#include <syslog.h>
#include <stdarg.h>
+#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
@@ -279,6 +280,12 @@ check_logins (pam_handle_t *pamh, const char *name, int limit, int ctrl,
&& !pam_modutil_user_in_group_nam_nam(pamh, ut->UT_USER, pl->login_group)) {
continue;
}
+ if (kill(ut->ut_pid, 0) == -1 && errno == ESRCH) {
+ /* process does not exist anymore */
+ pam_syslog(pamh, LOG_WARNING,
+ "Stale utmp entry (pid %d) for '%s' ignored", ut->ut_pid, name);
+ continue;
+ }
}
if (++count > limit) {
break;