diff --git a/nis.sh b/nis.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f3746110cc2ea713a3ed3da1ab29a59811e1fd1 --- /dev/null +++ b/nis.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# +# nis.sh: dhclient-script plugin for NIS settings, +# place in /etc/dhcp/dhclient.d and 'chmod +x nis.sh' to enable +# +# Copyright (C) 2008 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Author(s): David Cantrell + +CONF=/etc/yp.conf +SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface} + +fix_context() { + if [ -x /sbin/restorecon ]; then + /sbin/restorecon ${1} >/dev/null 2>&1 + fi +} + +save_config_file() { + if [ ! -d ${SAVEDIR} ]; then + mkdir -p ${SAVEDIR} + fi + + 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 > ${SAVECONF} + # Try restorecon + fix_context ${SAVECONF} + fi +} + +nis_config() { + if [ ! "${PEERNIS}" = "no" ]; then + if [ -n "${new_nis_domain}" ]; then + domainname "${new_nis_domain}" + save_config_file + echo '# generated by /sbin/dhclient-script' > ${CONF} + fix_context ${CONF} + + if [ -n "${new_nis_servers}" ]; then + for i in ${new_nis_servers} ; do + echo "domain ${new_nis_domain} server ${i}" >> ${CONF} + done + else + echo "domain ${new_nis_domain} broadcast" >> ${CONF} + fi + + elif [ -n "${new_nis_servers}" ]; then + save_config_file + echo '# generated by /sbin/dhclient-script' > ${CONF} + fix_context ${CONF} + + for i in ${new_nis_servers} ; do + echo "ypserver ${i}" >> ${CONF} + done + + fi + + # dimainname or servers changed, restart ypbind + if [ "${old_nis_domain}" != "${new_nis_domain}" ] \ + || [ "${old_nis_servers}" != "${new_nis_servers}" ] + then + service ypbind condrestart >/dev/null 2>&1 + fi + fi +} + +nis_restore() { + if [ ! "${PEERNIS}" = "no" ]; then + if [ -f ${SAVECONF} ]; then + rm -f ${CONF} + # 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: diff --git a/ypbind-1.11-gettextdomain.patch b/ypbind-1.11-gettextdomain.patch new file mode 100644 index 0000000000000000000000000000000000000000..0891dd5d3db8d8090f1ba81a1d3595d0d3fe2d4a --- /dev/null +++ b/ypbind-1.11-gettextdomain.patch @@ -0,0 +1,12 @@ +diff -up ./po/Makevars.gettextdomain ./po/Makevars +--- ./po/Makevars.gettextdomain 2004-01-14 20:25:25.000000000 +0100 ++++ ./po/Makevars 2013-05-06 19:07:24.961484803 +0200 +@@ -1,7 +1,7 @@ + # Makefile variables for PO directory in any package using GNU gettext. + + # Usually the message domain is the same as the package name. +-DOMAIN = $(PACKAGE) ++DOMAIN = ypbind + + # These two variables depend on the location of this directory. + subdir = po diff --git a/ypbind-2.4-gettext_version.patch b/ypbind-2.4-gettext_version.patch new file mode 100644 index 0000000000000000000000000000000000000000..8cd57839b56b12c6e09c07a9aa2d962e8b51092f --- /dev/null +++ b/ypbind-2.4-gettext_version.patch @@ -0,0 +1,10 @@ +--- a/configure.ac.gettext_version 2016-03-02 15:10:26.000000000 +0100 ++++ b/configure.ac 2017-02-15 13:39:12.295019148 +0100 +@@ -59,7 +60,6 @@ JH_CHECK_XML_CATALOG([http://docbook.sou + AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test x$enable_man != xno) + + dnl internationalization macros +-AM_GNU_GETTEXT_VERSION + AM_GNU_GETTEXT([external]) + + AC_OUTPUT(Makefile lib/Makefile src/Makefile man/Makefile po/Makefile.in) diff --git a/ypbind-mt-2.6.tar.gz b/ypbind-mt-2.6.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..f5c35445b262e0dacf58e4ae3d447741320b9562 Binary files /dev/null and b/ypbind-mt-2.6.tar.gz differ diff --git a/ypbind-post-waitbind b/ypbind-post-waitbind new file mode 100644 index 0000000000000000000000000000000000000000..e3ac27c32ab67d07d2e8a07372ea92bb161d4008 --- /dev/null +++ b/ypbind-post-waitbind @@ -0,0 +1,57 @@ +#!/bin/sh +# +# ypbind-domain +# +# description: This is part of former ypbind init script, which is used +# to fix problems with the init scripts continuing even when +# we are really not bound yet to a server, and then things +# that need NIS fail. +# + +# NISTIMEOUT should be a multiple of 15 since +# ypwhich has a hardcoded 15sec timeout +[ -z "$NISTIMEOUT" ] && NISTIMEOUT=45 + +logger -t ypbind $"Binding NIS service" + +timeout=$NISTIMEOUT +firsttime=1 +rpcbound=0 +SECONDS=0 +retval=0 +while [ $SECONDS -lt $timeout ] || [ $firsttime -eq 1 ] ; do +firsttime=0 +if /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind +then + rpcbound=1 + /usr/bin/ypwhich > /dev/null 2>&1 + retval=$? + if [ $retval -eq 0 ]; then + break; + fi +fi +sleep 2 +done + +logger -t ypbind "Binding took $SECONDS seconds" + +if [ $retval -eq 0 ]; then + if [ $rpcbound -eq 0 ]; then + logger -t ypbind \ + "NIS domain: `domainname`, ypbind not registered with rpcbind." + else + logger -t ypbind \ + "NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`" + fi +else + logger -t ypbind \ + "NIS server for domain `domainname` is not responding." + logger -t ypbind \ + "Killing ypbind with PID $MAINPID." + kill -s 15 $MAINPID || : + logger -t ypbind \ + "Try increase NISTIMEOUT in /etc/sysconfig/ypbind" +fi + +exit $retval + diff --git a/ypbind-pre-setdomain b/ypbind-pre-setdomain new file mode 100644 index 0000000000000000000000000000000000000000..9b22a8c7df8c54ec60b677f9e26bcd2e3b009351 --- /dev/null +++ b/ypbind-pre-setdomain @@ -0,0 +1,44 @@ +#!/bin/sh +# +# ypbind-domain +# +# description: This is part of former ypbind init script, which is used +# to setup proper domainname before starting ypbind daemon +# itself. If $NISDOMAIN is not defined, it reads config file. +# + +TIMEOUT=5 +DOMAINNAME=`domainname` +if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then + echo -n $"Setting NIS domain: " + seconds=0 + while [ $seconds -lt $TIMEOUT ]; do + if [ -n "$NISDOMAIN" ]; then + domainname $NISDOMAIN + echo $"'$NISDOMAIN' (environment variable)" + break + else # See if the domain is set in config file + NISDOMAIN=`awk '{ if ($1 == "domain") {print $2; exit} }' /etc/yp.conf` + if [ -n "$NISDOMAIN" ]; then + domainname $NISDOMAIN + echo $"'$NISDOMAIN' (/etc/yp.conf)" + break + else + seconds=$(($seconds+1)) + sleep 1 + fi + fi + done + # Give up if NISDOMAIN is still not set + [ -z "$NISDOMAIN" ] && logger -t ypbind $"domain not found" && exit 1 +fi + +#/etc/rpc check +grep ypbind /etc/rpc > /dev/null 2>&1 +if [ $? -ne 0 ]; then + logger -t ypbind $"Error: Missing ypbind entry in /etc/rpc." + exit 1 +fi + +echo + diff --git a/ypbind.service b/ypbind.service new file mode 100644 index 0000000000000000000000000000000000000000..16a4cf8fc092952e8c17a56a14273ded75ee1215 --- /dev/null +++ b/ypbind.service @@ -0,0 +1,22 @@ +# For details how to adjust this file or change daemon settings, please, read ypbind(8). +[Unit] +Description=NIS/YP (Network Information Service) Clients to NIS Domain Binder +Requires=rpcbind.service +Wants=nss-user-lookup.target network-online.target +After=syslog.target rpcbind.service ypserv.service +Before=systemd-user-sessions.service +Before=nss-user-lookup.target + +[Service] +Type=notify +NotifyAccess=all +EnvironmentFile=-/etc/sysconfig/network +EnvironmentFile=-/etc/sysconfig/ypbind +ExecStartPre=/usr/libexec/ypbind-pre-setdomain +ExecStartPre=-/usr/sbin/setsebool allow_ypbind=1 +ExecStart=/usr/sbin/ypbind -n $OTHER_YPBIND_OPTS +ExecStartPost=/usr/libexec/ypbind-post-waitbind +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/ypbind.spec b/ypbind.spec new file mode 100644 index 0000000000000000000000000000000000000000..5d3c6497d782e5d9d83362bdd22d27d82e3839ce --- /dev/null +++ b/ypbind.spec @@ -0,0 +1,97 @@ +Name: ypbind +Epoch: 3 +Version: 2.6 +Release: 3 +Summary: NIS binding software +License: GPLv2 +URL: http://www.linux-nis.org/nis/ypbind-mt/index.html +Source0: https://github.com/thkukuk/ypbind-mt/archive/v%{version}.tar.gz#/ypbind-mt-%{version}.tar.gz +Source1: nis.sh +Source2: ypbind.service +Source3: ypbind-pre-setdomain +Source4: ypbind-post-waitbind +Patch0: ypbind-1.11-gettextdomain.patch +Patch2: ypbind-2.4-gettext_version.patch + +BuildRequires: git gcc systemd automake autoconf libxslt +BuildRequires: dbus-glib-devel systemd-devel docbook-style-xsl +BuildRequires: libtirpc-devel libnsl2-devel gettext-devel +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +Requires: rpcbind nss_nis yp-tools >= 4.2.2-2 + +%description +This package helps create and maintain a binding to a YP server. +It can finds the server for a YP domain and stores the information +about it. + +%package help +Summary: Doc files for ypbind +Buildarch: noarch + +%description help +The help package contains doc files for ypbind. + +%prep +%autosetup -n %{name}-mt-%{version} -p1 -S git +autoreconf -fiv + +%build +export CFLAGS="$RPM_OPT_FLAGS -fpic" +export LDFLAGS="$LDFLAGS -pie -Wl,-z,relro,-z,now" + +%configure +%make_build + +%install +%make_install + +mkdir -p %{buildroot}/%{_libexecdir} +mkdir -p %{buildroot}/%{_unitdir} +mkdir -p %{buildroot}/%{_sysconfdir}/dhcp/dhclient.d +mkdir -p %{buildroot}/%{_localstatedir}/yp/binding +install -m 755 %{SOURCE1} %{buildroot}/%{_sysconfdir}/dhcp/dhclient.d/nis.sh +install -m 644 %{SOURCE2} %{buildroot}/%{_unitdir}/ypbind.service +install -m 755 %{SOURCE3} %{buildroot}/%{_libexecdir}/ypbind-pre-setdomain +install -m 755 %{SOURCE4} %{buildroot}/%{_libexecdir}/ypbind-post-waitbind +install -m 644 etc/yp.conf %{buildroot}/%{_sysconfdir}/yp.conf +%{find_lang} %{name} + +%post +%systemd_post %{name}.service + +%preun +%systemd_preun %{name}.service + +%postun +%systemd_postun_with_restart %{name}.service + +%files -f %{name}.lang +%license COPYING +%config(noreplace) %{_sysconfdir}/yp.conf +%{_sysconfdir}/dhcp/dhclient.d/nis.sh +%{_unitdir}/%{name}.service +%{_sbindir}/%{name} +%{_libexecdir}/%{name}* +%dir %{_localstatedir}/yp/binding + +%files help +%doc README NEWS +%{_mandir}/*/* + +%changelog +* Tue Dec 31 2019 openEuler Buildteam - 2.6-3 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:optimization the spec + +* Thu Nov 7 2019 openEuler Buildteam - 2.6-2 +- Type:enhancement +- Id:NA +- SUG:NA +- DESC:modify the release + +* Mon Sep 9 2019 luhuaxin - 2.6-1 +- Package init