Skip to content

Commit 2ff19fa

Browse files
systemd, tools: stop creating static cockpit-wsinstance user
Clean it up on package upgrades. Unlike the old `cockpit-ws` user, this user never owned any files on disk (other than cockpit-system), so this is safe. Co-Authored-By: Martin Pitt <mpitt@redhat.com>
1 parent 436b7af commit 2ff19fa

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

src/systemd/Makefile.am

-5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ tmpfilesconfdir = $(prefix)/lib/tmpfiles.d
5959
systemdgenerated += $(nodist_tmpfilesconf_DATA)
6060
nodist_tmpfilesconf_DATA = src/systemd/tmpfiles.d/cockpit-ws.conf
6161

62-
# -----------------
63-
# sysusers
64-
sysusersconfdir = $(prefix)/lib/sysusers.d
65-
dist_sysusersconf_DATA = src/systemd/sysusers.d/cockpit-wsinstance.conf
66-
6762
# -----------------
6863
# Policykit
6964
polkitdir = $(datadir)/polkit-1/actions

src/systemd/sysusers.d/cockpit-wsinstance.conf

-1
This file was deleted.

tools/cockpit.spec

+5-6
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ authentication via sssd/FreeIPA.
390390
%{_unitdir}/cockpit-wsinstance-socket-user.service
391391
%{_unitdir}/system-cockpithttps.slice
392392
%{_prefix}/%{__lib}/tmpfiles.d/cockpit-ws.conf
393-
%{_sysusersdir}/cockpit-wsinstance.conf
394393
%{pamdir}/pam_ssh_add.so
395394
%{pamdir}/pam_cockpit_cert.so
396395
%{_libexecdir}/cockpit-ws
@@ -409,11 +408,6 @@ authentication via sssd/FreeIPA.
409408
%ghost %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{name}
410409

411410
%pre ws
412-
# HACK: old RPM and even Fedora's current RPM don't properly support sysusers
413-
# https://github.com/rpm-software-management/rpm/issues/3073
414-
getent group cockpit-wsinstance >/dev/null || groupadd -r cockpit-wsinstance
415-
getent passwd cockpit-wsinstance >/dev/null || useradd -r -g cockpit-wsinstance -d /nonexisting -s /sbin/nologin -c "User for cockpit-ws instances" cockpit-wsinstance
416-
417411
if %{_sbindir}/selinuxenabled 2>/dev/null; then
418412
%selinux_relabel_pre -s %{selinuxtype}
419413
fi
@@ -448,6 +442,11 @@ if test -f %{_sysconfdir}/pam.d/cockpit && grep -q pam_cockpit_cert %{_sysconfd
448442
echo '**** WARNING:'
449443
fi
450444

445+
# remove obsolete system user on upgrade (replaced with DynamicUser in version 330)
446+
if getent passwd cockpit-wsinstance >/dev/null; then
447+
userdel cockpit-wsinstance
448+
fi
449+
451450
%preun ws
452451
%systemd_preun cockpit.socket cockpit.service
453452

tools/debian/cockpit-ws.install

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ ${env:deb_systemdsystemunitdir}/system-cockpithttps.slice
1818
${env:deb_pamlibdir}/security/pam_ssh_add.so
1919
${env:deb_pamlibdir}/security/pam_cockpit_cert.so
2020
usr/lib/tmpfiles.d/cockpit-ws.conf
21-
usr/lib/sysusers.d/cockpit-wsinstance.conf
2221
usr/lib/cockpit/cockpit-session
2322
usr/lib/cockpit/cockpit-ws
2423
usr/lib/cockpit/cockpit-wsinstance-factory

tools/debian/cockpit-ws.postinst

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ if [ "$1" = "configure" ] && dpkg-statoverride --list /usr/lib/cockpit/cockpit-s
1010
chgrp root /usr/lib/cockpit/cockpit-session
1111
fi
1212

13+
# remove obsolete system user on upgrade (replaced with DynamicUser in version 330)
14+
if [ "$1" = "configure" ] && getent passwd cockpit-wsinstance >/dev/null; then
15+
echo "Cleaning up obsolete static cockpit-wsinstance user"
16+
deluser --system cockpit-wsinstance
17+
fi
18+
1319
# restart cockpit.service on package upgrades, if it's already running
1420
if [ -d /run/systemd/system ] && [ -n "$2" ]; then
1521
deb-systemd-invoke try-restart cockpit.service >/dev/null || true

tools/debian/rules

-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,3 @@ else
8787
NO_QUNIT=1 pytest -vv -k 'not linter and not test_descriptions' -opythonpath=$$(ls -d debian/cockpit-bridge/usr/lib/python3*/dist-packages)
8888
endif
8989
endif
90-
91-
# dh compat 14 does that automatically, remove when upgrading
92-
execute_before_dh_installtmpfiles:
93-
dh_installsysusers

0 commit comments

Comments
 (0)