oliver-zehentleitner / maity

runner: scratchop's password-file ops share one 'file we vouch for' check

Sign in to report

tsk-dj6cm7teptyr Proposed

Audit round 4 (tsk-hgnbapyw7hnh), read at 0a1b832e. Kind: duplication.

What is wrong

  • The rule for a password file the runner vouches for (regular file, this user's uid, mode exactly 0600, one link) is written twice in runner/scratchop.py: _pg_vouched (scratchop.py:213-217, on os.stat(..., follow_symlinks=False)) used by pg_make, and inline in pg_read (scratchop.py:270-275, on os.fstat(fd)). A change to one (say, the mode) would let pg_make report pg_pass: true for a file pgenv then refuses, or the other way round, and the session silently gets no cluster.

Proposal

  • One predicate over a stat_result, e.g. _vouched(st) -> bool, called with the os.stat result in pg_make and the os.fstat result in pg_read.

Effort / risk: S. Low; test_scratchop covers both paths.