Browse Source

build: Add support for sysusers.d functionality

Use sysusers.d file instead of calling useradd in specfile. This is
needed for bootc containers.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Jan Friesse 1 year ago
parent
commit
7d62dac4d4
5 changed files with 25 additions and 1 deletions
  1. 5 0
      Makefile.am
  2. 5 0
      configure.ac
  3. 12 0
      corosync-qdevice.spec.in
  4. 2 1
      init/Makefile.am
  5. 1 0
      init/corosync-qnetd.sysusers.conf.example

+ 5 - 0
Makefile.am

@@ -134,6 +134,11 @@ if BUILD_INSTALL_QNETD_IN_SBIN
 	sed -i -e "s#@bcond_install_qnetd_in_sbin@#bcond_without#g" $@-t
 else
 	sed -i -e "s#@bcond_install_qnetd_in_sbin@#bcond_with#g" $@-t
+endif
+if BUILD_USESYSUSERS
+	sed -i -e "s#@bcond_use_sysusers@#bcond_without#g" $@-t
+else
+	sed -i -e "s#@bcond_use_sysusers@#bcond_with#g" $@-t
 endif
 	chmod a-w $@-t
 	mv $@-t $@

+ 5 - 0
configure.ac

@@ -186,6 +186,11 @@ AC_ARG_ENABLE([install-qnetd-in-sbin],
 	[ enable_install_qnetd_in_sbin="no" ])
 AM_CONDITIONAL([BUILD_INSTALL_QNETD_IN_SBIN], [test x$enable_install_qnetd_in_sbin = xyes])
 
+AC_ARG_ENABLE([use-sysusers],
+	[  --enable-use-sysusers           : Use sysusers.d file (RPM specfile)],,
+	[ enable_use_sysusers="no" ])
+AM_CONDITIONAL([BUILD_USESYSUSERS], [test x$enable_use_sysusers = xyes])
+
 # *FLAGS handling goes here
 
 ENV_CFLAGS="$CFLAGS"

+ 12 - 0
corosync-qdevice.spec.in

@@ -9,6 +9,7 @@
 %@bcond_runautogen@ runautogen
 %@bcond_systemd@ systemd
 %@bcond_install_qnetd_in_sbin@ install_qnetd_in_sbin
+%@bcond_use_sysusers@ use_sysusers
 
 %global gitver %{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}
 %global gittarver %{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}}
@@ -105,6 +106,10 @@ sed -i -e 's/^COROSYNC_QNETD_RUNAS=""$/COROSYNC_QNETD_RUNAS="coroqnetd"/' \
    %{buildroot}%{_sysconfdir}/sysconfig/corosync-qnetd
 %endif
 
+%if %{with use_sysusers}
+install -m0644 -D init/corosync-qnetd.sysusers.conf.example %{buildroot}%{_sysusersdir}/corosync-qnetd.conf
+%endif
+
 %description
 This package contains the Corosync Cluster Engine Qdevice, script for creating
 NSS certificates and an init script.
@@ -166,7 +171,9 @@ The Corosync Cluster Engine Qdevice
 %package -n corosync-qnetd
 Summary: The Corosync Cluster Engine Qdevice Network Daemon
 Requires: nss-tools
+%if %{without use_sysusers}
 Requires(pre): shadow-utils
+%endif
 
 %if %{with systemd}
 %{?systemd_requires}
@@ -177,10 +184,12 @@ This package contains the Corosync Cluster Engine Qdevice Network Daemon,
 script for creating NSS certificates and an init script.
 
 %pre -n corosync-qnetd
+%if %{without use_sysusers}
 getent group coroqnetd >/dev/null || groupadd -r coroqnetd
 getent passwd coroqnetd >/dev/null || \
     useradd -r -g coroqnetd -d / -s /sbin/nologin -c "User for corosync-qnetd" coroqnetd
 exit 0
+%endif
 
 %post -n corosync-qnetd
 %if %{with systemd} && 0%{?systemd_post:1}
@@ -228,6 +237,9 @@ fi
 %{_mandir}/man8/corosync-qnetd-tool.8*
 %{_mandir}/man8/corosync-qnetd-certutil.8*
 %{_mandir}/man8/corosync-qnetd.8*
+%if %{with use_sysusers}
+%{_sysusersdir}/corosync-qnetd.conf
+%endif
 
 %changelog
 * @date@ Autotools generated version <nobody@nowhere.org> - @version@-1-@numcomm@.@alphatag@.@dirty@

+ 2 - 1
init/Makefile.am

@@ -38,7 +38,8 @@ MAINTAINERCLEANFILES	= Makefile.in
 EXTRA_DIST		= corosync-qdevice.sysconfig.example corosync-qdevice.in \
                           corosync-qdevice.service.in \
                           corosync-qnetd.sysconfig.example corosync-qnetd.in \
-                          corosync-qnetd.service.in
+                          corosync-qnetd.service.in \
+                          corosync-qnetd.sysusers.conf.example
 
 if INSTALL_SYSTEMD
 systemdconfdir     = $(SYSTEMDDIR)

+ 1 - 0
init/corosync-qnetd.sysusers.conf.example

@@ -0,0 +1 @@
+u coroqnetd - 'User for corosync-qnetd' - -