@@ -5114,6 +5114,46 @@ dnl What pathname would we embed into unit files ExecStartPre?
51145114dnl TODO? Any need to make it a --with-... argument?
51155115AC_PATH_PROG ( [ SYSTEMD_TMPFILES_PROGRAM] , [ systemd-tmpfiles] , [ /usr/bin/systemd-tmpfiles] )
51165116
5117+ dnl Note: same as (systemd-)tmpfiles
5118+ AC_MSG_CHECKING ( [ whether to install sysusers.d files] )
5119+ NUT_ARG_WITH([ systemdsysusersdir] , [ (DIRPATH|yes|no|auto)] , [ Directory for systemd sysusers.d scripts] , [ auto] )
5120+ systemdsysusersdir="${nut_with_systemdsysusersdir}"
5121+
5122+ case "${systemdsysusersdir}" in
5123+ yes|auto|"")
5124+ AS_IF ( [ test x"$have_PKG_CONFIG" = xyes] ,
5125+ [ def_systemdsysusersdir="`$PKG_CONFIG --variable=sysusersdir systemd 2>/dev/null`" && test -n "$def_systemdsysusersdir" || \
5126+ def_systemdsysusersdir="`$PKG_CONFIG --variable=sysusersdir libsystemd 2>/dev/null`" || def_systemdsysusersdir=""] ,
5127+ [ def_systemdsysusersdir=""] )
5128+
5129+ AS_IF ( [ test x"${def_systemdsysusersdir}" = x] , [
5130+ AS_IF ( [ test "${systemdsysusersdir}" = yes] ,
5131+ [ AC_MSG_ERROR ( [ --with-systemdsysusersdir=${systemdsysusersdir} was requested, but PKG_CONFIG could not be queried for the system settings] ) ] )
5132+ systemdsysusersdir=""
5133+ ] , [ systemdsysusersdir="${def_systemdsysusersdir}"] )
5134+
5135+ unset def_systemdsysusersdir
5136+ ;;
5137+ no)
5138+ systemdsysusersdir=""
5139+ ;;
5140+ *)
5141+ AS_IF ( [ test -d "${systemdsysusersdir}"] , [ ] ,
5142+ [ AC_MSG_WARN ( [ --with-systemdsysusersdir='${systemdsysusersdir}' was requested, but that location does not currently exist in build environment - just so you know...] ) ] )
5143+ ;;
5144+ esac
5145+ if test "${systemdsysusersdir}" = "auto" ; then systemdsysusersdir=""; fi
5146+ if test -n "${systemdsysusersdir}"; then
5147+ AC_MSG_RESULT ( using ${systemdsysusersdir} )
5148+ NUT_REPORT_PATH_INTEGRATIONS([ Systemd-sysusers configs] , [ ${systemdsysusersdir}] )
5149+ else
5150+ AC_MSG_RESULT ( no )
5151+ fi
5152+ AM_CONDITIONAL([ WITH_SYSTEMD_SYSUSERS] , [ test x"${systemdsysusersdir}" != "x"] )
5153+ dnl What pathname would we embed into unit files ExecStartPre?
5154+ dnl TODO? Any need to make it a --with-... argument?
5155+ AC_PATH_PROG ( [ SYSTEMD_SYSUSERS_PROGRAM] , [ systemd-sysusers] , [ /usr/bin/systemd-sysusers] )
5156+
51175157
51185158dnl Note: we may want binaries with sd_notify and similar features regardless
51195159dnl of building and delivering unit files (which may be crafted separately).
@@ -6207,6 +6247,7 @@ AC_SUBST(systemdsystemunitdir)
62076247AC_SUBST ( systemdsystempresetdir )
62086248AC_SUBST ( systemdshutdowndir )
62096249AC_SUBST ( systemdtmpfilesdir )
6250+ AC_SUBST ( systemdsysusersdir )
62106251AC_SUBST ( auglensdir )
62116252AC_SUBST ( auglenstestsdir )
62126253AC_SUBST ( hotplugdir )
@@ -6685,6 +6726,39 @@ EOF])
66856726] )
66866727AC_MSG_RESULT ( [ done] )
66876728
6729+ dnl ---------------------------------------------------------------------
6730+ AC_MSG_CHECKING ( [ whether to customize ${TOP_BUILDDIR}/scripts/systemd/nut-common-sysusers.conf.in for this system] )
6731+ AS_IF ( [ test -n "$systemdsysusersdir"] ,
6732+ [ mkdir -p "${TOP_BUILDDIR}"/scripts/systemd
6733+ cat > "${TOP_BUILDDIR}"/scripts/systemd/nut-common-sysusers.conf.in << EOF
6734+ # Network UPS Tools (NUT) systemd integration
6735+ # Distributed under the terms of GPLv2+
6736+ # See https://networkupstools.org/
6737+ # and https://github.com/networkupstools/nut/
6738+ EOF
6739+ AS_IF ( [ test -n "${RUN_AS_USER}" && test x"${RUN_AS_USER}" != xnobody && test x"${RUN_AS_USER}" != xroot] ,
6740+ dnl Locked users ('!') are supported since v257
6741+ AS_IF ( [ test x"$have_PKG_CONFIG" = xyes && $PKG_CONFIG --atleast-version=257 systemd 2>/dev/null] , [
6742+ cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common-sysusers.conf.in << EOF
6743+ u! @RUN_AS_USER@ - - @STATEPATH@
6744+ EOF
6745+ ] , [
6746+ cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common-sysusers.conf.in << EOF
6747+ u @RUN_AS_USER@ - - @STATEPATH@
6748+ EOF
6749+ ] )
6750+ )
6751+ AS_IF ( [ test -n "${RUN_AS_GROUP}" && test x"${RUN_AS_GROUP}" != xnobody && test x"${RUN_AS_GROUP}" != xnogroup && test x"${RUN_AS_GROUP}" != xroot] ,
6752+ [ cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common-sysusers.conf.in << EOF
6753+ g @RUN_AS_GROUP@
6754+ EOF] )
6755+ AS_IF ( [ test -n "${RUN_AS_USER}" && test x"${RUN_AS_USER}" != xnobody && test x"${RUN_AS_USER}" != xroot && test -n "${RUN_AS_GROUP}" && test x"${RUN_AS_GROUP}" != xnobody && test x"${RUN_AS_GROUP}" != xnogroup && test x"${RUN_AS_GROUP}" != xroot] ,
6756+ [ cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common-sysusers.conf.in << EOF
6757+ m @RUN_AS_USER@ @RUN_AS_GROUP@
6758+ EOF] )
6759+ ] )
6760+ AC_MSG_RESULT ( [ done] )
6761+
66886762dnl # ccache versions 4.5 and newer support namespacing of the objects
66896763dnl # to facilitate more targeted eviction with --evict-namespace and
66906764dnl # perhaps --evict-older-than options. Here we bolt a namespace with
@@ -6888,6 +6962,7 @@ AC_CONFIG_FILES([
68886962 scripts/systemd/Makefile
68896963 scripts/systemd/nut.target
68906964 scripts/systemd/nut-common-tmpfiles.conf
6965+ scripts/systemd/nut-common-sysusers.conf
68916966 scripts/systemd/nut-driver.target
68926967 scripts/systemd/nut-driver@.service
68936968 scripts/systemd/nut-logger.service
0 commit comments