Hello,
On Sun, May 10, 2009 at 05:29:28PM +0200, [email protected] wrote:
>
> Following these steps, I systematically am prevented to deluser foobar:
> - on tty1 as root, adduser foobar, password foo
> - on tty2, login as foobar/foo, then ^D to logout
> - on tty1 as root, deluser foobar:
> Removing user `foobar' ...
> Warning: group `foobar' has no more members.
> userdel: user foobar is currently logged in
> /usr/sbin/deluser: `/usr/sbin/userdel foobar' returned error code 8.
> Exiting.
I cannot reproduce it.
I just remember already reading about this kind of bug, so it would be
nice to have more information.
Did you make changes in one of:
/etc/login.defs
/etc/pam.d/login
/etc/pam.d/common-session
(and maybe some other pam.d files)
> I reproduce with "userdel foobar" and if I strace it, I see one of the
> last actions before the message is to open /var/run/utmp.
>
> pgrep -u foobar yields no process and "who" and "w" don't show any
> session from foobar; "last foobar" doesn't show this user as logged in
> either.
>
> If I login on tty2 with another user, I can deluser foobar.
>
> I suspect the parsing of utmp is broken since both w and who get it
> right.
it would be nice to get the utmp entry for tty2.
Can check with the attached C file, after you have logged out foobar?
Best Regards,
--
Nekral
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <utmp.h>
int main (void)
{
struct utmp *utent;
setutent ();
while ((utent = getutent ()) != NULL)
{
if (strcmp (utent->ut_line, "tty2") == 0)
{
printf ("ut_type: %d\n", utent->ut_type);
printf ("ut_user: %s\n", utent->ut_user);
printf ("ut_id: %.4s\n", utent->ut_id);
}
}
endutent ();
/* Here's what deluser do: */
printf ("userdel check\n");
setutent ();
while ((utent = getutent ()) != NULL)
{
if (utent->ut_type != USER_PROCESS)
continue;
if (strcmp (utent->ut_user, "foobar") != 0)
continue;
fprintf (stderr,
"user %s is currently logged in\n",
"foobar");
}
endutent ();
return 0;
}