Fix rhbz#593278, improve nis.sh and spec file
This commit is contained in:
parent
9b7c014427
commit
08f5328450
56
nis.sh
56
nis.sh
@ -19,40 +19,42 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Author(s): David Cantrell <dcantrell@redhat.com>
|
||||
#
|
||||
|
||||
CONF=/etc/yp.conf
|
||||
SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface}
|
||||
|
||||
fixContext() {
|
||||
fix_context() {
|
||||
if [ -x /sbin/restorecon ]; then
|
||||
/sbin/restorecon ${1} >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
save_config_file() {
|
||||
origfile="${1}"
|
||||
savefile="${SAVEDIR}/${origfile##*/}.predhclient.${interface}"
|
||||
|
||||
if [ ! -d ${SAVEDIR} ]; then
|
||||
mkdir -p ${SAVEDIR}
|
||||
fi
|
||||
|
||||
if [ -e ${origfile} ]; then
|
||||
mv ${origfile} ${savefile}
|
||||
if [ -e ${CONF} ]; then
|
||||
# cp+rm instead of mv: preserve SELinux context
|
||||
# rhbz#509240
|
||||
# Do not rely on restorecon.
|
||||
cp -c ${CONF} ${SAVECONF}
|
||||
rm ${CONF}
|
||||
else
|
||||
echo > ${savefile}
|
||||
echo > ${SAVECONF}
|
||||
# Try restorecon
|
||||
fix_context ${SAVECONF}
|
||||
fi
|
||||
|
||||
fixContext ${savefile}
|
||||
}
|
||||
|
||||
nis_config() {
|
||||
if [ ! "${PEERNIS}" = "no" ]; then
|
||||
if [ -n "${new_nis_domain}" ]; then
|
||||
domainname "${new_nis_domain}"
|
||||
save_config_file ${CONF}
|
||||
save_config_file
|
||||
let contents=0
|
||||
echo '# generated by /sbin/dhclient-script' > ${CONF}
|
||||
fix_context ${CONF}
|
||||
|
||||
if [ -n "${new_nis_servers}" ]; then
|
||||
for i in ${new_nis_servers} ; do
|
||||
@ -65,14 +67,12 @@ nis_config() {
|
||||
fi
|
||||
|
||||
if [ ${contents} -gt 0 ]; then
|
||||
if [ -x /etc/rc.d/init.d/ypbind ] &&
|
||||
[ -r /var/run/ypbind.pid ]; then
|
||||
service ypbind restart >/dev/null 2>&1
|
||||
fi
|
||||
service ypbind condrestart >/dev/null 2>&1
|
||||
fi
|
||||
elif [ -n "${new_nis_servers}" ]; then
|
||||
save_config_file ${CONF}
|
||||
save_config_file
|
||||
echo '# generated by /sbin/dhclient-script' > ${CONF}
|
||||
fix_context ${CONF}
|
||||
let contents=0
|
||||
|
||||
for i in ${new_nis_servers} ; do
|
||||
@ -81,10 +81,7 @@ nis_config() {
|
||||
done
|
||||
|
||||
if [ $contents -gt 0 ]; then
|
||||
if [ -x /etc/rc.d/init.d/ypbind ] &&
|
||||
[ -r /var/run/ypbind.pid ]; then
|
||||
service ypbind restart >/dev/null 2>&1
|
||||
fi
|
||||
service ypbind condrestart >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@ -92,13 +89,20 @@ nis_config() {
|
||||
|
||||
nis_restore() {
|
||||
if [ ! "${PEERNIS}" = "no" ]; then
|
||||
if [ -f ${SAVEDIR}/${CONF}.predhclient.${interface} ]; then
|
||||
if [ -f ${SAVECONF} ]; then
|
||||
rm -f ${CONF}
|
||||
mv -f ${SAVEDIR}/${CONF}.predhclient.${interface} ${CONF}
|
||||
fixContext /etc/yp.conf
|
||||
if [ -x /etc/rc.d/init.d/ypbind ] && [ -r /var/run/ypbind.pid ]; then
|
||||
service ypbind restart >/dev/null 2>&1
|
||||
fi
|
||||
# cp+rm instead of mv: preserve SELinux context
|
||||
# rhbz#509240
|
||||
cp -c ${SAVECONF} ${CONF}
|
||||
rm ${SAVECONF}
|
||||
fix_context ${CONF} # Restorecon again to be sure.
|
||||
service ypbind condrestart >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 4
|
||||
# show-trailing-whitespace: t
|
||||
# End:
|
||||
|
14
ypbind.spec
14
ypbind.spec
@ -1,7 +1,7 @@
|
||||
Summary: The NIS daemon which binds NIS clients to an NIS domain
|
||||
Name: ypbind
|
||||
Version: 1.31
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
License: GPLv2
|
||||
Group: System Environment/Daemons
|
||||
Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2
|
||||
@ -17,8 +17,6 @@ Requires(preun): initscripts
|
||||
Requires(postun): initscripts
|
||||
Requires: rpcbind, yp-tools
|
||||
Epoch: 3
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
BuildRequires: dbus-glib-devel, docbook-style-xsl
|
||||
|
||||
%description
|
||||
@ -57,9 +55,6 @@ install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/etc/dhcp/dhclient.d/nis.sh
|
||||
|
||||
%{find_lang} %{name}
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
/sbin/chkconfig --add ypbind
|
||||
|
||||
@ -85,6 +80,13 @@ fi
|
||||
%doc README NEWS COPYING
|
||||
|
||||
%changelog
|
||||
* Wed May 19 2010 Karel Klic <kklic@redhat.com> - 3:1.31-4
|
||||
- Update SELinux context of /etc/yp.conf in nis.sh (rhbz#593278)
|
||||
- nis.sh: use condrestart instead of pidfile checking
|
||||
- nis.sh: various simplifications
|
||||
- Removed BuildRoot tag
|
||||
- Removed %%clean section
|
||||
|
||||
* Wed Feb 24 2010 Karel Klic <kklic@redhat.com> - 3:1.31-3
|
||||
- Added COPYING file to the package
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user