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