|
|
f2fdff |
diff -up Linux-PAM-1.1.8/modules/pam_limits/pam_limits.c.check-process Linux-PAM-1.1.8/modules/pam_limits/pam_limits.c
|
|
|
f2fdff |
--- Linux-PAM-1.1.8/modules/pam_limits/pam_limits.c.check-process 2013-06-18 16:11:21.000000000 +0200
|
|
|
f2fdff |
+++ Linux-PAM-1.1.8/modules/pam_limits/pam_limits.c 2014-09-10 16:39:36.263256066 +0200
|
|
|
f2fdff |
@@ -27,6 +27,7 @@
|
|
|
f2fdff |
#include <errno.h>
|
|
|
f2fdff |
#include <syslog.h>
|
|
|
f2fdff |
#include <stdarg.h>
|
|
|
f2fdff |
+#include <signal.h>
|
|
|
f2fdff |
#include <sys/types.h>
|
|
|
f2fdff |
#include <sys/stat.h>
|
|
|
f2fdff |
#include <sys/resource.h>
|
|
|
f2fdff |
@@ -269,16 +270,27 @@ check_logins (pam_handle_t *pamh, const
|
|
|
f2fdff |
continue;
|
|
|
f2fdff |
}
|
|
|
f2fdff |
if (!pl->flag_numsyslogins) {
|
|
|
f2fdff |
+ char user[sizeof(ut->UT_USER) + 1];
|
|
|
f2fdff |
+ user[0] = '\0';
|
|
|
f2fdff |
+ strncat(user, ut->UT_USER, sizeof(ut->UT_USER));
|
|
|
f2fdff |
+
|
|
|
f2fdff |
if (((pl->login_limit_def == LIMITS_DEF_USER)
|
|
|
f2fdff |
|| (pl->login_limit_def == LIMITS_DEF_GROUP)
|
|
|
f2fdff |
|| (pl->login_limit_def == LIMITS_DEF_DEFAULT))
|
|
|
f2fdff |
- && strncmp(name, ut->UT_USER, sizeof(ut->UT_USER)) != 0) {
|
|
|
f2fdff |
+ && strcmp(name, user) != 0) {
|
|
|
f2fdff |
continue;
|
|
|
f2fdff |
}
|
|
|
f2fdff |
if ((pl->login_limit_def == LIMITS_DEF_ALLGROUP)
|
|
|
f2fdff |
- && !pam_modutil_user_in_group_nam_nam(pamh, ut->UT_USER, pl->login_group)) {
|
|
|
f2fdff |
+ && !pam_modutil_user_in_group_nam_nam(pamh, user, pl->login_group)) {
|
|
|
f2fdff |
continue;
|
|
|
f2fdff |
}
|
|
|
f2fdff |
+ if (kill(ut->ut_pid, 0) == -1 && errno == ESRCH) {
|
|
|
f2fdff |
+ /* process does not exist anymore */
|
|
|
f2fdff |
+ pam_syslog(pamh, LOG_WARNING,
|
|
|
f2fdff |
+ "Stale utmp entry (pid %d) for '%s' ignored",
|
|
|
f2fdff |
+ ut->ut_pid, user);
|
|
|
f2fdff |
+ continue;
|
|
|
f2fdff |
+ }
|
|
|
f2fdff |
}
|
|
|
f2fdff |
if (++count > limit) {
|
|
|
f2fdff |
break;
|