[ypbind] don't go offline when one of NIS servers is localhost Related: #829487

Honza Horak hhorak at fedoraproject.org
Mon Jul 9 11:38:25 UTC 2012


commit a9bcc738bd688901c9e1dfda4e18a28b84c90ec7
Author: Honza HorĂ¡k <hhorak at redhat.com>
Date:   Mon Jul 9 13:38:10 2012 +0200

    don't go offline when one of NIS servers is localhost
    Related: #829487

 ypbind-nmlocal.patch |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++
 ypbind.spec          |    8 +++-
 2 files changed, 121 insertions(+), 1 deletions(-)
---
diff --git a/ypbind-nmlocal.patch b/ypbind-nmlocal.patch
new file mode 100644
index 0000000..3828ea3
--- /dev/null
+++ b/ypbind-nmlocal.patch
@@ -0,0 +1,114 @@
+diff -up ypbind-mt-1.35/src/local.h.nmlocal ypbind-mt-1.35/src/local.h
+--- ypbind-mt-1.35/src/local.h.nmlocal	2009-03-30 14:24:40.000000000 +0200
++++ ypbind-mt-1.35/src/local.h	2012-06-11 19:31:42.297661066 +0200
+@@ -7,6 +7,7 @@ extern int broken_server;
+ extern int port;
+ extern int ping_interval;
+ extern int use_broadcast;
++extern int localhost_used;
+ extern char *domain;
+ 
+ extern void find_domain (const char *domain, ypbind_resp *result);
+diff -up ypbind-mt-1.35/src/serv_list.c.nmlocal ypbind-mt-1.35/src/serv_list.c
+--- ypbind-mt-1.35/src/serv_list.c.nmlocal	2012-06-11 19:31:41.970660463 +0200
++++ ypbind-mt-1.35/src/serv_list.c	2012-06-11 19:39:15.177987490 +0200
+@@ -108,6 +108,28 @@ static pthread_mutex_t search_lock = PTH
+ static void do_broadcast (struct binding *list);
+ static int ping_all (struct binding *list);
+ 
++/* We have localhost defined in one of the domains.
++ * If so, we don't need to be connected to outer network. */
++void
++check_localhost()
++{
++  int i, s;
++  localhost_used = 0;
++  for (i = 0; i < max_domains; ++i)
++    {
++      for (s = 0; s < _MAXSERVER; ++s)
++        {
++	  if (domainlist[i].server[s].host == NULL)
++	    break;
++          if (strcmp(inet_ntoa(domainlist[i].server[s].addr), "127.0.0.1") == 0)
++            {
++       	      localhost_used = 1;
++      	      return;
++            }
++        }
++    }
++}
++
+ static void
+ remove_bindingfile (struct binding *entry)
+ {
+@@ -220,6 +242,7 @@ update_bindingfile (struct binding *entr
+     }
+   else
+     log_msg (LOG_ERR, "open(%s): %s", path2, strerror (errno));
++  check_localhost();
+ }
+ 
+ /* this is called from the RPC thread (ypset). */
+@@ -562,6 +585,7 @@ add_server (const char *domain, const ch
+ 	 If there is none, use the first one. */
+       memcpy (&entry->server[active].addr, hent->h_addr_list[0],
+ 	      hent->h_length);
++      check_localhost();
+       res = 1;
+     }
+ 
+@@ -1105,7 +1129,7 @@ test_bindings (void *param __attribute__
+   int lastcheck = 0;
+ 
+ #ifdef USE_DBUS_NM
+-  if (is_online)
++  if (is_online || localhost_used)
+ #endif
+     do_binding ();
+ 
+@@ -1125,7 +1149,7 @@ test_bindings (void *param __attribute__
+ 	lastcheck = 0;
+ 
+ #if USE_DBUS_NM
+-      if (is_online)
++      if (is_online || localhost_used)
+ 
+ #endif
+ 	lastcheck = test_bindings_once (lastcheck, NULL);
+diff -up ypbind-mt-1.35/src/ypbind_dbus_nm.c.nmlocal ypbind-mt-1.35/src/ypbind_dbus_nm.c
+--- ypbind-mt-1.35/src/ypbind_dbus_nm.c.nmlocal	2012-06-11 19:31:42.296661064 +0200
++++ ypbind-mt-1.35/src/ypbind_dbus_nm.c	2012-06-11 19:31:42.300661070 +0200
+@@ -92,8 +92,11 @@ go_offline (void)
+   if (debug_flag)
+     log_msg (LOG_DEBUG, _("Switch to offline mode"));
+   is_online = 0;
+-  portmapper_disconnect ();
+-  clear_server ();
++  if (!localhost_used)
++    {
++      portmapper_disconnect ();
++      clear_server ();
++    }
+ }
+ 
+ static void
+diff -up ypbind-mt-1.35/src/ypbind-mt.c.nmlocal ypbind-mt-1.35/src/ypbind-mt.c
+--- ypbind-mt-1.35/src/ypbind-mt.c.nmlocal	2011-08-31 15:21:11.000000000 +0200
++++ ypbind-mt-1.35/src/ypbind-mt.c	2012-06-11 19:40:02.419996267 +0200
+@@ -74,6 +74,7 @@ int broken_server = 0;
+ int foreground_flag = 0;
+ int ping_interval = 20;
+ int local_only = 0;
++int localhost_used = 1;
+ int port = -1;
+ static int lock_fd;
+ static int pid_is_written = 0;
+@@ -945,7 +946,7 @@ main (int argc, char **argv)
+     }
+ 
+ #ifdef USE_DBUS_NM
+-  if (!is_online)
++  if (!is_online && !localhost_used)
+     portmapper_disconnect ();
+ #endif
+ 
diff --git a/ypbind.spec b/ypbind.spec
index e547d1b..15cec93 100644
--- a/ypbind.spec
+++ b/ypbind.spec
@@ -1,7 +1,7 @@
 Summary: The NIS daemon which binds NIS clients to an NIS domain
 Name: ypbind
 Version: 1.35
-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
@@ -18,6 +18,7 @@ Patch1: ypbind-1.11-gettextdomain.patch
 Patch2: ypbind-mt-1.32-typo.patch
 Patch3: ypbind-mt-1.32-typo2.patch
 Patch4: ypbind-mt-1.35-nmsignal.patch
+Patch5: ypbind-nmlocal.patch
 # This is for /bin/systemctl
 Requires(post): systemd-units
 Requires(preun): systemd-units
@@ -54,6 +55,7 @@ also need to install the ypserv package to a machine on your network.
 %patch2 -p1 -b .typo
 %patch3 -p1 -b .typo2
 %patch4 -p1 -b .nmsignal
+%patch5 -p1 -b .nmlocal
 
 %build
 %configure --enable-dbus-nm
@@ -115,6 +117,10 @@ fi
 %doc README NEWS COPYING
 
 %changelog
+* Mon Jul 09 2012 Honza Horak <hhorak at redhat.com> - 3:1.35-4
+- don't go offline when one of NIS servers is localhost
+  Related: #829487
+
 * Fri Jun 01 2012 Honza Horak <hhorak at redhat.com> - 3:1.35-3
 - fixed kill call in ypbind-post-waitbind script
 


More information about the scm-commits mailing list