From e48ff1afbc3183bfda142e84113868baac9562bf Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 13 May 2026 13:44:32 -0700 Subject: [PATCH] infinoted: Use systemd-sysusers for creating a system user account - Drop dependency on 'adduser' package. Tests: - Functional tests for infinoted work. - Installing infinoted app works. The system user and group are created with proper UID/GID, shell, gecos, and home directory. Signed-off-by: Sunil Mohan Adapa --- .../lib/sysusers.d/freedombox-infinoted.conf | 6 ++++++ plinth/modules/infinoted/privileged.py | 19 ++----------------- 2 files changed, 8 insertions(+), 17 deletions(-) create mode 100644 plinth/modules/infinoted/data/usr/lib/sysusers.d/freedombox-infinoted.conf diff --git a/plinth/modules/infinoted/data/usr/lib/sysusers.d/freedombox-infinoted.conf b/plinth/modules/infinoted/data/usr/lib/sysusers.d/freedombox-infinoted.conf new file mode 100644 index 000000000..31bc1d08c --- /dev/null +++ b/plinth/modules/infinoted/data/usr/lib/sysusers.d/freedombox-infinoted.conf @@ -0,0 +1,6 @@ +# Create system user and group to run infinoted as system daemon (as opposed to +# running in particular user's account). The user is created at boot or when +# 'systemd-sysusers freedombox-infinoted.conf' is run. To override this file as +# system administrator, create a file /etc/sysusers.d/freedombox-infinoted.conf +# or link it to /dev/null. +u! infinoted - "Infinoted collaborative editing server" /var/lib/infinoted diff --git a/plinth/modules/infinoted/privileged.py b/plinth/modules/infinoted/privileged.py index 80bf1e275..e65d49c10 100644 --- a/plinth/modules/infinoted/privileged.py +++ b/plinth/modules/infinoted/privileged.py @@ -1,10 +1,8 @@ # SPDX-License-Identifier: AGPL-3.0-or-later """Configure infinoted.""" -import grp import os import pathlib -import pwd import shutil import subprocess import time @@ -126,21 +124,8 @@ def setup(): action_utils.service_daemon_reload() - # Create infinoted group if needed. - try: - grp.getgrnam('infinoted') - except KeyError: - action_utils.run(['addgroup', '--system', 'infinoted'], check=True) - - # Create infinoted user if needed. - try: - pwd.getpwnam('infinoted') - except KeyError: - action_utils.run([ - 'adduser', '--system', '--ingroup', 'infinoted', '--home', - DATA_DIR, '--gecos', 'Infinoted collaborative editing server', - 'infinoted' - ], check=True) + # Create an 'infinoted' system user and group, if needed. + action_utils.run(['systemd-sysusers', 'freedombox-infinoted.conf']) for directory in (DATA_DIR, KEY_DIR, SYNC_DIR): if not os.path.exists(directory):