]> git.seodisparate.com - AnotherAURHelper/commitdiff
Use mount options to set tmpfs user/permissions
authorStephen Seo <seo.disparate@gmail.com>
Fri, 17 Nov 2023 11:19:30 +0000 (20:19 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 17 Nov 2023 11:23:23 +0000 (20:23 +0900)
update.py

index c311df8369da70119baedeb0fa17826e7d48c15c..f38354e64907cdebd4ade8b4f1e64896c9b7ede3 100755 (executable)
--- a/update.py
+++ b/update.py
@@ -18,6 +18,7 @@ import threading
 from pathlib import Path
 from typing import Any, Union
 import signal
+import pwd
 
 # SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
 SUDO_PROC = False
@@ -1834,6 +1835,7 @@ if __name__ == "__main__":
     PKG_STATE = pkg_state
     OTHER_STATE = other_state
     other_state["USER"] = os.environ["USER"]
+    other_state["UID"] = pwd.getpwnam(other_state["USER"]).pw_uid
     other_state["logs_dir"] = None
     other_state["log_limit"] = 1024 * 1024 * 1024
     other_state["error_on_limit"] = False
@@ -2057,7 +2059,7 @@ if __name__ == "__main__":
                     "-t",
                     "tmpfs",
                     "-o",
-                    "size=90%",
+                    f"size=90%,mode=0700,uid={other_state['UID']}",
                     "tmpfs",
                     other_state["tmpfs_chroot"],
                 ),
@@ -2074,34 +2076,6 @@ if __name__ == "__main__":
                 ),
                 other_state["tmpfs_chroot"],
             )
-            log_print(
-                "Setting tmpfs dir permissions...", other_state=other_state
-            )
-            subprocess.run(
-                (
-                    "/usr/bin/env",
-                    "sudo",
-                    "chmod",
-                    "700",
-                    other_state["tmpfs_chroot"],
-                ),
-                check=True,
-            )
-            log_print(
-                "Giving self user owner of tmpfs dir...",
-                other_state=other_state,
-            )
-            subprocess.run(
-                (
-                    "/usr/bin/env",
-                    "sudo",
-                    "chown",
-                    "-R",
-                    other_state["USER"],
-                    other_state["tmpfs_chroot"],
-                ),
-                check=True,
-            )
             os.umask(old_umask)
         except subprocess.CalledProcessError:
             log_print("ERROR: Failed to set up tmpfs!")