mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
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 <sunil@medhas.org>
This commit is contained in:
parent
f4be9039d2
commit
e48ff1afbc
@ -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
|
||||||
@ -1,10 +1,8 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""Configure infinoted."""
|
"""Configure infinoted."""
|
||||||
|
|
||||||
import grp
|
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import pwd
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
@ -126,21 +124,8 @@ def setup():
|
|||||||
|
|
||||||
action_utils.service_daemon_reload()
|
action_utils.service_daemon_reload()
|
||||||
|
|
||||||
# Create infinoted group if needed.
|
# Create an 'infinoted' system user and group, if needed.
|
||||||
try:
|
action_utils.run(['systemd-sysusers', 'freedombox-infinoted.conf'])
|
||||||
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)
|
|
||||||
|
|
||||||
for directory in (DATA_DIR, KEY_DIR, SYNC_DIR):
|
for directory in (DATA_DIR, KEY_DIR, SYNC_DIR):
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user