Skip to content

Commit 5be4a9b

Browse files
committed
Install sysusers.d config for user/groups
Ubuntu, debian and other distro create the cups user/groups in their packages. Add a sysusers.d config file and install it. This configuration file will create the configured system users/groups on first boot/factory reset/package installation, without requiring manual scripts or actions. This is very important for image-based OSes, but it is useful in other cases too, to allow using declarative configuration instead of scripts. https://www.freedesktop.org/software/systemd/man/latest/sysusers.d.html By default if the systemd.pc pkg-config file does not exist, this will be a no-op, so that it does not affect other OSes. If systemd.pc exists and contains the installation directory variable, or if it is specified manually in ./configure, then a sysusers.d config file is generated based on the configure user/groups and installed. Add separate files for the cups user/group and for the system groups, as they can be set independently.
1 parent 8779733 commit 5be4a9b

9 files changed

Lines changed: 88 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
/cgi-bin/testhi.index
3232
/cgi-bin/testtemplate
3333
/conf/cups-files.conf
34+
/conf/cups-sysusers.conf
35+
/conf/cups-sysusers-groups.conf
3436
/conf/cupsd.conf
3537
/conf/mime.convs
3638
/conf/pam.std

Makedefs.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ INITDDIR = @INITDDIR@
243243
LAUNCHD_DIR = @LAUNCHD_DIR@
244244
SMFMANIFESTDIR = @SMFMANIFESTDIR@
245245
SYSTEMD_DIR = @SYSTEMD_DIR@
246+
SYSUSERS_DIR = @SYSUSERS_DIR@
247+
INSTALL_SYSUSERS = @INSTALL_SYSUSERS@
248+
INSTALL_SYSUSERS_GROUPS = @INSTALL_SYSUSERS_GROUPS@
246249
XINETD = @XINETD@
247250

248251
USBQUIRKS = @USBQUIRKS@

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ clean:
100100

101101
distclean: clean
102102
$(RM) Makedefs config.h config.log config.status
103-
$(RM) conf/cups-files.conf conf/cupsd.conf conf/mime.convs conf/pam.std conf/snmp.conf
103+
$(RM) conf/cups-files.conf conf/cups-sysusers.conf conf/cupsd.conf conf/mime.convs conf/pam.std conf/snmp.conf
104104
$(RM) cups.pc
105105
$(RM) desktop/cups.desktop
106106
$(RM) doc/index.html

conf/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ install-data:
9191
$(INSTALL_DATA) $(PAMFILE) $(BUILDROOT)$(PAMDIR)/cups ; \
9292
fi ; \
9393
fi
94+
-if test x$(SYSUSERS_DIR) != x -a x$(INSTALL_SYSUSERS) != x; then \
95+
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(SYSUSERS_DIR); \
96+
$(INSTALL_DATA) cups-sysusers.conf $(BUILDROOT)$(SYSUSERS_DIR)/cups.conf; \
97+
fi
98+
-if test x$(SYSUSERS_DIR) != x -a x$(INSTALL_SYSUSERS_GROUPS) != x; then \
99+
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(SYSUSERS_DIR); \
100+
$(INSTALL_DATA) cups-sysusers-groups.conf $(BUILDROOT)$(SYSUSERS_DIR)/cups-groups.conf; \
101+
fi
94102

95103

96104
#
@@ -131,3 +139,8 @@ uninstall:
131139
$(RM) $(BUILDROOT)$(PAMDIR)/cups; \
132140
$(RMDIR) $(BUILDROOT)$(PAMDIR); \
133141
fi
142+
-if test x$(SYSUSERS_DIR) != x; then \
143+
$(RM) $(BUILDROOT)$(SYSUSERS_DIR)/cups.conf; \
144+
$(RM) $(BUILDROOT)$(SYSUSERS_DIR)/cups-groups.conf; \
145+
$(RMDIR) $(BUILDROOT)$(SYSUSERS_DIR); \
146+
fi

conf/cups-sysusers-groups.conf.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# sysusers.d(5) config file for the CUPS administrative group(s).
2+
3+
@CUPS_SYSUSERS_SYSTEM_GROUPS@

conf/cups-sysusers.conf.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# sysusers.d(5) config file for the CUPS user and group.
2+
3+
@CUPS_SYSUSERS_GROUP@
4+
@CUPS_SYSUSERS_USER@

config-scripts/cups-defaults.m4

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,49 @@ AC_DEFINE_UNQUOTED([CUPS_DEFAULT_USER], ["$CUPS_USER"], [Default User value.])
298298
AC_DEFINE_UNQUOTED([CUPS_DEFAULT_GROUP], ["$CUPS_GROUP"], [Default Group value.])
299299
AC_DEFINE_UNQUOTED([CUPS_DEFAULT_SYSTEM_GROUPS], ["$CUPS_SYSTEM_GROUPS"], [Default SystemGroup value(s).])
300300

