From fc46e157bd708aa24ee366e027aa7edbaa0c8648 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 4 Dec 2020 11:11:04 +0000 Subject: service: Add a systemd unit for D-Bus activation On systems using systemd --user and dbus-daemon --session --systemd-activation, this means that dconf is correctly placed in its own cgroup, instead of being part of dbus.service's cgroup. This allows it to be controlled by systemctl --user, have resource limits set and so on. On other systems (in particular those where systemd is not used at all), the SystemdService field is ignored and dbus-daemon will continue to start dconf-service as its own child process ("traditional activation"), making this change harmless to apply. Resolves: https://gitlab.gnome.org/GNOME/dconf/-/issues/24 Signed-off-by: Simon McVittie --- meson.build | 14 ++++++++++++++ meson_options.txt | 1 + service/ca.desrt.dconf.service.in | 1 + service/dconf.service.in | 8 ++++++++ service/meson.build | 9 +++++++++ 5 files changed, 33 insertions(+) create mode 100644 service/dconf.service.in diff --git a/meson.build b/meson.build index 41fe1a9..6e88015 100644 --- a/meson.build +++ b/meson.build @@ -48,6 +48,20 @@ glib_dep = dependency('glib-2.0', version: '>= 2.44.0') gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir', define_variable: ['libdir', dconf_libdir]) dbus_session_service_dir = dependency('dbus-1').get_pkgconfig_variable('session_bus_services_dir', define_variable: ['datadir', dconf_datadir]) +systemd_userunitdir = get_option('systemduserunitdir') + +if systemd_userunitdir == '' + systemd_dep = dependency('systemd', required: false) + + if systemd_dep.found() + systemd_userunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir') + else + # Fall back to the upstream default. + # Note that this is always 'lib', even if libdir is something else + systemd_userunitdir = join_paths(dconf_prefix, 'lib', 'systemd', 'user') + endif +endif + enable_bash_completion = get_option('bash_completion') if enable_bash_completion bash_completion_dep = dependency('bash-completion') diff --git a/meson_options.txt b/meson_options.txt index a2794ce..1b85d5d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,3 +2,4 @@ option('bash_completion', type: 'boolean', value: true, description: 'install ba option('man', type: 'boolean', value: true, description: 'generate man pages') option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation') option('vapi', type: 'boolean', value: true, description: 'install dconf client vapi') +option('systemduserunitdir', type: 'string', value: '', description: 'override systemd user unit directory') diff --git a/service/ca.desrt.dconf.service.in b/service/ca.desrt.dconf.service.in index 369948a..be0b911 100644 --- a/service/ca.desrt.dconf.service.in +++ b/service/ca.desrt.dconf.service.in @@ -1,3 +1,4 @@ [D-BUS Service] Name=ca.desrt.dconf Exec=@libexecdir@/dconf-service +SystemdService=dconf.service diff --git a/service/dconf.service.in b/service/dconf.service.in new file mode 100644 index 0000000..1e40430 --- /dev/null +++ b/service/dconf.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Configuration service +Documentation=man:dconf-service(1) + +[Service] +ExecStart=@libexecdir@/dconf-service +Type=dbus +BusName=ca.desrt.dconf diff --git a/service/meson.build b/service/meson.build index 19fe670..ad635b0 100644 --- a/service/meson.build +++ b/service/meson.build @@ -10,6 +10,15 @@ configure_file( install_dir: dbus_session_service_dir, ) +systemd_service = 'dconf.service' + +configure_file( + input: systemd_service + '.in', + output: systemd_service, + configuration: service_conf, + install_dir: systemd_userunitdir, +) + lib_sources = [ 'dconf-blame.c', 'dconf-gvdb-utils.c', -- cgit v1.2.1