From 22671510e63fac0d2925aabad76d3bf1b01b29bb Mon Sep 17 00:00:00 2001 From: Veiko Aasa Date: Sat, 9 Mar 2024 13:58:22 +0200 Subject: [PATCH] samba: Ignore non-existent users who are in freedombox-share group Fixes error 500 when trying to open Samba app page when at least one of the users in freedombox-share group doesn't exist. Tests performed in both stable and testing containers: - Installed Samba app. - Installed Deluge app (Plinth install/setup fails but the Debian package itself was installed). - Did `apt remove --purge deluged` from command line. - Checked that the debian-deluged user doesn't exist (`getent passwd`) and the user is in the freedombox-share group (`getent group`). - Checked that the Samba app page opens without errors. - Checked that all the Samba tests pass. Fixes #2411. Signed-off-by: Veiko Aasa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/samba/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plinth/modules/samba/__init__.py b/plinth/modules/samba/__init__.py index 345e3ce6b..f81cd5d88 100644 --- a/plinth/modules/samba/__init__.py +++ b/plinth/modules/samba/__init__.py @@ -137,7 +137,11 @@ def get_users(): allowed_users = [] for group_user in group_users: - uid = pwd.getpwnam(group_user).pw_uid + try: + uid = pwd.getpwnam(group_user).pw_uid + except KeyError: # User doesn't exist + continue + if uid > 1000: allowed_users.append(group_user)