Comment 0 for bug 1556516

Revision history for this message
Jeff Norden (norden-jeff) wrote : passwd and group entries are not removed on logout

When a guest session is finished, the guest-xxxx entries don't get removed from /etc/passwd and /etc/group (at least they don't always get removed). The problem is that the userdel command in the /usr/sbin/guest-account script fails because some of the guest processes are not yet dead at the time that it runs. The earlier line in the script uses loginctl to tell systemd to kill the users processes, but this isn't completed by the time that userdel runs.

The simplest fix is to just call userdel with the --force flag, so that it removes the password and group entries even if the processes are still there. This doesn't cause any problems. The lingering guest processes are gone by the time you log in as a regular user.

A trivial patch file for /usr/sbin/guest-account is attached. Also, the 2008 copyright at the top of the gile should really be updated! I don't think that loginctl existed in 2008 (ah, the good ole days :)

Here is some debugging output that I obtained by modifying /usr/sbin/guest-account so that I could see what it was doing and capture its output in a temporary file. This confirms the behavior that I mentioned above.

+ GUEST_HOME=/tmp/guest-8iwujo
+ [ -x /bin/loginctl ]
+ loginctl kill-user guest-8iwujo
+ [ /tmp/guest-8iwujo = guest-8iwujo ]
+ umount /tmp/guest-8iwujo
umount: /tmp/guest-8iwujo: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
+ umount -l /tmp/guest-8iwujo
+ umount /tmp/guest-8iwujo
umount: /tmp/guest-8iwujo: not mounted
+ umount -l /tmp/guest-8iwujo
umount: /tmp/guest-8iwujo: not mounted
+ true
+ umount /tmp/guest-8iwujo
umount: /tmp/guest-8iwujo: not mounted
+ umount -l /tmp/guest-8iwujo
umount: /tmp/guest-8iwujo: not mounted
+ true
+ rm -rf /tmp/guest-8iwujo
+ xargs -0 rm -rf
+ find /tmp -mindepth 1 -maxdepth 1 -uid 999 -print0
+ [ -d /run/media/guest-8iwujo ]
+ [ -d /media/guest-8iwujo ]
+ ps -lww -u guest-8iwujo
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 999 7128 1 0 80 0 - 88460 poll_s ? 00:00:00 at-spi-bus-laun
0 R 999 7214 1 0 80 0 - 162593 - ? 00:00:00 nm-applet
0 R 999 7222 1 1 80 0 - 138676 - ? 00:00:00 tilda
+ userdel guest-8iwujo
userdel: user guest-8iwujo is currently used by process 7128