diff options
| author | Jan <sentrycraft123@gmail.com> | 2023-11-11 21:56:32 +0100 |
|---|---|---|
| committer | AAGaming <aagaming@riseup.net> | 2023-12-29 18:40:52 -0500 |
| commit | 98e2d1232c0d7f77156b12894950700330427dcf (patch) | |
| tree | dae28f7aaa51a792b2a5057edc6afd06603e3f15 /backend | |
| parent | 6cb545c78da982e6ffc46f45e1578f4226d6413c (diff) | |
| download | decky-loader-98e2d1232c0d7f77156b12894950700330427dcf.tar.gz decky-loader-98e2d1232c0d7f77156b12894950700330427dcf.zip | |
replace chmod implementation with os.chmod (#541)
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/decky_loader/localplatform/localplatformlinux.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/backend/decky_loader/localplatform/localplatformlinux.py b/backend/decky_loader/localplatform/localplatformlinux.py index 9bbb59a7..68717bcf 100644 --- a/backend/decky_loader/localplatform/localplatformlinux.py +++ b/backend/decky_loader/localplatform/localplatformlinux.py @@ -58,8 +58,22 @@ def chown(path : str, user : UserType = UserType.HOST_USER, recursive : bool = def chmod(path : str, permissions : int, recursive : bool = True) -> bool: if _get_effective_user_id() != 0: return True - result = call(["chmod", "-R", str(permissions), path] if recursive else ["chmod", str(permissions), path]) - return result == 0 + + try: + octal_permissions = int(str(permissions), 8) + + if recursive: + for root, dirs, files in os.walk(path): + for d in dirs: + os.chmod(os.path.join(root, d), octal_permissions) + for d in files: + os.chmod(os.path.join(root, d), octal_permissions) + + os.chmod(path, octal_permissions) + except: + return False + + return True def folder_owner(path : str) -> UserType|None: user_owner = _get_user_owner(path) |
