Bug 5862

Summary: Reboot hangs for 90 seconds after removing a user that was logged-in before
Product: [ROSA-based products] ROSA Fresh Reporter: a.lahin
Component: Packages from MainAssignee: ROSA Linux Bugs <bugs>
Status: RESOLVED FIXED QA Contact: ROSA Linux Bugs <bugs>
Severity: normal    
Priority: Normal CC: v.potapov
Version: Fresh   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Platform: --- ROSA Vulnerability identifier:
RPM Package: systemd ISO-related:
Bad POT generating: Upstream: known

Description a.lahin 2015-07-01 16:32:36 MSK
System hangs on reboot if there are user processes left after the user is deleted.

How reproducible:

1. Install Fresh R5 (create a user named "user")
2. Log in as user
3. Create new user named "user2"
4. Log in as "user2" and wait until user environment is initialized
5. Log out
6. Log in as "user"
7. Remove user2 using GUI tool (systemsettings).
8. Try to reboot the system.

System hangs on the plymouth screen.
After pressing Escape you can see the last message:
Stopping user-500.slice.

After the reboot the system journal contains:

июл 01 14:09:18 user-VirtualBox systemd[1]: Stopping user-500.slice.
июл 01 14:09:18 user-VirtualBox systemd[1]: Removed slice user-500.slice.
июл 01 14:09:32 user-VirtualBox systemd[1]: Received SIGRTMIN+20 from PID 11630 (plymouthd).
июл 01 14:10:24 user-VirtualBox systemd-journal[536]: Forwarding to syslog missed 64 messages.
июл 01 14:10:47 user-VirtualBox systemd[1]: user@501.service stopping timed out. Killing.
[14:15:50] alexanderlaw: июл 01 14:10:47 user-VirtualBox systemd[6347]: pam_succeed_if(systemd-user:session): error retrieving information about user 501
июл 01 14:10:47 user-VirtualBox systemd[6347]: pam_unix(systemd-user:session): session closed for user user2
июл 01 14:10:47 user-VirtualBox systemd[1]: Stopped User Manager for 501.
июл 01 14:10:47 user-VirtualBox systemd[1]: Unit user@501.service entered failed state.
июл 01 14:10:47 user-VirtualBox systemd[1]: Stopping user-501.slice.
июл 01 14:10:47 user-VirtualBox systemd[1]: Removed slice user-501.slice.
Comment 1 a.lahin 2015-07-01 16:39:08 MSK
User has some processes running after exit:
/lib/systemd/systemd --user
(sd-pam)
/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation

So userdel doesn't permit to remove such user:
user2 is currently used by process 5519

(where 5519 is pid of the "/lib/systemd/systemd --user" process)
When trying to kill the process (after user was deleted with GUI tool):

июл 01 15:38:13 user-VirtualBox systemd[5519]: Starting Exit the Session...
июл 01 15:38:13 user-VirtualBox systemd[12701]: Failed at step CHDIR spawning /bin/kill: No such file or directory
июл 01 15:38:13 user-VirtualBox systemd[5519]: systemd-exit.service: main process exited, code=exited, status=200/CHDIR
июл 01 15:38:13 user-VirtualBox systemd[5519]: Failed to start Exit the Session.
июл 01 15:38:13 user-VirtualBox systemd[5519]: Dependency failed for Exit the Session.
июл 01 15:38:13 user-VirtualBox systemd[5519]: Unit systemd-exit.service entered failed state.
Comment 2 Vladimir Potapov 2015-07-01 16:42:01 MSK
upstream bug https://bugzilla.redhat.com/show_bug.cgi?id=1185278
Comment 3 a.lahin 2015-07-01 16:45:15 MSK
The bug is produced by the following issues:
1. User leaves some processes after exit.
2. GUI Tool (System settings) allows to remove a user with the processes running.
3. systemd can't kill "/lib/systemd/systemd --user" process (due to missing $HOME?)
Comment 4 a.lahin 2015-07-01 16:57:32 MSK
If I recreate home directory for the deleted user, it's systemd process killed successfully:

июл 01 15:47:43 user-VirtualBox systemd[1]: Received SIGCHLD from PID 5519 (systemd).
июл 01 15:47:43 user-VirtualBox systemd[1]: Child 5519 (systemd) died (code=exited, status=0/SUCCESS)
июл 01 15:47:43 user-VirtualBox systemd[1]: Child 5519 belongs to user@501.service
июл 01 15:47:43 user-VirtualBox systemd[1]: user@501.service: main process exited, code=exited, status=0/SUCCESS
июл 01 15:47:43 user-VirtualBox systemd[1]: About to execute: /bin/kill -TERM ${MAINPID}
июл 01 15:47:43 user-VirtualBox systemd[1]: Forked /bin/kill as 14189
июл 01 15:47:43 user-VirtualBox systemd[1]: user@501.service changed running -> stop
июл 01 15:47:43 user-VirtualBox systemd[14189]: Failed at step USER spawning /bin/kill: No such process
июл 01 15:47:43 user-VirtualBox systemd[1]: Received SIGCHLD from PID 14189 ((kill)).

After that the system rebooted without a delay.
Comment 5 a.lahin 2015-07-17 15:16:21 MSK
Not reproduced anymore with systemd v219.
(user2's processes terminated when "user" login second time)
Comment 6 Vladimir Potapov 2015-07-20 11:22:09 MSK
It's no QA, please, add message of fixing the bug to advisory http://bugs.rosalinux.ru/show_bug.cgi?id=5944