Skip to content

Commit

Permalink
test: systemctl stop user@*.service now also kills the root session
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed May 15, 2024
1 parent c5ffda1 commit daa397c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,9 @@ def _terminate_sessions(self) -> None:
raise

# terminate all systemd user services for users who are not logged in
m.execute("systemctl stop user@*.service")
# since systemd 256 we stop user@*.service now also stops the root session (uid 0)
m.execute("cd /run/systemd/users/; "
"for f in $(ls); do [ $f -le 500 ] || systemctl stop user@$f; done")

# Clean up "closing" sessions again, and clean user id cache for non-system users
m.execute("systemctl stop systemd-logind; cd /run/systemd/users/; "
Expand Down
6 changes: 5 additions & 1 deletion test/verify/check-users
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,11 @@ class TestAccounts(testlib.MachineCase):

if not m.ostree_image: # User is not shown as logged in when logged in through Cockpit
b.go("#/admin")
b.wait_visible("#account-logout[disabled]")
m.execute("loginctl terminate-user admin || true; loginctl kill-user admin || true")
print(m.execute("loginctl list-sessions"))
with b.wait_timeout(60):
print(m.execute("loginctl list-sessions"))
b.wait_visible("#account-logout[disabled]")

(year, month) = m.execute("date +'%Y %b'").strip().split()

Expand Down

0 comments on commit daa397c

Please sign in to comment.