Added a wrapper script to use all variables correctly in the unit file

Resolves: #755775
This commit is contained in:
Honza Horák 2011-11-25 15:31:33 +01:00
parent 967a2ed63b
commit 6abb66981e
3 changed files with 29 additions and 1 deletions

16
rpc.yppasswdd.env Normal file
View File

@ -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

View File

@ -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

View File

@ -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@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@redhat.com> - 2.26-6
- Made error messages in yppasswdd more accurate