small pixel drawing of a pufferfish pa

Add more guards to /dev/shm usage
Jes Olson j3s@c3f.net
Wed, 28 Dec 2022 11:52:48 -0800
commit

6b9c395fa20badc78870a253c64a82af4ca720b3

parent

6295a586f142710dad4de03c5808b5ada254d5db

1 files changed, 10 insertions(+), 1 deletions(-)

jump to
M papa

@@ -64,8 +64,17 @@ # get base dirname in case we're dealing with

# a nested item (foo/bar) tmpfile="/dev/shm/pa/$name.txt" tmpdir="$(dirname "$tmpfile")" - mkdir -p "$tmpdir" + + # We want to clear the way for mkdir if we run + # into unexpected state, but we also want to trap + # that removal as a security precaution. + # + # Dying on mkdir is a security precaution as well, since + # mkdir will fail if the directory already exists (in which + # case, someone else may own it). trap 'rm -rf /dev/shm/pa' EXIT + rm -rf /dev/shm/pa + mkdir "$tmpdir" || die "Failed to create tmpdir, check perms on $tmpdir" age -i "$identities_file" --decrypt "$name.age" 2>/dev/null >"$tmpfile" || die "Could not decrypt $name.age"