Skip to content

Commit 297b88b

Browse files
committed
Improve permission settings
1 parent 203237d commit 297b88b

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

tools/config_editor/compile.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,25 @@ def compile_libs(self) -> None:
139139
print("Error reading child process errors: " + str(e))
140140
label.update("Compilation failed for " + target)
141141
else:
142-
regex = r"^[1-9][0-9]*:[1-9][0-9]*$" # Regex to match the uid:gid format
143-
if self.app.setting_output_permissions and re.match(regex, self.app.setting_output_permissions):
144-
print_info("Changing permissions of generated files")
145-
chown_process = None
146-
try:
147-
chown_process = subprocess.run(["chown", "-R", self.app.setting_output_permissions, self.app.setting_arduino_path])
148-
chown_process.wait()
149-
except Exception as e:
150-
print("Error changing permissions: " + str(e))
151-
152-
if chown_process and chown_process.returncode != 0:
153-
self.print_error("Error changing permissions.")
154-
self.print_error("Please change the ownership of generated files manually")
142+
if self.app.setting_output_permissions:
143+
regex = r"^[1-9][0-9]*:[1-9][0-9]*$" # Regex to match the uid:gid format. Note that 0:0 (root) is not allowed
144+
if re.match(regex, self.app.setting_output_permissions):
145+
print_info("Setting permissions to: " + self.app.setting_output_permissions)
146+
chown_process = None
147+
try:
148+
chown_process = subprocess.run(["chown", "-R", self.app.setting_output_permissions, self.app.setting_arduino_path])
149+
chown_process.wait()
150+
except Exception as e:
151+
print("Error changing permissions: " + str(e))
152+
153+
if chown_process and chown_process.returncode != 0:
154+
self.print_error("Error changing permissions")
155+
self.print_error("Please change the ownership of generated files manually")
156+
else:
157+
self.print_success("Permissions changed successfully")
155158
else:
156-
self.print_success("Permissions changed successfully")
159+
self.print_error("Invalid permissions format: " + self.app.setting_output_permissions)
160+
self.print_error("Please change the ownership of generated files manually")
157161

158162
self.print_success("Compilation successful for " + target)
159163
label.update("Compilation successful for " + target)

0 commit comments

Comments
 (0)