Browse Source

Merge pull request #1830 from pbiering/fix-1826

Fix issue 1826
Peter Bieringer 7 months ago
parent
commit
2a134061c0
2 changed files with 7 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 6 1
      radicale/utils.py

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@
 * Fix: logging ignores not retrievable get_native_id if not supported by OS
 * Fix: logging ignores not retrievable get_native_id if not supported by OS
 * Fix: report with enabled expand honors now provided filter proper
 * Fix: report with enabled expand honors now provided filter proper
 * Improve: add options [logging] trace_on_debug and trace_filter for supporting trace logging
 * Improve: add options [logging] trace_on_debug and trace_filter for supporting trace logging
+* Fix: catch case where getpwuid is not returning a username
 
 
 ## 3.5.4
 ## 3.5.4
 * Improve: item filter enhanced for 3rd level supporting VALARM and honoring TRIGGER (offset or absolute)
 * Improve: item filter enhanced for 3rd level supporting VALARM and honoring TRIGGER (offset or absolute)

+ 6 - 1
radicale/utils.py

@@ -225,7 +225,12 @@ def user_groups_as_string():
     if sys.platform != "win32":
     if sys.platform != "win32":
         euid = os.geteuid()
         euid = os.geteuid()
         egid = os.getegid()
         egid = os.getegid()
-        username = pwd.getpwuid(euid)[0]
+        try:
+            username = pwd.getpwuid(euid)[0]
+        except Exception:
+            # name of user not found
+            s = "user=(%d) group=(%d)" % (euid, egid)
+            return s
         gids = os.getgrouplist(username, egid)
         gids = os.getgrouplist(username, egid)
         groups = []
         groups = []
         for gid in gids:
         for gid in gids: