Skip to content

Commit c01589f

Browse files
all: stop creating static users
Move all remaining systemd services over to DynamicUser=yes and remove the variables from configure.ac and the build system. Adjust the distribution packaging.
1 parent e7066fb commit c01589f

8 files changed

+3
-81
lines changed

configure.ac

-60
Original file line numberDiff line numberDiff line change
@@ -274,62 +274,6 @@ fi
274274
AM_CONDITIONAL(WITH_ASAN, test "$enable_asan" = "yes")
275275
AC_MSG_RESULT($asan_status)
276276

277-
# User and group for running cockpit web server (cockpit-tls or -ws in customized setups)
278-
279-
AC_ARG_WITH(cockpit_user,
280-
AS_HELP_STRING([--with-cockpit-user=<user>],
281-
[User for running cockpit (root)]
282-
)
283-
)
284-
AC_ARG_WITH(cockpit_group,
285-
AS_HELP_STRING([--with-cockpit-group=<group>],
286-
[Group for running cockpit]
287-
)
288-
)
289-
if test -z "$with_cockpit_user"; then
290-
COCKPIT_USER=root
291-
COCKPIT_GROUP=
292-
else
293-
COCKPIT_USER=$with_cockpit_user
294-
if test -z "$with_cockpit_group"; then
295-
COCKPIT_GROUP=$with_cockpit_user
296-
else
297-
COCKPIT_GROUP=$with_cockpit_group
298-
fi
299-
fi
300-
301-
AC_SUBST(COCKPIT_USER)
302-
AC_SUBST(COCKPIT_GROUP)
303-
304-
# User for running cockpit-ws instances from cockpit-tls
305-
306-
AC_ARG_WITH(cockpit_ws_instance_user,
307-
AS_HELP_STRING([--with-cockpit-ws-instance-user=<user>],
308-
[User for running cockpit-ws instances from cockpit-tls (root)]
309-
)
310-
)
311-
AC_ARG_WITH(cockpit_ws_instance_group,
312-
AS_HELP_STRING([--with-cockpit-ws-instance-group=<group>],
313-
[Group for running cockpit-ws instances from cockpit-tls]
314-
)
315-
)
316-
if test -z "$with_cockpit_ws_instance_user"; then
317-
if test "$COCKPIT_USER" != "root"; then
318-
AC_MSG_ERROR([--with-cockpit-ws-instance-user is required when setting --with-cockpit-user])
319-
fi
320-
COCKPIT_WSINSTANCE_USER=root
321-
else
322-
COCKPIT_WSINSTANCE_USER=$with_cockpit_ws_instance_user
323-
if test -z "$with_cockpit_ws_instance_group"; then
324-
COCKPIT_WSINSTANCE_GROUP=$with_cockpit_ws_instance_user
325-
else
326-
COCKPIT_WSINSTANCE_GROUP=$with_cockpit_ws_instance_group
327-
fi
328-
fi
329-
330-
AC_SUBST(COCKPIT_WSINSTANCE_USER)
331-
AC_SUBST(COCKPIT_WSINSTANCE_GROUP)
332-
333277
# admin users group
334278
AC_ARG_WITH([admin-group],
335279
[AS_HELP_STRING([--with-admin-group=GROUP],
@@ -495,10 +439,6 @@ echo "
495439
cflags: ${CFLAGS}
496440
cppflags: ${CPPFLAGS}
497441

498-
cockpit-ws user: ${COCKPIT_USER}
499-
cockpit-ws group: ${COCKPIT_GROUP}
500-
cockpit-ws instance user: ${COCKPIT_WSINSTANCE_USER}
501-
cockpit-ws instance group: ${COCKPIT_WSINSTANCE_GROUP}
502442
admin group: ${admin_group}
503443

504444
Building docs: ${enable_doc}

src/systemd/Makefile.am

-4
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ src/systemd/%: src/systemd/%.in
4141
-e 's,[@]PACKAGE[@],$(PACKAGE),g' \
4242
-e 's,[@]admin_group[@],$(admin_group),g' \
4343
-e 's,[@]datadir[@],$(datadir),g' \
44-
-e 's,[@]group[@],$(COCKPIT_GROUP),g' \
4544
-e 's,[@]libexecdir[@],$(libexecdir),g' \
46-
-e 's,[@]user[@],$(COCKPIT_USER),g' \
47-
-e 's,[@]wsinstancegroup[@],$(COCKPIT_WSINSTANCE_GROUP),g' \
48-
-e 's,[@]wsinstanceuser[@],$(COCKPIT_WSINSTANCE_USER),g' \
4945
$< > $@.tmp && mv -f $@.tmp $@
5046

5147
systemdgenerated = \

src/systemd/cockpit-wsinstance-http.service.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ After=cockpit-session.socket cockpit-session-socket-owner.service
77

88
[Service]
99
ExecStart=@libexecdir@/cockpit-ws --no-tls --port=0
10-
User=@wsinstanceuser@
11-
Group=@wsinstancegroup@
10+
DynamicUser=true
1211
SupplementaryGroups=cockpit-session-socket

src/systemd/cockpit-wsinstance-https@.service.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ After=cockpit-session.socket cockpit-session-socket-owner.service
88
[Service]
99
Slice=system-cockpithttps.slice
1010
ExecStart=@libexecdir@/cockpit-ws --for-tls-proxy --port=0
11-
User=@wsinstanceuser@
12-
Group=@wsinstancegroup@
11+
DynamicUser=yes
1312
SupplementaryGroups=cockpit-session-socket

src/systemd/cockpit.service.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ RuntimeDirectory=cockpit/tls
1111
Environment=RUNTIME_DIRECTORY=/run/cockpit/tls
1212
ExecStartPre=+@libexecdir@/cockpit-certificate-ensure --for-cockpit-tls
1313
ExecStart=@libexecdir@/cockpit-tls
14-
User=@user@
15-
Group=@group@
14+
DynamicUser=yes
1615
SupplementaryGroups=cockpit-wsinstance-socket
1716
NoNewPrivileges=true
1817
ProtectSystem=strict

tools/cockpit.spec

-6
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ Recommends: subscription-manager-cockpit
164164
exec 2>&1
165165
%configure \
166166
--disable-silent-rules \
167-
--with-cockpit-user=cockpit-ws \
168-
--with-cockpit-ws-instance-user=cockpit-wsinstance \
169167
%if 0%{?suse_version}
170168
--docdir=%_defaultdocdir/%{name} \
171169
%endif
@@ -516,10 +514,6 @@ authentication via sssd/FreeIPA.
516514
%endif
517515

518516
%pre ws
519-
getent group cockpit-ws >/dev/null || groupadd -r cockpit-ws
520-
getent passwd cockpit-ws >/dev/null || useradd -r -g cockpit-ws -d /nonexisting -s /sbin/nologin -c "User for cockpit web service" cockpit-ws
521-
getent group cockpit-wsinstance >/dev/null || groupadd -r cockpit-wsinstance
522-
getent passwd cockpit-wsinstance >/dev/null || useradd -r -g cockpit-wsinstance -d /nonexisting -s /sbin/nologin -c "User for cockpit-ws instances" cockpit-wsinstance
523517

524518
%if 0%{?with_selinux}
525519
if %{_sbindir}/selinuxenabled 2>/dev/null; then

tools/debian/cockpit-ws.postinst

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/bin/sh
22
set -e
33

4-
adduser --system --group --home /nonexistent --no-create-home --quiet cockpit-ws
5-
adduser --system --group --home /nonexistent --no-create-home --quiet cockpit-wsinstance
6-
74
#DEBHELPER#
85

96
# restart cockpit.service on package upgrades, if it's already running

tools/debian/rules

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ endif
1717

1818
override_dh_auto_configure:
1919
dh_auto_configure -- \
20-
--with-cockpit-user=cockpit-ws \
21-
--with-cockpit-ws-instance-user=cockpit-wsinstance \
2220
--with-pamdir=/lib/$(DEB_HOST_MULTIARCH)/security \
2321
--libexecdir=/usr/lib/cockpit $(CONFIG_OPTIONS)
2422

0 commit comments

Comments
 (0)