Skip to content

Commit

Permalink
Use DynamicUser instead of static users
Browse files Browse the repository at this point in the history
To allow this, we need a more lenient policy for owning the service's
name on the system bus.
  • Loading branch information
dylanmccall committed Feb 12, 2021
1 parent 7708c46 commit b30fa6e
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 34 deletions.
6 changes: 1 addition & 5 deletions data/dbus/org.learningequality.Kolibri.Daemon.conf.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only @KOLIBRI_USER@ can own the service -->
<policy user="@KOLIBRI_USER@">
<allow own="@KOLIBRI_DAEMON_SERVICE@" />
</policy>

<!-- Any user can call into the service -->
<policy context="default">
<allow own="@KOLIBRI_DAEMON_SERVICE@" />
<allow send_destination="@KOLIBRI_DAEMON_SERVICE@" send_interface="org.freedesktop.DBus.Introspectable" />
<allow send_destination="@KOLIBRI_DAEMON_SERVICE@" send_interface="org.freedesktop.DBus.Properties" />
<allow send_destination="@KOLIBRI_DAEMON_SERVICE@" send_interface="org.learningequality.Kolibri.Daemon" />
Expand Down
2 changes: 1 addition & 1 deletion data/dbus/org.learningequality.Kolibri.Daemon.service.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[D-BUS Service]
Name=@KOLIBRI_DAEMON_SERVICE@
Exec=/bin/false
User=@KOLIBRI_USER@
User=root
SystemdService=dbus-@[email protected]
2 changes: 0 additions & 2 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
subdir('dbus')
subdir('environment.d')
subdir('systemd')
subdir('sysusers.d')
subdir('tmpfiles.d')

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ ConditionPathExists=/var/lib/flatpak/app/@KOLIBRI_FLATPAK_ID@
Type=dbus
BusName=@KOLIBRI_DAEMON_SERVICE@
ExecStart=@libexecdir@/eos-kolibri-daemon
DynamicUser=yes
User=@KOLIBRI_USER@
PrivateTmp=yes
RuntimeDirectory=kolibri
StateDirectory=kolibri
Environment=HOME=%t/kolibri
1 change: 0 additions & 1 deletion data/sysusers.d/eos-kolibri.conf.in

This file was deleted.

6 changes: 0 additions & 6 deletions data/sysusers.d/meson.build

This file was deleted.

3 changes: 0 additions & 3 deletions data/tmpfiles.d/eos-kolibri.conf.in

This file was deleted.

6 changes: 0 additions & 6 deletions data/tmpfiles.d/meson.build

This file was deleted.

1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ eos_kolibri_config.set('libexecdir', libexecdir)
eos_kolibri_config.set('PYTHON', 'python3')
eos_kolibri_config.set('PYTHON_INSTALL_DIR', python_install_dir)
eos_kolibri_config.set('KOLIBRI_USER', kolibri_user)
eos_kolibri_config.set('KOLIBRI_USER_HOME', kolibri_user_home)
eos_kolibri_config.set('KOLIBRI_DATA_DIR', kolibri_data_dir)
eos_kolibri_config.set('KOLIBRI_FLATPAK_ID', kolibri_flatpak_id)
eos_kolibri_config.set('KOLIBRI_DAEMON_SERVICE', kolibri_daemon_service)
Expand Down
7 changes: 0 additions & 7 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ option(
description: 'user to create for the system service'
)

option(
'kolibri_user_home',
type: 'string',
value: '',
description: 'home directory for the system user [default=$localstatedir/lib/kolibri]'
)

option(
'kolibri_flatpak_id',
type: 'string',
Expand Down
6 changes: 5 additions & 1 deletion src/eos-kolibri-daemon.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh

: ${KOLIBRI_HOME:="@KOLIBRI_DATA_DIR@"}
: ${STATE_DIRECTORY:=/var/lib/kolibri}

export KOLIBRI_HOME="${STATE_DIRECTORY}/data"

mkdir -p "${KOLIBRI_HOME}"

@bindir@/flatpak run \
--no-desktop \
Expand Down

0 comments on commit b30fa6e

Please sign in to comment.