mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-05 13:27:09 +02:00
57 lines
2.0 KiB
Diff
57 lines
2.0 KiB
Diff
From ed0718a25cf230377b64adcd7009cd8a7dd052dd Mon Sep 17 00:00:00 2001
|
|
From: Julia Schroeder <julia.schroeder@grommunio.com>
|
|
Date: Thu, 28 Mar 2024 11:04:08 +0100
|
|
Subject: [PATCH] Fix wrong permissions on user homedir path
|
|
|
|
---
|
|
api/__init__.py | 2 +-
|
|
tools/storage.py | 17 +++++++++++------
|
|
2 files changed, 12 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/api/__init__.py b/api/__init__.py
|
|
index f4e2cb6..30b5548 100644
|
|
--- a/api/__init__.py
|
|
+++ b/api/__init__.py
|
|
@@ -7,7 +7,7 @@
|
|
|
|
apiSpec = None # API specification
|
|
apiVersion = None # API specification version. Extracted from the OpenAPI document.
|
|
-backendVersion = "1.15.1" # Backend version number
|
|
+backendVersion = "1.15.2" # Backend version number
|
|
|
|
|
|
def _loadOpenApiSpec():
|
|
diff --git a/tools/storage.py b/tools/storage.py
|
|
index 24e16ab..5b0f6db 100644
|
|
--- a/tools/storage.py
|
|
+++ b/tools/storage.py
|
|
@@ -41,17 +41,22 @@ def createPath(parent: str, name: str, fileUid=None, fileGid=None):
|
|
path : str
|
|
The full path of the created directory (without trailing slash)
|
|
"""
|
|
- path = basepath = os.path.join(parent, *reversed(name.split('@')))
|
|
+ homepath = list(reversed(name.split('@')))
|
|
+ leaf = homepath[-1]
|
|
+ path = os.path.join(parent, *homepath)
|
|
counter = 0
|
|
while os.path.exists(path):
|
|
counter += 1
|
|
- path = f"{basepath}~{counter}"
|
|
+ homepath[-1] = f"{leaf}~{counter}"
|
|
+ path = os.path.join(parent, *homepath)
|
|
os.makedirs(path)
|
|
if fileUid is not None or fileGid is not None:
|
|
- try:
|
|
- shutil.chown(path, fileUid, fileGid)
|
|
- except Exception:
|
|
- logger.warn(f"failed to set ownership on '{path}' to {fileUid}/{fileGid}")
|
|
+ for h in homepath:
|
|
+ try:
|
|
+ parent = os.path.join(parent, h)
|
|
+ shutil.chown(parent, fileUid, fileGid)
|
|
+ except Exception:
|
|
+ logger.warn(f"failed to set ownership on '{path}' to {fileUid}/{fileGid}")
|
|
return path
|
|
|
|
|