Don't change permissions when on developmentMachine
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
This commit is contained in:
@@ -7,11 +7,11 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
|
||||||
import glob
|
import glob
|
||||||
import string
|
import string
|
||||||
|
|
||||||
whitelist = set(string.ascii_letters + string.digits + "/" + "@" + "." + "-" + "_")
|
whitelist = set(string.ascii_letters + string.digits + "/" + "@" + "." + "-" + "_")
|
||||||
|
developmentMachine = os.getenv("WEBSITE_DEVELOPER", "false") == "true"
|
||||||
|
|
||||||
|
|
||||||
def sanitize(
|
def sanitize(
|
||||||
@@ -40,7 +40,7 @@ def writeFile(
|
|||||||
): # Will write info in json format to a file
|
): # Will write info in json format to a file
|
||||||
with open(location, "w") as f:
|
with open(location, "w") as f:
|
||||||
json.dump(info, f)
|
json.dump(info, f)
|
||||||
if permission:
|
if permission and not developmentMachine:
|
||||||
os.system("chown -R www-data:www-data " + location)
|
os.system("chown -R www-data:www-data " + location)
|
||||||
|
|
||||||
|
|
||||||
@@ -54,14 +54,13 @@ try:
|
|||||||
# Looks at the configuration at understands the config
|
# Looks at the configuration at understands the config
|
||||||
try:
|
try:
|
||||||
configFilePath = __file__[: __file__.rindex("/") + 1]
|
configFilePath = __file__[: __file__.rindex("/") + 1]
|
||||||
# Makes sure the python file area is owned by root and not accessable by www-data for security reasons
|
|
||||||
os.system("chmod 750 -R " + configFilePath)
|
|
||||||
os.system("chown -R root:root " + configFilePath)
|
|
||||||
configFilePath = configFilePath + "config.json"
|
configFilePath = configFilePath + "config.json"
|
||||||
|
if not developmentMachine:
|
||||||
|
# Makes sure the python file area is owned by root and not accessable by www-data for security reasons
|
||||||
|
os.system("chmod 750 -R " + configFilePath)
|
||||||
|
os.system("chown -R root:root " + configFilePath)
|
||||||
# Will find the location where the config should be located.
|
# Will find the location where the config should be located.
|
||||||
location = __file__[: __file__.rindex("/python/restart.py") + 1] + "html/"
|
location = __file__[: __file__.rindex("/python/restart.py") + 1] + "html/"
|
||||||
# Creates config with the enviromental variables
|
|
||||||
developmentMachine = os.getenv("WEBSITE_DEVELOPER", "false") == "true"
|
|
||||||
# This stores a list for the default config
|
# This stores a list for the default config
|
||||||
envConfiguration = [
|
envConfiguration = [
|
||||||
[["passwordOptions", "cost"], int(os.getenv("PASSWORD_ROUNDS", "10"))],
|
[["passwordOptions", "cost"], int(os.getenv("PASSWORD_ROUNDS", "10"))],
|
||||||
@@ -126,9 +125,10 @@ try:
|
|||||||
developmentMachine = configuration["developer"]
|
developmentMachine = configuration["developer"]
|
||||||
backupLocation = configuration["database"]["backupLocation"]
|
backupLocation = configuration["database"]["backupLocation"]
|
||||||
# Makes sure that the permissions are not wrong
|
# Makes sure that the permissions are not wrong
|
||||||
os.system("chown -R www-data:www-data " + location)
|
if not developmentMachine:
|
||||||
os.system(f"chmod 644 -R {backupLocation}")
|
os.system("chown -R www-data:www-data " + location)
|
||||||
os.system("chmod 750 -R " + location)
|
os.system(f"chmod 644 -R {backupLocation}")
|
||||||
|
os.system("chmod 750 -R " + location)
|
||||||
f = open(location + "/maintenance-mode", "w")
|
f = open(location + "/maintenance-mode", "w")
|
||||||
f.close()
|
f.close()
|
||||||
while (
|
while (
|
||||||
@@ -437,8 +437,9 @@ except Exception as e:
|
|||||||
f.write(error(e))
|
f.write(error(e))
|
||||||
f = open(location + "maintenance-mode", "w")
|
f = open(location + "maintenance-mode", "w")
|
||||||
f.close()
|
f.close()
|
||||||
os.system("chmod 750 -R " + location)
|
if not developmentMachine:
|
||||||
os.system("chown -R www-data:www-data " + location)
|
os.system("chmod 750 -R " + location)
|
||||||
|
os.system("chown -R www-data:www-data " + location)
|
||||||
except Exception:
|
except Exception:
|
||||||
print("crash")
|
print("crash")
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Reference in New Issue
Block a user