mirror of
https://github.com/openwrt/packages.git
synced 2025-12-22 01:44:32 +04:00
Running dbus as an unprivileged user fails for two reasons: Cannot write pid file
and cannot read the installed policies:
Tue Aug 5 17:12:41 2025 daemon.info dbus-daemon[8568]: jail: exec-ing /usr/bin/dbus-daemon
Tue Aug 5 17:12:41 2025 daemon.info dbus-daemon[8585]: Encountered error 'Failed to open "/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf": Permission denied' while parsing '/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf'
Tue Aug 5 17:12:41 2025 daemon.err dbus-daemon[8568]: dbus-daemon[8585]: Encountered error 'Failed to open "/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf": Permission denied' while parsing '/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf'
Tue Aug 5 17:12:41 2025 daemon.warn dbus-daemon[8585]: Failed to start message bus: Failed to open "/var/run/dbus.pid": Permission denied
Tue Aug 5 17:12:41 2025 daemon.err dbus-daemon[8568]: dbus-daemon[8585]: Failed to start message bus: Failed to open "/var/run/dbus.pid": Permission denied
Tue Aug 5 17:12:41 2025 daemon.info dbus-daemon[8568]: jail: jail (8585) exited with exit: 1
Fix by dropping the pid file when running unprivileged and changing the owner
of the installed policies.
Fixes: f238d6dd09 ("dbus: run as regular user rather than as root")
Signed-off-by: Bjørn Mork <bjorn@mork.no>
42 lines
999 B
Bash
42 lines
999 B
Bash
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2007-2011 OpenWrt.org
|
|
|
|
START=60
|
|
|
|
USE_PROCD=1
|
|
PROG=/usr/bin/dbus-daemon
|
|
|
|
# To enable this makes only sense if the dbus has been compiled with
|
|
# the option CONFIG_DBUS_VERBOSE=y
|
|
|
|
#DEBUG=1
|
|
|
|
start_service() {
|
|
mkdir -m 0755 -p /var/lib/dbus
|
|
mkdir -m 0755 -p /var/run/dbus
|
|
chown dbus:dbus /var/lib/dbus /var/run/dbus
|
|
chown -R dbus:dbus /etc/dbus-1
|
|
|
|
[ -x /usr/bin/dbus-uuidgen ] && /usr/bin/dbus-uuidgen --ensure
|
|
|
|
procd_open_instance
|
|
procd_set_param command "${PROG}"
|
|
procd_append_param command --system
|
|
procd_append_param command --nofork
|
|
[ -n "$DEBUG" ] && procd_set_param env DBUS_VERBOSE=1
|
|
procd_set_param stdout 1
|
|
procd_set_param stderr 1
|
|
[ -x /sbin/ujail -a -e /etc/capabilities/dbus.json ] && {
|
|
procd_append_param command --nopidfile
|
|
procd_add_jail dbus
|
|
procd_set_param user dbus
|
|
procd_set_param group dbus
|
|
procd_set_param capabilities /etc/capabilities/dbus.json
|
|
}
|
|
procd_close_instance
|
|
}
|
|
|
|
stop_service() {
|
|
service_stop "${PROG}"
|
|
}
|