Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/general.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2022-08-28 22:04:25 +0200
committerGitHub <noreply@github.com>2022-08-28 22:04:25 +0200
commit13703fbb04d7bc7975368b035342e104c26e3f35 (patch)
treefad90fef6678180dfbf0062cc4a357a92fca4ea6 /archinstall/lib/general.py
parent65212a46aa43fadb2b0ee88b46b573765d7be9f9 (diff)
Fix permission flags on all the log files created (#1440)
* Changed permissions on the logs stored in /var/log/archinstall. Also cleaned up one of the saves to have the same syntax as the others * Tweaked secondary encryption password detection logic, as it wouldn't take it from the main arguments[] otherwise. * Changed permission on cmd_output.txt * Changed permission on cmd_history.txt
Diffstat (limited to 'archinstall/lib/general.py')
-rw-r--r--archinstall/lib/general.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 1dc37994..61c4358e 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -6,6 +6,7 @@ import os
import secrets
import shlex
import subprocess
+import stat
import string
import sys
import time
@@ -313,9 +314,18 @@ class SysCommandWorker:
except UnicodeDecodeError:
return False
- with open(f"{storage['LOG_PATH']}/cmd_output.txt", "a") as peak_output_log:
+ peak_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_output.txt")
+
+ change_perm = False
+ if peak_logfile.exists() is False:
+ change_perm = True
+
+ with peak_logfile.open("a") as peak_output_log:
peak_output_log.write(output)
+ if change_perm:
+ os.chmod(str(peak_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
+
sys.stdout.write(str(output))
sys.stdout.flush()
@@ -361,10 +371,18 @@ class SysCommandWorker:
# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
if not self.pid:
+ history_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_history.txt")
try:
+ change_perm = False
+ if history_logfile.exists() is False:
+ change_perm = True
+
try:
- with open(f"{storage['LOG_PATH']}/cmd_history.txt", "a") as cmd_log:
+ with history_logfile.open("a") as cmd_log:
cmd_log.write(f"{self.cmd}\n")
+
+ if change_perm:
+ os.chmod(str(history_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
except PermissionError:
pass