dbus: add optional D-Bus activation file for gpio-manager
Subsystems (2)
PATCH v2 1/1 dbus: add optional D-Bus activation file for gpio-manager
Add an io.gpiod1.service D-Bus system-service file whose SystemdService= points at gpio-manager.service, which lets dbus-daemon start the manager through systemd on demand when a client sends a request to io.gpiod1.
On-demand activation is not wanted on every system, so gate it behind a new dbus-activation feature option. It defaults to disabled and requires systemd support. When disabled, the activation file is not installed.
---
Quoted 3 lines · Bartosz Golaszewski
This has none of the sandboxing features the original .service file has. :(
It also runs as root, as opposed to the gpio-manager user.
I updated the file so that the dbus service must always use systemd to start, since dbus service files do not really have the same sandboxing features.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+if opt_dbus_activation.enabled() + assert(opt_systemd.allowed(),What about
systemd_dep.found()? If we allow systemd but it's not found, the config will just ignore this one?
Updated to use systemd_enabled
--- dbus/data/io.gpiod1.service | 8 ++++++++ dbus/data/meson.build | 7 +++++++ meson.build | 6 ++++++ meson_options.txt | 3 +++ 4 files changed, 24 insertions(+) create mode 100644 dbus/data/io.gpiod1.service
dbus/data/io.gpiod1.service new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2026 Garmin Ltd. or its subsidiaries + +[D-BUS Service] +Name=io.gpiod1 +Exec=/bin/false +User=gpio-manager +SystemdService=gpio-manager.service
dbus/data/meson.build +7 -0
@@ -18,6 +18,13 @@ if opt_systemd.allowed() and systemd_dep.found() install_data(gpio_manager_service, install_dir: systemd_unit_dir, ) + + if opt_dbus_activation.allowed() + install_data('io.gpiod1.service', + install_dir: get_option('datadir') / 'dbus-1' / 'system-services', + ) + endif + install_data('90-gpio.rules', install_dir: get_option('libdir') / 'udev' / 'rules.d', )
meson.build +6 -0
@@ -55,6 +55,7 @@ opt_bindings_glib = get_option('bindings-glib') opt_dbus = get_option('dbus') opt_introspection = get_option('introspection') opt_systemd = get_option('systemd') +opt_dbus_activation = get_option('dbus-activation') if opt_bindings_cxx.allowed() add_languages('cpp', native: false)
@@ -172,6 +173,11 @@ else systemd_enabled = false endif +if opt_dbus_activation.enabled() + assert(systemd_enabled, + 'D-Bus activation requires systemd support, which is disabled or was not found') +endif + if opt_bindings_rust.allowed() cargo = find_program('cargo', required: opt_bindings_rust)
meson_options.txt +3 -0
@@ -34,6 +34,9 @@ option('introspection', type: 'feature', option('systemd', type: 'feature', description: 'Install systemd unit and udev rules (requires dbus)') +option('dbus-activation', type: 'feature', value: 'disabled', + description: 'Install D-Bus activation file for gpio-manager (requires systemd)') + option('systemd-unit-dir', type: 'string', value: '', description: 'Directory for systemd system unit files (default: from pkg-config)')
Signature · 6 lines
base commit: c2e9287333d7be588b3acaed7bbb1c58d7b551be Sorry about the thread confusion. Many Thanks, Payton
Bartosz Golaszewski
maintainerQuoted 21 lines · Payton Fack
Add an io.gpiod1.service D-Bus system-service file whose SystemdService= points at gpio-manager.service, which lets dbus-daemon start the manager through systemd on demand when a client sends a request to io.gpiod1.
On-demand activation is not wanted on every system, so gate it behind a new dbus-activation feature option. It defaults to disabled and requires systemd support. When disabled, the activation file is not installed.
Signed-off-by Payton Fack <[email protected]>---
Quoted 3 lines · Bartosz Golaszewski
This has none of the sandboxing features the original .service file has. :(
It also runs as root, as opposed to the gpio-manager user.
I updated the file so that the dbus service must always use systemd to start, since dbus service files do not really have the same sandboxing features.
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+if opt_dbus_activation.enabled() + assert(opt_systemd.allowed(),What about
systemd_dep.found()? If we allow systemd but it's not found, the config will just ignore this one?Updated to use
systemd_enabled
Please use a logical changelog format, like so:
Changes in v2:
- changed foo
- added bar
- Link to v1: ...
Preferably use b4 to manage patch series.
Quoted 27 lines
--- dbus/data/io.gpiod1.service | 8 ++++++++ dbus/data/meson.build | 7 +++++++ meson.build | 6 ++++++ meson_options.txt | 3 +++ 4 files changed, 24 insertions(+) create mode 100644 dbus/data/io.gpiod1.servicedbus/data/io.gpiod1.service new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2026 Garmin Ltd. or its subsidiaries + +[D-BUS Service] +Name=io.gpiod1 +Exec=/bin/false +User=gpio-manager +SystemdService=gpio-manager.servicedbus/data/meson.build +0
-0
dbus/data/meson.build if opt_systemd.allowed() and systemd_dep.found() · line 24
Quoted 7 lines
dbus/data/meson.build +4
-0@@ -18,6 +18,13 @@ if opt_systemd.allowed() and systemd_dep.found() install_data(gpio_manager_service, install_dir: systemd_unit_dir, ) + + if opt_dbus_activation.allowed() + install_data('io.gpiod1.service', + install_dir: get_option('datadir') / 'dbus-1' / 'system-services',
Can you use pkg-config's system_bus_services_dir instead of hardcoding it?
dbus/data/meson.build if opt_systemd.allowed() and systemd_dep.found() · line 27
Quoted 3 lines
dbus/data/meson.build +3
-0+ ) + endif +
The following command:
meson setup ./build -Ddbus=disabled -Ddbus-activation=enable
will not install anything and not warn either. Please bail-out if the user wants dbus-activation with dbus disabled.
For --auto-features=enabled the default should be: yes for dbus, no for dbus-activation.
Which made me realize the guard for systemd's D-Bus dependency should check if dbus was found, not only allowed. It would be great if you could prepend the series with a fix for that as well.
Quoted 32 lines
dbus/data/meson.build +0
-0install_data('90-gpio.rules', install_dir: get_option('libdir') / 'udev' / 'rules.d', )meson.build +6
-0@@ -55,6 +55,7 @@ opt_bindings_glib = get_option('bindings-glib') opt_dbus = get_option('dbus') opt_introspection = get_option('introspection') opt_systemd = get_option('systemd') +opt_dbus_activation = get_option('dbus-activation') if opt_bindings_cxx.allowed() add_languages('cpp', native: false)@@ -172,6 +173,11 @@ else systemd_enabled = false endif +if opt_dbus_activation.enabled() + assert(systemd_enabled, + 'D-Bus activation requires systemd support, which is disabled or was not found') +endif + if opt_bindings_rust.allowed() cargo = find_program('cargo', required: opt_bindings_rust)meson_options.txt +0
-0
meson_options.txt option('introspection', type: 'feature', · line 42
Quoted 9 lines
meson_options.txt +3
-0@@ -34,6 +34,9 @@ option('introspection', type: 'feature', option('systemd', type: 'feature', description: 'Install systemd unit and udev rules (requires dbus)') +option('dbus-activation', type: 'feature', value: 'disabled', + description: 'Install D-Bus activation file for gpio-manager (requires systemd)') + option('systemd-unit-dir', type: 'string', value: '', description: 'Directory for systemd system unit files (default: from pkg-config)')
Thanks,
Bartosz