summaryrefslogtreecommitdiff
path: root/test/fs.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/fs.py')
-rw-r--r--test/fs.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/test/fs.py b/test/fs.py
index 74c958ce..b69ecf57 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -520,7 +520,7 @@ def run_file(binary):
client.remove(f'/pane/{pager[0]}')
# systemd's tools page through their own variable: set too, its
# secure mode off, the path unquoted where it needs none.
- systemd_pager = run(client, term, b'printenv SYSTEMD_PAGER SYSTEMD_PAGERSECURE\n')
+ systemd_pager = run(client, term, b'printenv SYSTEMD_PAGER; printenv SYSTEMD_PAGERSECURE\n')
assert systemd_pager.startswith(b'exit 0\n') and systemd_pager.rstrip().endswith(b' -\n0'), systemd_pager
if shutil.which('journalctl'):
assert run(client, term, b'journalctl -n 3 --no-hostname\n').startswith(b'exit ')
@@ -551,8 +551,9 @@ def run_file(binary):
time.sleep(.05)
locked.chmod(0o600)
try:
- client.write(f'/pane/{term}/pty/ctl', b'exec\n')
- raise AssertionError('pty/ctl exec of a shell that cannot start was taken')
+ if os.geteuid() != 0: # root enters any directory
+ client.write(f'/pane/{term}/pty/ctl', b'exec\n')
+ raise AssertionError('pty/ctl exec of a shell that cannot start was taken')
except OSError as refused:
assert 'shell' in str(refused), refused
finally:
@@ -1663,15 +1664,17 @@ def test(binary, quic=False):
client.remove(f'/pane/{dashed}')
# A name under a directory that may not be searched is refused,
# permission denied, exit 1, no pane: its Save could never be.
- (root / 'noperm').mkdir()
- (root / 'noperm').chmod(0)
- before = serials()
- try:
- denied = subprocess.run([binary, 'noperm/a/b/c'], cwd=root, env=env, capture_output=True, timeout=10)
- finally:
- (root / 'noperm').chmod(0o755)
- assert denied.returncode == 1 and b'permission denied' in denied.stderr, denied
- assert serials() == before
+ # (Root searches any directory.)
+ if os.geteuid() != 0:
+ (root / 'noperm').mkdir()
+ (root / 'noperm').chmod(0)
+ before = serials()
+ try:
+ denied = subprocess.run([binary, 'noperm/a/b/c'], cwd=root, env=env, capture_output=True, timeout=10)
+ finally:
+ (root / 'noperm').chmod(0o755)
+ assert denied.returncode == 1 and b'permission denied' in denied.stderr, denied
+ assert serials() == before
# --wait waits on the pane its look answered, on the look's own
# open: a name /index shows escaped (a backslash is `\\` there)
# is still the pane waited on, not one already gone.
@@ -1824,16 +1827,17 @@ def test(binary, quic=False):
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=10)
assert fed.returncode == 0 and serials() == before, (fed, serials())
# A new name in a directory there but not writable: refused now,
- # not a pane that only fails at Save.
+ # not a pane that only fails at Save. (Root writes anywhere.)
shut = root / 'shut-dir'
shut.mkdir()
shut.chmod(0o500)
try:
- refused = subprocess.run([binary, 'shut-dir/new.txt'], cwd=root, env=env,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=10)
- assert refused.returncode == 1, refused
- assert b'may not be read or written' in refused.stderr, refused.stderr
- assert serials() == before, (serials(), before)
+ if os.geteuid() != 0:
+ refused = subprocess.run([binary, 'shut-dir/new.txt'], cwd=root, env=env,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=10)
+ assert refused.returncode == 1, refused
+ assert b'may not be read or written' in refused.stderr, refused.stderr
+ assert serials() == before, (serials(), before)
finally:
shut.chmod(0o755)
for word, said in (('@p999:1', b'pardes: @p999:1: this session has no such pane'),