Skip to content

Commit 2105c17

Browse files
committed
Introduce sysusers config file to create libvirtdbus user
Install a systemd sysusers config file to create libvirtdbus user. Signed-off-by: Pavel Hrdina <[email protected]>
1 parent 0643cd8 commit 2105c17

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

data/libvirt-dbus.sysusers.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
u libvirtdbus - 'Libvirt D-Bus bridge' - -

data/meson.build

+6
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ install_data(
1212
install_dir: dbus_interfaces_dir,
1313
)
1414

15+
install_data(
16+
'libvirt-dbus.sysusers.conf',
17+
install_dir: sysusersdir,
18+
rename: [ 'libvirt-dbus.conf' ],
19+
)
20+
1521
subdir('session')
1622
subdir('system')

libvirt-dbus.spec.in

+3-8
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,13 @@ This package provides D-Bus API for libvirt
3838

3939
%build
4040
%meson \
41-
-Dinit_script=systemd
41+
-Dinit_script=systemd \
42+
-Dsysusersdir=%{_sysusersdir}
4243
%meson_build
4344

4445
%install
4546
%meson_install
4647

47-
%pre
48-
getent group %{system_user} >/dev/null || groupadd -r %{system_user}
49-
getent passwd %{system_user} >/dev/null || \
50-
useradd -r -g %{system_user} -d / -s /sbin/nologin \
51-
-c "Libvirt D-Bus bridge" %{system_user}
52-
exit 0
53-
5448
%post
5549
%systemd_post %{name}.service
5650
%systemd_user_post %{name}.service
@@ -74,6 +68,7 @@ exit 0
7468
%{_datadir}/dbus-1/system.d/org.libvirt.conf
7569
%{_datadir}/dbus-1/interfaces/org.libvirt.*.xml
7670
%{_datadir}/polkit-1/rules.d/libvirt-dbus.rules
71+
%{_sysusersdir}/libvirt-dbus.conf
7772
%{_mandir}/man8/libvirt-dbus.8*
7873

7974
%changelog

meson.build

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ if init_script == 'systemd'
2828
systemd_system_unit_dir = systemd_base_unit_dir / 'system'
2929
endif
3030

31+
sysusersdir = get_option('sysusersdir')
32+
if sysusersdir == ''
33+
sysusersdir = prefix / 'lib' / 'sysusers.d'
34+
endif
35+
3136
opt_dirs = [
3237
'dbus_interfaces',
3338
'dbus_services',

meson_options.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ option('polkit_rules', type: 'string', value: 'polkit-1/rules.d', description: '
77
option('system_user', type: 'string', value: 'libvirtdbus', description: 'username to run system instance as')
88
option('unix_socket_group', type: 'string', value: 'libvirt', description: 'libvirt UNIX domain socket group')
99
option('init_script', type: 'combo', choices: ['systemd', 'other', 'check'], value: 'check', description: 'Style of init script to install')
10+
option('sysusersdir', type: 'string', value: '', description: 'directory for sysusers files')

0 commit comments

Comments
 (0)