file persistance fix

This commit is contained in:
Thomas Hobson 2021-04-28 16:03:35 +12:00
parent a6bc24e22e
commit 3bd73d07a9
No known key found for this signature in database
GPG key ID: 9F1FD9D87950DB6F
3 changed files with 59 additions and 6 deletions

25
tests/file_persistance.py Normal file
View file

@ -0,0 +1,25 @@
"""
Description
Files can be written into world writable directories without being removed,
potentially leading to disk space exhaustion
Run this test twice and there should be no output
"""
import os
directories = [
"/dev/shm",
"/run/lock",
"/tmp",
"/var/tmp"
]
for dir in directories:
fpath = f"{dir}/bean"
if os.path.exists(fpath):
print(f"{fpath} exists")
else:
with open(fpath, "w") as f:
f.write("beannn")