Skip to content

Commit

Permalink
Merge pull request #168 from YunoHost/fix_nontext_conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamandar authored Nov 16, 2024
2 parents f9791b1 + cb755a5 commit e32bee4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tests/test_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ def systemd_config_specific_user(self):

try:
content = open(app.path + "/conf/" + filename).read()
except UnicodeDecodeError:
yield Info("%s does not look like a text file.")
continue
except Exception as e:
yield Warning("Can't open/read %s : %s" % (filename, e))
return
continue

if "[Unit]" not in content:
continue
Expand All @@ -128,7 +131,7 @@ def systemd_config_specific_user(self):
yield Level(
"You should specify a 'User=' directive in the systemd config !"
)
return
continue

if any(match[1] in ["root", "www-data"] for match in matches):
yield Level(
Expand Down Expand Up @@ -178,9 +181,12 @@ def php_config_specific_user(self):

try:
content = open(app.path + "/conf/" + filename).read()
except UnicodeDecodeError:
yield Info("%s does not look like a text file.")
continue
except Exception as e:
yield Warning("Can't open/read %s : %s" % (filename, e))
return
continue

matches = re.findall(
r"^ *(user|group) = (\S+)", content, flags=re.MULTILINE
Expand All @@ -189,7 +195,7 @@ def php_config_specific_user(self):
yield Error(
"You should at least specify a 'user =' directive in your PHP conf file"
)
return
continue

if any(
match[1] == "root" or match == ("user", "www-data") for match in matches
Expand Down Expand Up @@ -446,11 +452,14 @@ def bind_public_ip(self):
for filename in files:
try:
content = open(os.path.join(path, filename)).read()
except UnicodeDecodeError:
yield Info("%s does not look like a text file.")
continue
except Exception as e:
yield Warning(
"Can't open/read %s: %s" % (os.path.join(path, filename), e)
)
return
continue

for number, line in enumerate(content.split("\n"), 1):
comment = ("#", "//", ";", "/*", "*")
Expand Down

0 comments on commit e32bee4

Please sign in to comment.