commit 4eb04f3974b9245e31a59b0910c7b81ac5bc0496
Author: Tomas Mraz <tmraz(a)fedoraproject.org>
Date: Mon Jan 20 17:12:53 2014 +0100
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.
modules/pam_limits/pam_limits.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/modules/pam_limits/pam_limits.c b/modules/pam_limits/pam_limits.c
index 8bf3b9b..e2bc8e1 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;
Show replies by date