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 <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa 2024-03-09 13:58:22 +02:00 committed by Sunil Mohan Adapa
parent 4b09d91f93
commit 22671510e6
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -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)