Compare commits

..
3 Commits
Author SHA1 Message Date
mxmehl 701da16aaf make sure .filter are 0600 2021-12-23 14:57:52 +01:00
mxmehl 57de8f47d0 make path to message file absolute 2021-12-23 14:48:51 +01:00
mxmehl 671af52b15 do not create backup files for .qmail 2021-12-23 14:20:47 +01:00
+10 -2
View File
@@ -62,7 +62,13 @@ def check_user(user):
def get_messagefile(user): def get_messagefile(user):
"""Return message file of user, and create if necessary""" """Return message file of user, and create if necessary"""
filepath = f"message-{user}.txt" # Path of the project
gitpath = str(Path(app.root_path).parent)
# File name of the message
filename = f"message-{user}.txt"
# Combine path
filepath = os.path.join(gitpath, filename)
if not os.path.isfile(filepath): if not os.path.isfile(filepath):
Path(filepath).touch() Path(filepath).touch()
@@ -97,6 +103,9 @@ def get_filterfile(user):
with open(filepath, "w", encoding="utf-8") as filterfile: with open(filepath, "w", encoding="utf-8") as filterfile:
filterfile.write(filterconfig) filterfile.write(filterconfig)
# Change permissions to 0600
os.chmod(filepath, 0o600)
return filepath return filepath
@@ -168,7 +177,6 @@ def user_update(user):
with fileinput.FileInput( with fileinput.FileInput(
get_qmailfile(user), get_qmailfile(user),
inplace=True, inplace=True,
backup=".bak",
) as qmailfile: ) as qmailfile:
for line in qmailfile: for line in qmailfile:
print( print(