301+
dnl sysusers.d entries for CUPS user and group...
302+
CUPS_SYSUSERS_GROUP=""
303+
CUPS_SYSUSERS_USER=""
304+
AS_IF([test "x$CUPS_USER" != "xroot" -a "x$CUPS_USER" != "xnobody"], [
305+
AS_IF([test "x$CUPS_GROUP" != "xroot" -a "x$CUPS_GROUP" != "xnobody" -a "x$CUPS_GROUP" != "xnogroup"], [
306+
CUPS_SYSUSERS_USER="u $CUPS_USER -:$CUPS_GROUP \"CUPS printing service\""
307+
], [
308+
CUPS_SYSUSERS_USER="u $CUPS_USER - \"CUPS printing service\""
309+
])
310+
], [
311+
AS_IF([test "x$CUPS_GROUP" != "xroot" -a "x$CUPS_GROUP" != "xnobody" -a "x$CUPS_GROUP" != "xnogroup"], [
312+
CUPS_SYSUSERS_GROUP="g $CUPS_GROUP"
313+
])
314+
])
315+
AC_SUBST([CUPS_SYSUSERS_GROUP])
316+
AC_SUBST([CUPS_SYSUSERS_USER])
317+
318+
AS_IF([test "x$CUPS_SYSUSERS_USER" != x -o "x$CUPS_SYSUSERS_GROUP" != x], [
319+
INSTALL_SYSUSERS="install-sysusers"
320+
], [
321+
INSTALL_SYSUSERS=""
322+
])
323+
AC_SUBST([INSTALL_SYSUSERS])
324+
325+
CUPS_SYSUSERS_SYSTEM_GROUPS=""
326+
for group in $CUPS_SYSTEM_GROUPS; do
327+
AS_IF([test "x$group" != "xroot" -a "x$group" != "xnobody" -a "x$group" != "xnogroup"], [
328+
AS_IF([test "x$CUPS_SYSUSERS_SYSTEM_GROUPS" = x], [
329+
CUPS_SYSUSERS_SYSTEM_GROUPS="g $group"
330+
], [
331+
CUPS_SYSUSERS_SYSTEM_GROUPS="$CUPS_SYSUSERS_SYSTEM_GROUPS
332+
g $group"
333+
])
334+
])
335+
done
336+
AC_SUBST([CUPS_SYSUSERS_SYSTEM_GROUPS])
337+
338+
AS_IF([test "x$CUPS_SYSUSERS_SYSTEM_GROUPS" != x], [
339+
INSTALL_SYSUSERS_GROUPS="install-sysusers-groups"
340+
], [
341+
INSTALL_SYSUSERS_GROUPS=""
342+
])
343+
AC_SUBST([INSTALL_SYSUSERS_GROUPS])
301344

302345
dnl Default printcap file...
303346
AC_ARG_WITH([printcap], AS_HELP_STRING([--with-printcap], [set default printcap file]), [

config-scripts/cups-directories.m4

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,20 @@ AC_ARG_WITH([rundir], AS_HELP_STRING([--with-rundir], [set transient run-time st
284284
])
285285
AC_DEFINE_UNQUOTED([CUPS_STATEDIR], ["$CUPS_STATEDIR"], [Location of transient state files.])
286286
AC_SUBST([CUPS_STATEDIR])
287+
288+
dnl sysusers.d directory...
289+
AC_ARG_WITH([sysusersdir], AS_HELP_STRING([--with-sysusersdir], [set directory for sysusers.d config file]), [
290+
SYSUSERS_DIR="$withval"
291+
], [
292+
SYSUSERS_DIR=""
293+
AS_IF([test "x$PKGCONFIG" != x], [
294+
AS_IF([$PKGCONFIG --exists systemd], [
295+
SYSUSERS_DIR="$($PKGCONFIG --variable=sysusersdir systemd)"
296+
])
297+
])
298+
])
299+
300+
AS_IF([test "x$SYSUSERS_DIR" = xno], [
301+
SYSUSERS_DIR=""
302+
])
303+
AC_SUBST([SYSUSERS_DIR])

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ dnl Provide autoconf with a list of files to generate and output them...
4949
AC_CONFIG_FILES([
5050
Makedefs
5151
conf/cups-files.conf
52+
conf/cups-sysusers.conf
53+
conf/cups-sysusers-groups.conf
5254
conf/cupsd.conf
5355
conf/mime.convs
5456
conf/pam.std

0 commit comments

Comments
 (0)