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 (strncmp(inet_ntoa(domainlist[i].server[s].addr), "127", 3) == 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