[ypserv] Added a wrapper script to use all variables correctly in the unit file Resolves: #755775

Jan Horak hhorak at fedoraproject.org
Fri Nov 25 14:37:07 UTC 2011


commit 6abb66981e9ed3cab86be845d284e8fdc26cf5ff
Author: Honza HorĂ¡k <hhorak at redhat.com>
Date:   Fri Nov 25 15:31:33 2011 +0100

    Added a wrapper script to use all variables correctly in the unit file
    Resolves: #755775

 rpc.yppasswdd.env |   16 ++++++++++++++++
 yppasswdd.service |    2 +-
 ypserv.spec       |   12 ++++++++++++
 3 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/rpc.yppasswdd.env b/rpc.yppasswdd.env
new file mode 100644
index 0000000..364e09e
--- /dev/null
+++ b/rpc.yppasswdd.env
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+if [ "$ETCDIR" ]; then
+  YPPASSWDD_ARGS="$YPPASSWDD_ARGS -D $ETCDIR"
+fi
+
+if [ "$PASSWDFILE" ]; then
+  YPPASSWDD_ARGS="$YPPASSWDD_ARGS -p $PASSWDFILE"
+fi
+
+if [ "$SHADOWFILE" ]; then
+  YPPASSWDD_ARGS="$YPPASSWDD_ARGS -s $SHADOWFILE"
+fi
+
+exec /usr/sbin/rpc.yppasswdd -f $YPPASSWDD_ARGS
+
diff --git a/yppasswdd.service b/yppasswdd.service
index ec92f54..1e3e402 100644
--- a/yppasswdd.service
+++ b/yppasswdd.service
@@ -5,7 +5,7 @@ After=syslog.target network.target rpcbind.service
 
 [Service]
 EnvironmentFile=-/etc/sysconfig/yppasswdd
-ExecStart=/usr/sbin/rpc.yppasswdd -f $YPPASSWDD_ARGS
+ExecStart=/usr/sbin/rpc.yppasswdd.env
 
 [Install]
 WantedBy=multi-user.target
diff --git a/ypserv.spec b/ypserv.spec
index 15e71b8..ff3401d 100644
--- a/ypserv.spec
+++ b/ypserv.spec
@@ -9,6 +9,7 @@ Source0: ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypserv-%{version}.tar.bz2
 Source1: ypserv.service
 Source2: yppasswdd.service
 Source3: ypxfrd.service
+Source4: rpc.yppasswdd.env
 
 Requires: gawk, make, portmap, bash >= 2.0
 Requires(post): systemd-units
@@ -110,6 +111,15 @@ cat >$RPM_BUILD_ROOT/etc/sysconfig/yppasswdd <<EOF
 YPPASSWDD_ARGS=
 EOF
 
+# We need to pass all environment variables set in /etc/sysconfig/yppasswdd 
+# only if they are not empty. However, this simple logic is not supported 
+# by systemd. The script rpc.yppasswdd.env wraps the main binary and 
+# prepares YPPASSWDD_ARGS variable to include all necessary variables 
+# (ETCDIR, PASSWDFILE and SHADOWFILE). The script ensures, that the 
+# rpc.yppasswdd arguments are not used when the appropriate environment 
+# variables are empty.
+install -m755 %{SOURCE4} $RPM_BUILD_ROOT%{_sbindir}/rpc.yppasswdd.env
+
 %post
 # Package with native systemd unit file is installed for the first time
 if [ $1 -eq 1 ]; then
@@ -161,6 +171,8 @@ exit 0
 * Thu Nov 24 2011 Honza Horak <hhorak at redhat.com> - 2.26-7
 - Fixed empty domain handling in ypinit script
   Resolves: #751427
+- Added a wrapper script to use all variables correctly in the unit file
+  Resolves: #755775
 
 * Mon Oct 10 2011 Honza Horak <hhorak at redhat.com> - 2.26-6
 - Made error messages in yppasswdd more accurate


More information about the scm-commits mailing list