util: drop absolute path from Chroot.run() calls
We currently use the absolute path of these binaries in the helper. This has some advantages but given that we control the inputs for PATH in general it seems unnecessary. We are also slightly inconsistent about this in the codebase but favor the non absolute path version. A quick count: ``` $ git grep '"chroot"'|wc -l 13 $ git grep '"/usr/sbin/chroot"'|grep -v test_|wc -l 8 ``` for `mount` and `umount` it seems this is the only place that uses the absolute path. It's not an important change but it has the nice property that it allows us to use e.g. `testutil.mock_command()` in our tests and it would be nice to be consistent.
This commit is contained in:
parent
0cf3cf9020
commit
a3e32f3823
3 changed files with 14 additions and 14 deletions
|
|
@ -27,17 +27,17 @@ def test_chroot_context(mocked_run, tmp_path):
|
|||
chroot.run(["/bin/false"], check=False)
|
||||
|
||||
assert mocked_run.call_args_list == [
|
||||
call(["/usr/bin/mount", "-t", "proc", "-o", "nosuid,noexec,nodev",
|
||||
call(["mount", "-t", "proc", "-o", "nosuid,noexec,nodev",
|
||||
"proc", os.fspath(tmp_path / "proc")], check=True),
|
||||
call(["/usr/bin/mount", "-t", "devtmpfs", "-o", "mode=0755,noexec,nosuid,strictatime",
|
||||
call(["mount", "-t", "devtmpfs", "-o", "mode=0755,noexec,nosuid,strictatime",
|
||||
"devtmpfs", os.fspath(tmp_path / "dev")], check=True),
|
||||
call(["/usr/bin/mount", "-t", "sysfs", "-o", "nosuid,noexec,nodev",
|
||||
call(["mount", "-t", "sysfs", "-o", "nosuid,noexec,nodev",
|
||||
"sysfs", os.fspath(tmp_path / "sys")], check=True),
|
||||
|
||||
call(["/usr/sbin/chroot", os.fspath(tmp_path), "/bin/true"], check=True),
|
||||
call(["/usr/sbin/chroot", os.fspath(tmp_path), "/bin/false"], check=False),
|
||||
call(["chroot", os.fspath(tmp_path), "/bin/true"], check=True),
|
||||
call(["chroot", os.fspath(tmp_path), "/bin/false"], check=False),
|
||||
|
||||
call(["/usr/bin/umount", "--lazy", os.fspath(tmp_path / "proc")], check=False),
|
||||
call(["/usr/bin/umount", "--lazy", os.fspath(tmp_path / "dev")], check=False),
|
||||
call(["/usr/bin/umount", "--lazy", os.fspath(tmp_path / "sys")], check=False),
|
||||
call(["umount", "--lazy", os.fspath(tmp_path / "proc")], check=False),
|
||||
call(["umount", "--lazy", os.fspath(tmp_path / "dev")], check=False),
|
||||
call(["umount", "--lazy", os.fspath(tmp_path / "sys")], check=False),
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue