Skip to content

Commit

Permalink
test: simplify restoring /var/lib/sudo/lectured
Browse files Browse the repository at this point in the history
Use restore_dir instead of restoring four different files.
  • Loading branch information
jelly authored and martinpitt committed Nov 14, 2023
1 parent e36f0e2 commit 626e4f9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/verify/check-superuser
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ class TestSuperuser(testlib.MachineCase):
b.drop_superuser()

# We want to be lectured again
self.restore_file("/var/db/sudo/lectured/admin")
self.restore_file("/var/lib/sudo/lectured/admin")
m.execute("rm -rf /var/{db,lib}/sudo/lectured/admin")
self.restore_dir("/var/db/sudo/lectured")

m.execute("rm -rf /var/{db,lib}/sudo/lectured/admin")
# Sudo since 1.9.15 uses a UID not a username https://www.sudo.ws/releases/stable/#1.9.15
uid = m.execute("id -u admin").strip()
self.restore_file(f"/var/db/sudo/lectured/{uid}")
self.restore_file(f"/var/lib/sudo/lectured/{uid}")
m.execute(f"rm -rf /var/{{db,lib}}/sudo/lectured/{uid}")

# Get the privileges back, this time in the mobile layout
Expand Down

0 comments on commit 626e4f9

Please sign in to comment.