From: nekral-guest Date: Sun, 17 May 2009 16:27:29 +0000 (+0000) Subject: * src/userdel.c (user_busy): Check if the process registered in X-Git-Tag: 4.1.4.1~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3343c1d9b85b431821da23989a0b0c5e20e1871;p=shadow * src/userdel.c (user_busy): Check if the process registered in utmp is still running. This avoids rejecting the removal of an user when UTMP was not updated and indicate that the user is still logged in. --- diff --git a/ChangeLog b/ChangeLog index b71a1d50..df2f1cdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-05-17 Nicolas François + + * src/userdel.c (user_busy): Check if the process registered in + utmp is still running. This avoids rejecting the removal of an + user when UTMP was not updated and indicate that the user is still + logged in. + 2009-05-16 Nicolas François * NEWS, libmisc/console.c (console): Remove the leading /dev/ from diff --git a/src/userdel.c b/src/userdel.c index c341d027..aca65243 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -602,14 +602,19 @@ static void user_busy (const char *name, uid_t uid) while ((utent = getutent ()) != NULL) #endif /* !USE_UTMPX */ { - if (utent->ut_type != USER_PROCESS) + if (utent->ut_type != USER_PROCESS) { continue; - + } if (strncmp (utent->ut_user, name, sizeof utent->ut_user) != 0) { continue; } + if (kill (utent->ut_pid, 0) != 0) { + continue; + } + fprintf (stderr, - _("%s: user %s is currently logged in\n"), Prog, name); + _("%s: user %s is currently logged in\n"), + Prog, name); if (!fflg) { #ifdef WITH_AUDIT audit_logger (AUDIT_DEL_USER, Prog,