Hello community,
here is the log from the commit of package ypbind
checked in at Thu Aug 17 18:28:23 CEST 2006.
--------
--- ypbind/ypbind.changes 2006-05-26 13:05:29.000000000 +0200
+++ ypbind/ypbind.changes 2006-08-17 06:01:54.000000000 +0200
@@ -1,0 +2,6 @@
+Thu Aug 17 06:01:36 CEST 2006 - kukuk@suse.de
+
+- Add DBUS/NetworkManager support to ypbind
+- Remove obsolete documentation
+
+-------------------------------------------------------------------
Old:
----
HOWTO.SuSE
README.NetworkManager
ypbind-mt-1.19.1.diff
ypbind-mt-1.19.1.tar.bz2
New:
----
ypbind-mt-1.19.90.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ypbind.spec ++++++
--- /var/tmp/diff_new_pack.JCVCcb/_old 2006-08-17 18:27:21.000000000 +0200
+++ /var/tmp/diff_new_pack.JCVCcb/_new 2006-08-17 18:27:21.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package ypbind (Version 1.19.1)
+# spec file for package ypbind (Version 1.19.90)
#
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -11,7 +11,7 @@
# norootforbuild
Name: ypbind
-BuildRequires: openslp-devel
+BuildRequires: NetworkManager-devel dbus-1-devel dbus-1-glib-devel openslp-devel pkgconfig
License: GPL
Group: Productivity/Networking/NIS
Requires: portmap yp-tools
@@ -20,15 +20,12 @@
Autoreqprov: on
PreReq: %insserv_prereq %fillup_prereq
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-Version: 1.19.1
-Release: 15
+Version: 1.19.90
+Release: 1
URL: http://www.linux-nis.org/nis/ypbind-mt
Summary: NIS client daemon
Source: ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2
Source1: sysconfig.ypbind
-Source2: HOWTO.SuSE
-Source3: README.NetworkManager
-Patch: ypbind-mt-%{version}.diff
%description
This package provides the ypbind daemon. The ypbind daemon binds NIS
@@ -46,7 +43,6 @@
%prep
%setup -n ypbind-mt-%{version}
-%patch
%build
export CFLAGS=$RPM_OPT_FLAGS
@@ -89,7 +85,7 @@
%files -f ypbind-mt.lang
%defattr(-,root,root)
-%doc AUTHORS ChangeLog COPYING NEWS README THANKS TODO $RPM_SOURCE_DIR/HOWTO.SuSE $RPM_SOURCE_DIR/README.NetworkManager
+%doc AUTHORS ChangeLog COPYING NEWS README THANKS
%ghost %config(noreplace) /etc/yp.conf
%config /etc/init.d/ypbind
/var/adm/fillup-templates/sysconfig.ypbind
@@ -104,6 +100,9 @@
%dir /var/yp/binding
%changelog -n ypbind
+* Thu Aug 17 2006 - kukuk@suse.de
+- Add DBUS/NetworkManager support to ypbind
+- Remove obsolete documentation
* Fri May 26 2006 - schwab@suse.de
- Don't strip binaries.
* Wed May 17 2006 - seife@suse.de
++++++ ypbind-mt-1.19.1.tar.bz2 -> ypbind-mt-1.19.90.tar.bz2 ++++++
++++ 2021 lines of diff (skipped)
++++ retrying with extended exclude list
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/ChangeLog new/ypbind-mt-1.19.90/ChangeLog
--- old/ypbind-mt-1.19.1/ChangeLog 2005-07-03 18:49:17.000000000 +0200
+++ new/ypbind-mt-1.19.90/ChangeLog 2005-07-13 23:53:47.000000000 +0200
@@ -1,3 +1,9 @@
+2005-07-12 Thorsten Kukuk
+
+ * man/ypbind.8.in: Fix typo.
+ * man/yp.conf.5.in: Likewise.
+ (Reported by Saleem A. )
+
2005-07-03 Thorsten Kukuk
* release version 1.19.1
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/Makefile.am new/ypbind-mt-1.19.90/Makefile.am
--- old/ypbind-mt-1.19.1/Makefile.am 2004-01-14 16:34:03.000000000 +0100
+++ new/ypbind-mt-1.19.90/Makefile.am 2006-08-17 03:50:40.000000000 +0200
@@ -1,10 +1,9 @@
#
-# Copyright (c) 1998, 1999, 2001, 2002, 2004 Thorsten Kukuk, Germany
+# Copyright (c) 1998, 1999, 2001, 2002, 2004, 2006 Thorsten Kukuk, Germany
#
# Author: Thorsten Kukuk
#
AUTOMAKE_OPTIONS = 1.6 gnits dist-bzip2
-MAINT_CHARSET = latin1
#
SUBDIRS = m4 lib src man po
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/NEWS new/ypbind-mt-1.19.90/NEWS
--- old/ypbind-mt-1.19.1/NEWS 2005-07-02 11:25:01.000000000 +0200
+++ new/ypbind-mt-1.19.90/NEWS 2006-08-17 03:35:12.000000000 +0200
@@ -4,6 +4,9 @@
Please send bug reports, questions and suggestions to .
+Version 1.19.90
+* Add DBUS/NetworkManager support
+
Version 1.19.1
* Fix crash if debug mode is enabled
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/THANKS new/ypbind-mt-1.19.90/THANKS
--- old/ypbind-mt-1.19.1/THANKS 2004-04-29 22:30:18.000000000 +0200
+++ new/ypbind-mt-1.19.90/THANKS 2005-07-13 23:53:47.000000000 +0200
@@ -12,3 +12,4 @@
Jeff Bastian jmbastia@ti.com
Chris Barrera cbarrera@ti.com
Mark Brown broonie@sirena.org.uk
+Saleem A. saleem@vmware.com
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/config.h.in new/ypbind-mt-1.19.90/config.h.in
--- old/ypbind-mt-1.19.1/config.h.in 2005-07-03 18:52:44.000000000 +0200
+++ new/ypbind-mt-1.19.90/config.h.in 2006-08-17 03:35:23.000000000 +0200
@@ -113,6 +113,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Enable DBUS/NetworkManager support */
+#undef USE_DBUS_NM
+
/* Enable SLP support */
#undef USE_SLP
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/configure.in new/ypbind-mt-1.19.90/configure.in
--- old/ypbind-mt-1.19.1/configure.in 2005-07-03 18:51:53.000000000 +0200
+++ new/ypbind-mt-1.19.90/configure.in 2006-08-17 03:35:06.000000000 +0200
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/ypbind-mt.c)
-AM_INIT_AUTOMAKE(ypbind-mt, 1.19.1)
+AM_INIT_AUTOMAKE(ypbind-mt, 1.19.90)
AM_CONFIG_HEADER(config.h)
AC_PREFIX_DEFAULT(/usr)
@@ -49,6 +49,19 @@
AC_CHECK_LIB(socket, bind)
AC_CHECK_LIB(pthread, pthread_create)
+AC_ARG_ENABLE([dbus-nm],
+ AC_HELP_STRING([--disable-dbus-nm],[Disable DBUS/NetworkManager support]))
+if test "$enable_dbus_nm" \!= "no"
+then
+ PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.60)
+ AC_SUBST(DBUS_CFLAGS)
+ AC_SUBST(DBUS_LIBS)
+ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6)
+ AC_SUBST(GLIB_CFLAGS)
+ AC_SUBST(GLIB_LIBS)
+ AC_DEFINE(USE_DBUS_NM, 1, [Enable DBUS/NetworkManager support])
+fi
+
dnl The difficult part: could we reconfigure NSS or must we use DNS ?
AC_CHECK_FUNCS(__nss_configure_lookup)
if eval "test \"`echo '$ac_cv_func___nss_configure_lookup'`\" != yes"; then
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/lib/Makefile.am new/ypbind-mt-1.19.90/lib/Makefile.am
--- old/ypbind-mt-1.19.1/lib/Makefile.am 2003-07-12 06:58:09.000000000 +0200
+++ new/ypbind-mt-1.19.90/lib/Makefile.am 2006-08-17 03:51:35.000000000 +0200
@@ -5,8 +5,6 @@
#
# Process this file with automake to produce Makefile.in.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
noinst_LIBRARIES = libcompat.a
EXTRA_DIST = clnt_udp.c
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/man/Makefile.am new/ypbind-mt-1.19.90/man/Makefile.am
--- old/ypbind-mt-1.19.1/man/Makefile.am 2002-04-04 18:34:35.000000000 +0200
+++ new/ypbind-mt-1.19.90/man/Makefile.am 2006-08-17 03:51:41.000000000 +0200
@@ -4,9 +4,7 @@
# Author: Thorsten Kukuk
#
-AUTOMAKE_OPTIONS = 1.6 gnits
-
-CLEANFILES = *~ sedscript ypbind.8 yp.conf.5
+CLEANFILES = *~ ypbind.8 yp.conf.5
EXTRA_DIST = $(addsuffix .in,$(MANS))
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/man/yp.conf.5.in new/ypbind-mt-1.19.90/man/yp.conf.5.in
--- old/ypbind-mt-1.19.1/man/yp.conf.5.in 2004-02-13 22:17:12.000000000 +0100
+++ new/ypbind-mt-1.19.90/man/yp.conf.5.in 2005-07-13 23:53:47.000000000 +0200
@@ -66,7 +66,7 @@
.I hostname
.RS
Use server
-.I server
+.I hostname
for the local domain.
.RE
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/man/ypbind.8.in new/ypbind-mt-1.19.90/man/ypbind.8.in
--- old/ypbind-mt-1.19.1/man/ypbind.8.in 2005-07-02 11:24:15.000000000 +0200
+++ new/ypbind-mt-1.19.90/man/ypbind.8.in 2006-08-17 02:07:26.000000000 +0200
@@ -1,5 +1,5 @@
.\" -*- nroff -*-
-.\" Copyright 1998, 1999, 2002, 2004 Thorsten Kukuk, Germany
+.\" Copyright 1998, 1999, 2002, 2004, 2006 Thorsten Kukuk, Germany
.\"
.\" This file is part of ypbind-mt.
.\"
@@ -20,7 +20,7 @@
.\" write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
.\" Boston, MA 02111-1307, USA.
.\"
-.TH ypbind 8 "October 2004" "ypbind-mt Version @VERSION@"
+.TH ypbind 8 "August 2006" "ypbind-mt Version @VERSION@"
.SH NAME
ypbind - NIS binding process
.SH SYNOPSIS
@@ -95,37 +95,8 @@
.B ypbind
parses the file
.B /etc/yp.conf
-and tries to use the entries for its initial binding. Valid entries
-are
-
-.B domain
-.I nisdomain
-.B server
-.I hostname
-.RS
-Use server
-.I hostname
-for the domain
-.IR nisdomain .
-You could have more then one entry of this type for a single domain.
-.RE
-
-.B domain
-.I nisdomain
-.B broadcast
-.RS
-Use broadcast on the local net for domain
-.IR nisdomain .
-.RE
-
-.B ypserver
-.I hostname
-.RS
-Use server
-.I server
-for the local domain.
-.RE
-
+and tries to use the entries for its initial binding.
+.LP
A broadcast entry in the configuration file will overwrite a ypserver/server
entry and a ypserver/server entry broadcast. If all given server are down,
.B ypbind
@@ -160,13 +131,18 @@
.LP
This
.B ypbind
-is a special version which uses
-.BR pthreads .
-It will start 2 more threads. The master process services RPC requests
-asking for binding info. The first thread initializes the binding and
-checks it periodically. Upon failure, the binding is invalidated and
-the process tries again to find a valid server. The second thread
-will handle all the signals.
+version listens for DBUS messages from NetworkManager. If no NetworkManager
+is running at startup,
+.B ypbind
+will behave as usual and assumes there is a working network
+connection. If NetworkManager is running on the system, ypbind will only
+search and providde NIS informations, if NetworkManager tells that a network
+connection is available. If NetworkManager establishes a connection,
+.B ypbind
+will reread all configuration files, registers at the local portmapper and
+try to search NIS servers. If NetworkManager drops a connection,
+.B ypbind
+will unregister from portmapper.
.SH OPTIONS
.TP
@@ -244,14 +220,6 @@
.B "\--version"
Prints the version number
.LP
-.SH NOTES
-Binding to multiple domains is tested and works.
-Load sharing between multiple servers for a single domain is
-not supported.
-.B ypbind
-will always try to bind a domain to a server. If there is no valid
-server in the list or answers to a broadcast, the domain is unbounded.
-.LP
.SH FILES
.TP
.B /etc/yp.conf
@@ -268,6 +236,7 @@
.SH "SEE ALSO"
.BR syslog (3),
.BR domainname (1),
+.BR yp.conf (5),
.BR ypdomainname (8),
.BR ypwhich (1),
.BR ypserv (8),
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/src/Makefile.am new/ypbind-mt-1.19.90/src/Makefile.am
--- old/ypbind-mt-1.19.1/src/Makefile.am 2004-02-13 22:17:12.000000000 +0100
+++ new/ypbind-mt-1.19.90/src/Makefile.am 2006-08-17 03:51:43.000000000 +0200
@@ -4,15 +4,11 @@
# Author: Thorsten Kukuk
#
-AUTOMAKE_OPTIONS = 1.4 gnits
-
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ -s -m 555
-
-AM_CFLAGS = -D_REENTRANT=1 @WARNFLAGS@ -DUSE_BROADCAST=@USE_BROADCAST@
-LDADD = ../lib/libcompat.a @LIBINTL@ @SLP_LIBS@
-
localedir = $(datadir)/locale
-INCLUDES = -DLOCALEDIR=\"$(localedir)\"
+
+AM_CFLAGS = -D_REENTRANT=1 @WARNFLAGS@ -DUSE_BROADCAST=@USE_BROADCAST@ \
+ -DLOCALEDIR=\"$(localedir)\" @DBUS_CFLAGS@ @GLIB_CFLAGS@
+AM_LDFLAGS = ../lib/libcompat.a @LIBINTL@ @SLP_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@
CLEANFILES = *~
@@ -22,4 +18,4 @@
ypbind_SOURCES = ypbind-mt.c ypbind_xdr.c ypbind_svc.c \
ypbind_server.c log_msg.c serv_list.c \
- pthread_np.c ypbind_slp.c
+ pthread_np.c ypbind_slp.c ypbind_dbus_nm.c
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/src/local.h new/ypbind-mt-1.19.90/src/local.h
--- old/ypbind-mt-1.19.1/src/local.h 2005-07-02 11:24:15.000000000 +0200
+++ new/ypbind-mt-1.19.90/src/local.h 2006-08-17 00:29:07.000000000 +0200
@@ -6,18 +6,26 @@
extern int broken_server;
extern int port;
extern int ping_interval;
+extern int use_broadcast;
+extern char *domain;
extern void find_domain (const char *domain, ypbind_resp *result);
extern void clear_server (void);
extern int add_server (const char *__domain, const char *__host,
int __check_syntax);
extern void change_binding (const char *__domain, ypbind_binding *binding);
+extern int load_config (int check_syntax);
extern int query_slp (const char *domain);
extern void *test_bindings (void *param);
extern int test_bindings_once (int lastcheck, const char *domain);
+#if defined(USE_DBUS_NM)
+extern void *watch_dbus_nm (void *param);
+extern int is_online;
+#endif
+
extern void do_binding (void);
extern void ypbindprog_1 (struct svc_req *rqstp, register SVCXPRT *transp);
@@ -29,4 +37,7 @@
extern struct hostent *res_gethostbyaddr(const char *, int, int);
#endif /* HAVE___NSS_CONFIGURE_LOOKUP */
+void portmapper_disconnect (void);
+int portmapper_connect (void);
+
#endif
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/src/serv_list.c new/ypbind-mt-1.19.90/src/serv_list.c
--- old/ypbind-mt-1.19.1/src/serv_list.c 2005-07-02 11:24:15.000000000 +0200
+++ new/ypbind-mt-1.19.90/src/serv_list.c 2006-08-17 01:37:31.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998-2005 Thorsten Kukuk
+/* Copyright (c) 1998-2006 Thorsten Kukuk
This file is part of ypbind-mt.
Author: Thorsten Kukuk
@@ -330,15 +330,20 @@
{
for (i = 0; i < max_domains; ++i)
{
- for (j = 0; j < _MAXSERVER; ++j)
+ if (domainlist[i].active != -1)
{
- if (domainlist[i].server[j].host != NULL)
- free (domainlist[i].server[j].host);
+ remove_bindingfile (domainlist[i].domain);
+ for (j = 0; j < _MAXSERVER; ++j)
+ {
+ if (domainlist[i].server[j].host != NULL)
+ free (domainlist[i].server[j].host);
+ }
+ if (domainlist[i].ypset.host != NULL)
+ free (domainlist[i].ypset.host);
+ if (domainlist[i].client_handle != NULL)
+ clnt_destroy (domainlist[i].client_handle);
+ domainlist[i].active = -1;
}
- if (domainlist[i].ypset.host != NULL)
- free (domainlist[i].ypset.host);
- if (domainlist[i].client_handle != NULL)
- clnt_destroy (domainlist[i].client_handle);
}
free (domainlist);
}
@@ -1016,7 +1021,10 @@
static int success = 0;
int lastcheck = 0;
- do_binding ();
+#ifdef USE_DBUS_NM
+ if (is_online)
+#endif
+ do_binding ();
if (ping_interval < 1)
pthread_exit (&success);
@@ -1025,8 +1033,7 @@
{
sleep (ping_interval);
- /* Check, if ping_interval was changed through a SIGHUP.
- Not possible in the moment, but maybe in the future. */
+ /* Check, if ping_interval was changed through a SIGHUP. */
if (ping_interval < 1)
pthread_exit (&success);
@@ -1034,8 +1041,11 @@
if (lastcheck >= 900) /* 900 = 15min. */
lastcheck = 0;
- lastcheck = test_bindings_once (lastcheck, NULL);
+#if USE_DBUS_NM
+ if (is_online)
+#endif
+ lastcheck = test_bindings_once (lastcheck, NULL);
} /* end while() endless loop */
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/src/ypbind-mt.c new/ypbind-mt-1.19.90/src/ypbind-mt.c
--- old/ypbind-mt-1.19.1/src/ypbind-mt.c 2005-07-02 11:24:15.000000000 +0200
+++ new/ypbind-mt-1.19.90/src/ypbind-mt.c 2006-08-17 03:57:07.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2001, 2002, 2004, 2005 Thorsten Kukuk
+/* Copyright (c) 1998, 1999, 2001, 2002, 2004, 2005, 2006 Thorsten Kukuk
This file is part of ypbind-mt.
Author: Thorsten Kukuk
@@ -101,7 +101,7 @@
}
/* Load the config file (/etc/yp.conf) */
-static int
+int
load_config (int check_syntax)
{
FILE *fp;
@@ -429,8 +429,7 @@
if (debug_flag)
log_msg (LOG_DEBUG, _("Signal (%d) for quitting program arrived."),
caught);
- pmap_unset (YPBINDPROG, YPBINDVERS);
- pmap_unset (YPBINDPROG, YPBINDOLDVERS);
+ portmapper_disconnect ();
/* unlock pidfile */
lock.l_type = F_UNLCK;
lock.l_start = 0;
@@ -465,23 +464,167 @@
}
static void
-usage (void)
+usage (int ret)
{
- fputs (_("Usage:\n"), stderr);
- fputs (_("\typbind [-broadcast | -ypset | -ypsetme] [-p port] [-f configfile]\n\t [-no-ping] [-broken-server] [-local-only] [-i ping-interval] [-debug]\n"), stderr);
- fputs (_("\typbind -c [-f configfile]\n"), stderr);
- fputs (_("\typbind --version\n"), stderr);
- exit (1);
+ FILE *output;
+
+ if (ret)
+ output = stderr;
+ else
+ output = stdout;
+
+ fputs (_("Usage:\n"), output);
+ fputs (_("\typbind [-broadcast | -ypset | -ypsetme] [-p port] [-f configfile]\n\t [-no-ping] [-broken-server] [-local-only] [-i ping-interval] [-debug]\n"), output);
+ fputs (_("\typbind -c [-f configfile]\n"), output);
+ fputs (_("\typbind --version\n"), output);
+ exit (ret);
}
+void
+portmapper_disconnect (void)
+{
+ pmap_unset (YPBINDPROG, YPBINDOLDVERS);
+ pmap_unset (YPBINDPROG, YPBINDVERS);
+}
+
+static int portmapper_udp_port;
+static int portmapper_tcp_port;
+
int
-main (int argc, char **argv)
+portmapper_connect (void)
+{
+ pmap_set (YPBINDPROG, YPBINDVERS, IPPROTO_UDP, portmapper_udp_port);
+ pmap_set (YPBINDPROG, YPBINDOLDVERS, IPPROTO_UDP, portmapper_udp_port);
+ pmap_set (YPBINDPROG, YPBINDVERS, IPPROTO_TCP, portmapper_tcp_port);
+ pmap_set (YPBINDPROG, YPBINDOLDVERS, IPPROTO_TCP, portmapper_tcp_port);
+ return 0;
+}
+
+static int
+portmapper_register (void)
{
+ struct sockaddr_in socket_address;
SVCXPRT *transp;
- int sock, result, i;
+ int sock, result;
+
+ if (port >= 0 || local_only)
+ {
+ sock = socket (AF_INET, SOCK_DGRAM, 0);
+ if (sock < 0)
+ {
+ log_msg (LOG_ERR, _("Cannot create UDP: %s"), strerror (errno));
+ return 1;
+ }
+
+ memset ((char *) &socket_address, 0, sizeof (socket_address));
+ socket_address.sin_family = AF_INET;
+ if (local_only)
+ socket_address.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+ else
+ socket_address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+ if (port >= 0)
+ socket_address.sin_port = htons (port);
+
+ result = bind (sock, (struct sockaddr *) &socket_address,
+ sizeof (socket_address));
+ if (result < 0)
+ {
+ log_msg (LOG_ERR, _("Cannot bind UDP: %s"), strerror (errno));
+ return 1;
+ }
+ }
+ else
+ sock = RPC_ANYSOCK;
+
+ transp = svcudp_create (sock);
+ if (transp == NULL)
+ {
+ log_msg (LOG_ERR, _("Cannot create udp service."));
+ return 1;
+ }
+ portmapper_udp_port = transp->xp_port;
+
+ if (!svc_register (transp, YPBINDPROG, YPBINDVERS, ypbindprog_2,
+ IPPROTO_UDP))
+ {
+ log_msg (LOG_ERR,
+ _("Unable to register (YPBINDPROG, YPBINDVERS, udp)."));
+ return 1;
+ }
+
+ if (!svc_register (transp, YPBINDPROG, YPBINDOLDVERS, ypbindprog_1,
+ IPPROTO_UDP))
+ {
+ log_msg (LOG_ERR,
+ _("Unable to register (YPBINDPROG, YPBINDOLDVERS, udp)."));
+ return 1;
+ }
+
+ if (port >= 0 || local_only)
+ {
+ sock = socket (AF_INET, SOCK_STREAM, 0);
+ if (sock < 0)
+ {
+ log_msg (LOG_ERR, _("Cannot create TCP: %s"), strerror (errno));
+ return 1;
+ }
+
+ memset (&socket_address, 0, sizeof (socket_address));
+ socket_address.sin_family = AF_INET;
+ if (local_only)
+ socket_address.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+ else
+ socket_address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+ if (port >= 0)
+ socket_address.sin_port = htons (port);
+
+ result = bind (sock, (struct sockaddr *) &socket_address,
+ sizeof (socket_address));
+ if (result < 0)
+ {
+ log_msg (LOG_ERR, _("Cannot bind TCP: %s"), strerror (errno));
+ return 1;
+ }
+ }
+ else
+ sock = RPC_ANYSOCK;
+
+ transp = svctcp_create (sock, 0, 0);
+ if (transp == NULL)
+ {
+ log_msg (LOG_ERR, _("Cannot create tcp service.\n"));
+ return 1;
+ }
+ portmapper_tcp_port = transp->xp_port;
+
+ if (!svc_register (transp, YPBINDPROG, YPBINDVERS, ypbindprog_2,
+ IPPROTO_TCP))
+ {
+ log_msg (LOG_ERR, _("Unable to register (YPBINDPROG, YPBINDVERS, tcp)."));
+ return 1;
+ }
+
+ if (!svc_register (transp, YPBINDPROG, YPBINDOLDVERS, ypbindprog_1,
+ IPPROTO_TCP))
+ {
+ log_msg (LOG_ERR,
+ _("Unable to register (YPBINDPROG, YPBINDOLDVERS, tcp)."));
+ return 1;
+ }
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
sigset_t sigs_to_block;
- struct sockaddr_in socket_address;
pthread_t sig_thread, ping_thread;
+#ifdef USE_DBUS_NM
+ pthread_t dbus_thread;
+#endif
struct stat st;
int configcheck_only = 0;
@@ -495,8 +638,8 @@
{
if (strcmp ("--version", argv[i]) == 0)
{
- fprintf (stderr, "ypbind (%s) %s\n", PACKAGE, VERSION);
- exit (1);
+ fprintf (stdout, "ypbind (%s) %s\n", PACKAGE, VERSION);
+ exit (0);
}
else if (strcmp ("-ypset", argv[i]) == 0)
ypset = SET_YPSET;
@@ -519,14 +662,14 @@
else if (strcmp ("-f", argv[i]) == 0)
{
if (i+1 == argc || argv[i+1][0] == '-')
- usage ();
+ usage (1);
++i;
configfile = argv[i];
}
else if (strcmp ("-p", argv[i]) == 0)
{
if (i+1 == argc || argv[i+1][0] == '-')
- usage ();
+ usage (1);
++i;
port = atoi (argv[i]);
}
@@ -535,14 +678,16 @@
strcmp ("-i", argv[i]) == 0)
{
if (i+1 == argc || argv[i+1][0] == '-')
- usage ();
+ usage (1);
++i;
ping_interval = atoi (argv[i]);
}
else if (strcmp ("-c", argv[i]) == 0)
configcheck_only = 1;
+ else if (strcmp ("--help", argv[i]) == 0)
+ usage (0);
else
- usage ();
+ usage (1);
}
if (yp_get_default_domain (&domain) || domain == NULL ||
@@ -695,116 +840,21 @@
}
pthread_mutex_unlock(&mutex_pid);
- pmap_unset (YPBINDPROG, YPBINDOLDVERS);
- pmap_unset (YPBINDPROG, YPBINDVERS);
-
- if (port >= 0 || local_only)
- {
- sock = socket (AF_INET, SOCK_DGRAM, 0);
- if (sock < 0)
- {
- log_msg (LOG_ERR, _("Cannot create UDP: %s"), strerror (errno));
- exit (1);
- }
-
- memset ((char *) &socket_address, 0, sizeof (socket_address));
- socket_address.sin_family = AF_INET;
- if (local_only)
- socket_address.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
- else
- socket_address.sin_addr.s_addr = htonl (INADDR_ANY);
-
- if (port >= 0)
- socket_address.sin_port = htons (port);
-
- result = bind (sock, (struct sockaddr *) &socket_address,
- sizeof (socket_address));
- if (result < 0)
- {
- log_msg (LOG_ERR, _("Cannot bind UDP: %s"), strerror (errno));
- exit (1);
- }
- }
- else
- sock = RPC_ANYSOCK;
-
- transp = svcudp_create (sock);
- if (transp == NULL)
- {
- log_msg (LOG_ERR, _("Cannot create udp service."));
- exit (1);
- }
-
- if (!svc_register (transp, YPBINDPROG, YPBINDVERS, ypbindprog_2,
- IPPROTO_UDP))
- {
- log_msg (LOG_ERR,
- _("Unable to register (YPBINDPROG, YPBINDVERS, udp)."));
- exit (1);
- }
-
- if (!svc_register (transp, YPBINDPROG, YPBINDOLDVERS, ypbindprog_1,
- IPPROTO_UDP))
+ portmapper_disconnect ();
+ if (portmapper_register () != 0)
{
- log_msg (LOG_ERR,
- _("Unable to register (YPBINDPROG, YPBINDOLDVERS, udp)."));
- exit (1);
- }
-
- if (port >= 0 || local_only)
- {
- sock = socket (AF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- {
- log_msg (LOG_ERR, _("Cannot create TCP: %s"), strerror (errno));
- exit (1);
- }
-
- memset (&socket_address, 0, sizeof (socket_address));
- socket_address.sin_family = AF_INET;
- if (local_only)
- socket_address.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
- else
- socket_address.sin_addr.s_addr = htonl (INADDR_ANY);
-
- if (port >= 0)
- socket_address.sin_port = htons (port);
-
- result = bind (sock, (struct sockaddr *) &socket_address,
- sizeof (socket_address));
- if (result < 0)
- {
- log_msg (LOG_ERR, _("Cannot bind TCP: %s"), strerror (errno));
- exit (1);
- }
- }
- else
- sock = RPC_ANYSOCK;
-
- transp = svctcp_create (sock, 0, 0);
- if (transp == NULL)
- {
- log_msg (LOG_ERR, _("Cannot create tcp service.\n"));
- exit (1);
- }
-
- if (!svc_register (transp, YPBINDPROG, YPBINDVERS, ypbindprog_2,
- IPPROTO_TCP))
- {
- log_msg (LOG_ERR, _("Unable to register (YPBINDPROG, YPBINDVERS, tcp)."));
- exit (1);
- }
-
- if (!svc_register (transp, YPBINDPROG, YPBINDOLDVERS, ypbindprog_1,
- IPPROTO_TCP))
- {
- log_msg (LOG_ERR,
- _("Unable to register (YPBINDPROG, YPBINDOLDVERS, tcp)."));
+ portmapper_disconnect ();
exit (1);
}
+ if (!is_online)
+ portmapper_disconnect ();
pthread_create (&ping_thread, NULL, &test_bindings, NULL);
+#ifdef USE_DBUS_NM
+ pthread_create (&dbus_thread, NULL, &watch_dbus_nm, NULL);
+#endif
+
svc_run ();
log_msg (LOG_ERR, _("svc_run returned."));
unlink (_YPBIND_PIDFILE);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ypbind-mt-1.19.1/src/ypbind_dbus_nm.c new/ypbind-mt-1.19.90/src/ypbind_dbus_nm.c
--- old/ypbind-mt-1.19.1/src/ypbind_dbus_nm.c 1970-01-01 01:00:00.000000000 +0100
+++ new/ypbind-mt-1.19.90/src/ypbind_dbus_nm.c 2006-08-17 01:31:55.000000000 +0200
@@ -0,0 +1,334 @@
+/* Copyright (c) 2006 Thorsten Kukuk
+ This file is part of ypbind-mt.
+ Author: Thorsten Kukuk
+
+ The ypbind-mt are free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ ypbind-mt 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 ypbind-mt; see the file COPYING. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#ifdef USE_DBUS_NM
+
+#define DBUS_API_SUBJECT_TO_CHANGE 1
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "ypbind.h"
+#include "log_msg.h"
+#include "local.h"
+
+#ifndef _
+#define _(String) gettext (String)
+#endif
+
+int is_online = 0;
+
+static void
+go_offline (void)
+{
+ if (is_online == 0) /* Do nothing if already offline. */
+ return;
+
+ if (debug_flag)
+ log_msg (LOG_DEBUG, _("Switch to offline mode"));
+ is_online = 0;
+ portmapper_disconnect ();
+ clear_server ();
+}
+
+static void
+go_online (void)
+{
+ if (is_online) /* Do nothing if already online. */
+ return;
+
+ if (debug_flag)
+ log_msg (LOG_DEBUG, _("Switch to online mode"));
+ is_online = 1;
+
+ /* Reload config file, may have changed. */
+ if (debug_flag)
+ log_msg (LOG_DEBUG, _("Going online, reloading config file."));
+ clear_server ();
+
+ if (use_broadcast)
+ add_server (domain, NULL, 0);
+ else
+ load_config (0);
+
+ if (portmapper_connect () != 0)
+ {
+ go_offline (); /* go offline again */
+ }
+
+ do_binding ();
+}
+
+static int dbus_init (void);
+
+
+static gboolean
+dbus_reconnect (gpointer user_data)
+{
+ gboolean status;
+
+ status = dbus_init ();
+ if (debug_flag)
+ log_msg (LOG_DEBUG, "Reconnect %s",
+ status ? "successful" : "failed");
+ return !status;
+}
+
+static DBusHandlerResult
+dbus_filter (DBusConnection *connection,
+ DBusMessage *message, void *user_data __attribute__((unused)))
+{
+ DBusHandlerResult handled = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL,
+ "Disconnected"))
+ {
+ /* D-Bus system bus went away */
+ log_msg (LOG_INFO, "Lost connection to D-Bus\n");
+ dbus_connection_unref (connection);
+ connection = NULL;
+ g_timeout_add (1000, dbus_reconnect, NULL);
+ handled = DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE,
+ NM_DBUS_SIGNAL_STATE_CHANGE))
+ {
+ NMState state = NM_STATE_UNKNOWN;
+
+ if (dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32,
+ &state, DBUS_TYPE_INVALID))
+ {
+ if (state == NM_STATE_CONNECTED)
+ go_online ();
+ else if (state == NM_STATE_DISCONNECTED)
+ go_offline ();
+ }
+ handled = DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE,
+ "DeviceNoLongerActive"))
+ {
+ go_offline ();
+ handled = DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
+ "NameOwnerChanged"))
+ {
+ if (debug_flag)
+ {
+ char *service = NULL;
+ char *old_owner = NULL;
+ char *new_owner = NULL;
+
+ if (dbus_message_get_args (message, NULL,
+ DBUS_TYPE_STRING, &service,
+ DBUS_TYPE_STRING, &old_owner,
+ DBUS_TYPE_STRING, &new_owner,
+ DBUS_TYPE_INVALID))
+ {
+ if (strcmp (service, NM_DBUS_SERVICE) == 0)
+ {
+ /* Check if it was NetworkManager who dropped off or
+ jumped on the system bus. */
+ int old_owner_good =
+ (old_owner && (strlen (old_owner) > 0));
+ int new_owner_good =
+ (new_owner && (strlen (new_owner) > 0));
+
+ if (!old_owner_good && new_owner_good)
+ log_msg (LOG_DEBUG,
+ "NetworkManager is on the system bus");
+ else if (old_owner_good && !new_owner_good)
+ log_msg (LOG_DEBUG,
+ "NetworkManager left the system bus");
+ }
+ }
+ handled = DBUS_HANDLER_RESULT_HANDLED;
+ }
+ }
+ else if (debug_flag)
+ {
+ log_msg (LOG_DEBUG, "interface: %s, object path: %s, method: %s",
+ dbus_message_get_interface(message),
+ dbus_message_get_path (message),
+ dbus_message_get_member (message));
+ }
+
+ return handled;
+}
+
+static int
+check_online (DBusConnection *connection)
+{
+ DBusMessage *message, *reply;
+ DBusError error;
+ dbus_uint32_t state;
+
+ message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH,
+ NM_DBUS_INTERFACE, "state");
+ if (!message)
+ return -1;
+
+ dbus_error_init (&error);
+ reply = dbus_connection_send_with_reply_and_block (connection, message,
+ -1, &error);
+ dbus_message_unref (message);
+ if (!reply)
+ return 0;
+
+ if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &state,
+ DBUS_TYPE_INVALID))
+ return -1;
+
+ if (state != NM_STATE_CONNECTED)
+ return 0;
+
+ return 1;
+}
+
+static int
+check_for_nm (DBusConnection *connection)
+{
+
+ if (dbus_bus_name_has_owner (connection, NM_DBUS_SERVICE, NULL))
+ {
+ if (debug_flag)
+ log_msg (LOG_DEBUG, "NetworkManager is running.\n");
+ return 1;
+ }
+ else
+ {
+ if (debug_flag)
+ log_msg (LOG_DEBUG, "NetworkManager is running.\n");
+ return 0;
+ }
+}
+
+
+static int
+dbus_init (void)
+{
+ DBusConnection *connection = NULL;
+ DBusError error;
+
+ dbus_error_init (&error);
+
+ connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL || dbus_error_is_set (&error))
+ {
+ log_msg (LOG_ERR, "Connection to D-BUS system message bus failed: %s.",
+ error.message);
+ dbus_error_free (&error);
+ goto out;
+ }
+
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
+
+ if (!dbus_connection_add_filter (connection, dbus_filter, NULL, NULL))
+ goto out;
+
+ dbus_bus_add_match (connection, "type='signal',"
+ "interface='" DBUS_INTERFACE_DBUS "',"
+ "sender='" DBUS_SERVICE_DBUS "'",
+ &error);
+ if (dbus_error_is_set (&error))
+ {
+ log_msg (LOG_ERR, "Error adding match, %s: %s",
+ error.name, error.message);
+
+ dbus_error_free (&error);
+ goto out;
+ }
+
+ dbus_bus_add_match (connection,
+ "type='signal',"
+ "interface='" NM_DBUS_INTERFACE "',"
+ "sender='" NM_DBUS_SERVICE "',"
+ "path='" NM_DBUS_PATH "'", &error);
+ if (dbus_error_is_set (&error))
+ {
+ log_msg (LOG_ERR, "Error adding match, %s: %s",
+ error.name, error.message);
+ dbus_error_free (&error);
+ goto out;
+ }
+
+ dbus_connection_setup_with_g_main (connection, NULL);
+
+ out:
+ if (connection)
+ {
+ if (!check_for_nm (connection))
+ {
+ /* NetworkManager not in use. */
+ dbus_connection_close (connection);
+ is_online = 1;
+ return 0;
+ }
+ if (check_online (connection) == 1)
+ {
+ if (debug_flag)
+ log_msg (LOG_DEBUG, "Are already online");
+ is_online = 1;
+ }
+ else
+ {
+ if (debug_flag)
+ log_msg (LOG_DEBUG, "Are offline");
+ is_online = 0;
+ }
+ return 1;
+ }
+ else
+ return 0;
+}
+
+
+/* This thread handles the NetworkManager communication over DBUS */
+void *
+watch_dbus_nm (void *param __attribute__ ((unused)))
+{
+ static int status = 1;
+ GMainLoop *loop;
+
+ g_type_init ();
+
+ if (dbus_init () != 1)
+ {
+ status = 0;
+ return &status;
+ }
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ g_main_loop_run (loop);
+
+ return &status;
+}
+
+#endif
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org