diff options
Diffstat (limited to 'src/dns-manager')
| -rw-r--r-- | src/dns-manager/Makefile.am | 6 | ||||
| -rw-r--r-- | src/dns-manager/Makefile.in | 91 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-bind.c | 529 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-bind.h | 47 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-dnsmasq.c | 38 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-manager.c | 20 |
6 files changed, 74 insertions, 657 deletions
diff --git a/src/dns-manager/Makefile.am b/src/dns-manager/Makefile.am index c6c28446..e6c2ff22 100644 --- a/src/dns-manager/Makefile.am +++ b/src/dns-manager/Makefile.am @@ -16,8 +16,6 @@ libdns_manager_la_SOURCES = \ nm-dns-plugin.c \ nm-dns-dnsmasq.h \ nm-dns-dnsmasq.c \ - nm-dns-bind.h \ - nm-dns-bind.c \ nm-dns-utils.h \ nm-dns-utils.c @@ -26,7 +24,9 @@ libdns_manager_la_CPPFLAGS = \ $(DBUS_CFLAGS) \ $(GLIB_CFLAGS) \ -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DNMCONFDIR=\"$(nmconfdir)\" \ + -DNMRUNDIR=\"$(nmrundir)\" libdns_manager_la_LIBADD = \ $(top_builddir)/src/logging/libnm-logging.la \ diff --git a/src/dns-manager/Makefile.in b/src/dns-manager/Makefile.in index b8d5c12b..b0ea7e77 100644 --- a/src/dns-manager/Makefile.in +++ b/src/dns-manager/Makefile.in @@ -55,16 +55,18 @@ subdir = src/dns-manager DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \ - $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ - $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/introspection.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnl-check.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gnome-code-coverage.m4 \ + $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ + $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libnl-check.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/vapigen.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -81,7 +83,6 @@ libdns_manager_la_DEPENDENCIES = \ am_libdns_manager_la_OBJECTS = libdns_manager_la-nm-dns-manager.lo \ libdns_manager_la-nm-dns-plugin.lo \ libdns_manager_la-nm-dns-dnsmasq.lo \ - libdns_manager_la-nm-dns-bind.lo \ libdns_manager_la-nm-dns-utils.lo libdns_manager_la_OBJECTS = $(am_libdns_manager_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -135,6 +136,10 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CKDB_PATH = @CKDB_PATH@ +CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ +CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ +CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ @@ -149,9 +154,7 @@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCLIENT_VERSION = @DHCLIENT_VERSION@ DHCPCD_PATH = @DHCPCD_PATH@ -DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ @@ -161,17 +164,14 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GENHTML = @GENHTML@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GIO_CFLAGS = @GIO_CFLAGS@ -GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MAKEFILE = @GLIB_MAKEFILE@ GLIB_MKENUMS = @GLIB_MKENUMS@ -GMODULE_CFLAGS = @GMODULE_CFLAGS@ -GMODULE_LIBS = @GMODULE_LIBS@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ @@ -212,6 +212,7 @@ IPTABLES_PATH = @IPTABLES_PATH@ IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ +LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDL = @LIBDL@ @@ -228,11 +229,7 @@ LIBNL2_LIBS = @LIBNL2_LIBS@ LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_GENL3_CFLAGS = @LIBNL_GENL3_CFLAGS@ -LIBNL_GENL3_LIBS = @LIBNL_GENL3_LIBS@ LIBNL_LIBS = @LIBNL_LIBS@ -LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ -LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ @@ -247,6 +244,8 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ +MM_GLIB_LIBS = @MM_GLIB_LIBS@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ @@ -256,6 +255,7 @@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ NM_VERSION = @NM_VERSION@ NSS_CFLAGS = @NSS_CFLAGS@ NSS_LIBS = @NSS_LIBS@ @@ -282,13 +282,14 @@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ -RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ -SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ -SYSTEMD_LIBS = @SYSTEMD_LIBS@ +SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ +SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ +SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ @@ -343,6 +344,11 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +nmbinary = @nmbinary@ +nmconfdir = @nmconfdir@ +nmdatadir = @nmdatadir@ +nmrundir = @nmrundir@ +nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ @@ -357,6 +363,10 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +with_dhclient = @with_dhclient@ +with_dhcpcd = @with_dhcpcd@ +with_netconfig = @with_netconfig@ +with_resolvconf = @with_resolvconf@ INCLUDES = \ -I${top_srcdir}/src/logging \ -I${top_srcdir}/src/posix-signals \ @@ -374,8 +384,6 @@ libdns_manager_la_SOURCES = \ nm-dns-plugin.c \ nm-dns-dnsmasq.h \ nm-dns-dnsmasq.c \ - nm-dns-bind.h \ - nm-dns-bind.c \ nm-dns-utils.h \ nm-dns-utils.c @@ -384,7 +392,9 @@ libdns_manager_la_CPPFLAGS = \ $(DBUS_CFLAGS) \ $(GLIB_CFLAGS) \ -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DNMCONFDIR=\"$(nmconfdir)\" \ + -DNMRUNDIR=\"$(nmrundir)\" libdns_manager_la_LIBADD = \ $(top_builddir)/src/logging/libnm-logging.la \ @@ -445,32 +455,28 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdns_manager_la-nm-dns-bind.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdns_manager_la-nm-dns-dnsmasq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdns_manager_la-nm-dns-manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdns_manager_la-nm-dns-plugin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdns_manager_la-nm-dns-utils.Plo@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< @@ -496,13 +502,6 @@ libdns_manager_la-nm-dns-dnsmasq.lo: nm-dns-dnsmasq.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdns_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdns_manager_la-nm-dns-dnsmasq.lo `test -f 'nm-dns-dnsmasq.c' || echo '$(srcdir)/'`nm-dns-dnsmasq.c -libdns_manager_la-nm-dns-bind.lo: nm-dns-bind.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdns_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdns_manager_la-nm-dns-bind.lo -MD -MP -MF $(DEPDIR)/libdns_manager_la-nm-dns-bind.Tpo -c -o libdns_manager_la-nm-dns-bind.lo `test -f 'nm-dns-bind.c' || echo '$(srcdir)/'`nm-dns-bind.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdns_manager_la-nm-dns-bind.Tpo $(DEPDIR)/libdns_manager_la-nm-dns-bind.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nm-dns-bind.c' object='libdns_manager_la-nm-dns-bind.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdns_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdns_manager_la-nm-dns-bind.lo `test -f 'nm-dns-bind.c' || echo '$(srcdir)/'`nm-dns-bind.c - libdns_manager_la-nm-dns-utils.lo: nm-dns-utils.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdns_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdns_manager_la-nm-dns-utils.lo -MD -MP -MF $(DEPDIR)/libdns_manager_la-nm-dns-utils.Tpo -c -o libdns_manager_la-nm-dns-utils.lo `test -f 'nm-dns-utils.c' || echo '$(srcdir)/'`nm-dns-utils.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdns_manager_la-nm-dns-utils.Tpo $(DEPDIR)/libdns_manager_la-nm-dns-utils.Plo diff --git a/src/dns-manager/nm-dns-bind.c b/src/dns-manager/nm-dns-bind.c deleted file mode 100644 index 1a3243be..00000000 --- a/src/dns-manager/nm-dns-bind.c +++ /dev/null @@ -1,529 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2010 Dan Williams <dcbw@redhat.com> - * - * 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, 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, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include <config.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <arpa/inet.h> -#include <sys/stat.h> - -#include <glib.h> -#include <glib/gi18n.h> - -#include "nm-dns-bind.h" -#include "nm-logging.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" - -G_DEFINE_TYPE (NMDnsBind, nm_dns_bind, NM_TYPE_DNS_PLUGIN) - -#define NM_DNS_BIND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DNS_BIND, NMDnsBindPrivate)) - -#define PIDFILE LOCALSTATEDIR "/run/nm-dns-named.pid" -#define CONFFILE LOCALSTATEDIR "/run/nm-dns-named.conf" - -typedef struct { - GPid pid; -} NMDnsBindPrivate; - -/*******************************************/ - -static inline const char * -find_bind (void) -{ - static const char *paths[] = { - "/usr/local/sbin/named", - "/usr/sbin/named", - "/sbin/named", - NULL - }; - const char **binary = paths; - - while (*binary != NULL) { - if (g_file_test (*binary, G_FILE_TEST_EXISTS)) - return *binary; - binary++; - } - return NULL; -} - -static gboolean -start_bind (NMDnsBind *self) -{ - const char *argv[10]; - - argv[0] = find_bind (); - argv[1] = "-f"; /* don't daemonize; stay in foreground */ - argv[2] = "-c"; - argv[3] = CONFFILE; - argv[4] = NULL; - - /* And finally spawn bind */ - return nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/named"); -} - -/*******************************************/ - -static gboolean -find_address (GPtrArray *array, const char *addr) -{ - int n; - - for (n = 0; n < array->len; n++) { - if (g_strcmp0 ((const char*) g_ptr_array_index (array, n), addr) == 0) - return TRUE; - } - return FALSE; -} - -static void -add_ip4_nameservers (NMIP4Config *ip4, GPtrArray *array) -{ - int i; - - for (i = 0; i < nm_ip4_config_get_num_nameservers (ip4); i++) { - char buf[INET_ADDRSTRLEN + 1]; - struct in_addr addr; - - memset (&buf[0], 0, sizeof (buf)); - addr.s_addr = nm_ip4_config_get_nameserver (ip4, i); - if (inet_ntop (AF_INET, &addr, buf, sizeof (buf))) { - if (!find_address (array, buf)) - g_ptr_array_add (array, g_strdup (buf)); - } - } -} - -static gboolean -ip6_addr_to_string (const struct in6_addr *addr, char *buf, size_t buflen) -{ - /* inet_ntop is probably supposed to do this for us, but it doesn't */ - if (IN6_IS_ADDR_V4MAPPED (addr)) - return !!inet_ntop (AF_INET, &(addr->s6_addr32[3]), buf, buflen); - - return !!inet_ntop (AF_INET6, addr, buf, buflen); -} - -static void -add_ip6_nameservers (NMIP6Config *ip6, GPtrArray *array) -{ - char buf[INET6_ADDRSTRLEN + 1]; - int i; - - for (i = 0; i < nm_ip6_config_get_num_nameservers (ip6); i++) { - memset (buf, 0, sizeof (buf)); - if (ip6_addr_to_string (nm_ip6_config_get_nameserver (ip6, i), buf, sizeof (buf))) { - if (!find_address (array, buf)) - g_ptr_array_add (array, g_strdup (buf)); - } - } -} - -typedef struct { - guint32 dhash; - char *domain; - GPtrArray *servers; -} ZoneInfo; - -static ZoneInfo * -zone_new (const char *domain) -{ - ZoneInfo *info; - - g_return_val_if_fail (domain != NULL, NULL); - - info = g_malloc0 (sizeof (ZoneInfo)); - info->domain = g_strdup (domain); - info->dhash = g_str_hash (domain); - info->servers = g_ptr_array_sized_new (4); - return info; -} - -static void -zone_add_nameserver (ZoneInfo *info, const char *server) -{ - guint32 i; - - g_return_if_fail (info != NULL); - g_return_if_fail (server != NULL); - - for (i = 0; i < info->servers->len; i++) { - if (g_strcmp0 ((char *) g_ptr_array_index (info->servers, i), server) == 0) - return; - } - g_ptr_array_add (info->servers, g_strdup (server)); -} - -static void -zone_free (ZoneInfo *info) -{ - g_return_if_fail (info != NULL); - - g_free (info->domain); - g_ptr_array_foreach (info->servers, (GFunc) g_free, NULL); - g_ptr_array_free (info->servers, TRUE); - memset (info, 0, sizeof (ZoneInfo)); - g_free (info); -} - -static ZoneInfo * -find_zone (GPtrArray *zones, const char *domain) -{ - guint32 dhash, i; - - g_return_val_if_fail (domain != NULL, NULL); - - dhash = g_str_hash (domain); - for (i = 0; i < zones->len; i++) { - ZoneInfo *zone = g_ptr_array_index (zones, i); - - if (zone->dhash == dhash) - return zone; - } - return NULL; -} - -static void -add_zone (GObject *ip, GPtrArray *zones) -{ - guint32 i, j, ns, nd, nn; - GPtrArray *to_add; - ZoneInfo *z; - - if (NM_IS_IP4_CONFIG (ip)) { - ns = nm_ip4_config_get_num_searches (NM_IP4_CONFIG (ip)); - nd = nm_ip4_config_get_num_domains (NM_IP4_CONFIG (ip)); - nn = nm_ip4_config_get_num_nameservers (NM_IP4_CONFIG (ip)); - } else if (NM_IS_IP6_CONFIG (ip)) { - ns = nm_ip6_config_get_num_searches (NM_IP6_CONFIG (ip)); - nd = nm_ip6_config_get_num_domains (NM_IP6_CONFIG (ip)); - nn = nm_ip6_config_get_num_nameservers (NM_IP6_CONFIG (ip)); - } else - g_assert_not_reached (); - - /* If we don't have any domains or searches, or we don't have any - * nameservers, we can't do split DNS for this config. - */ - if ((!nd && !ns) || !nn) - return; - - to_add = g_ptr_array_sized_new (MAX (ns, nd)); - - /* searches are preferred over domains */ - for (i = 0; i < ns; i++) { - const char *domain = NULL; - - if (NM_IS_IP4_CONFIG (ip)) - domain = nm_ip4_config_get_search (NM_IP4_CONFIG (ip), i); - else if (NM_IS_IP6_CONFIG (ip)) - domain = nm_ip6_config_get_search (NM_IP6_CONFIG (ip), i); - - z = find_zone (zones, domain); - if (!z) { - z = zone_new (domain); - g_ptr_array_add (zones, z); - } - g_ptr_array_add (to_add, z); - } - - if (ns == 0) { - /* If no searches, add any domains */ - for (i = 0; i < nd; i++) { - const char *domain = NULL; - - if (NM_IS_IP4_CONFIG (ip)) - domain = nm_ip4_config_get_domain (NM_IP4_CONFIG (ip), i); - else if (NM_IS_IP6_CONFIG (ip)) - domain = nm_ip6_config_get_domain (NM_IP6_CONFIG (ip), i); - - z = find_zone (zones, domain); - if (!z) { - z = zone_new (domain); - g_ptr_array_add (zones, z); - } - g_ptr_array_add (to_add, z); - } - } - - /* Now add the nameservers to every zone for this config */ - for (i = 0; i < nn; i++) { - char buf[INET6_ADDRSTRLEN + 1]; - struct in_addr addr4; - const struct in6_addr *addr6; - - memset (&buf[0], 0, sizeof (buf)); - - if (NM_IS_IP4_CONFIG (ip)) { - addr4.s_addr = nm_ip4_config_get_nameserver (NM_IP4_CONFIG (ip), i); - if (!inet_ntop (AF_INET, &addr4, buf, sizeof (buf))) - continue; - } else if (NM_IS_IP6_CONFIG (ip)) { - addr6 = nm_ip6_config_get_nameserver (NM_IP6_CONFIG (ip), i); - if (!ip6_addr_to_string (addr6, buf, sizeof (buf))) - continue; - } - - /* Add this nameserver to every zone from this IP config */ - for (j = 0; j < to_add->len; j++) { - z = g_ptr_array_index (to_add, j); - zone_add_nameserver (z, buf); - } - } - - g_ptr_array_free (to_add, TRUE); -} - -static gboolean -update (NMDnsPlugin *plugin, - const GSList *vpn_configs, - const GSList *dev_configs, - const GSList *other_configs, - const char *hostname, - const char *iface) -{ - NMDnsBind *self = NM_DNS_BIND (plugin); - NMDnsBindPrivate *priv = NM_DNS_BIND_GET_PRIVATE (self); - GString *conf; - GPtrArray *globals, *zones; - GSList *iter; - GError *error = NULL; - int ignored, i, j; - gboolean success = FALSE; - - /* Build up the new bind config file */ - conf = g_string_sized_new (200); - globals = g_ptr_array_sized_new (6); - - /* If any of the VPN configs *don't* have domains or searches, then we - * dont' have any split DNS configuration for them, and we add them - * first in the global nameserver lists. Otherwise we add them later as - * split DNS zones. - */ - for (iter = (GSList *) vpn_configs; iter;iter = g_slist_next (iter)) { - if (NM_IS_IP4_CONFIG (iter->data)) { - NMIP4Config *ip4 = NM_IP4_CONFIG (iter->data); - - if (!nm_ip4_config_get_num_domains (ip4) && !nm_ip4_config_get_num_searches (ip4)) - add_ip4_nameservers (ip4, globals); - } else if (NM_IS_IP6_CONFIG (iter->data)) { - NMIP6Config *ip6 = NM_IP6_CONFIG (iter->data); - - if (!nm_ip6_config_get_num_domains (ip6) && !nm_ip6_config_get_num_searches (ip6)) - add_ip6_nameservers (ip6, globals); - } - } - - /* Get a list of global upstream servers with dupe checking */ - for (iter = (GSList *) dev_configs; iter;iter = g_slist_next (iter)) { - if (NM_IS_IP4_CONFIG (iter->data)) - add_ip4_nameservers (NM_IP4_CONFIG (iter->data), globals); - else if (NM_IS_IP6_CONFIG (iter->data)) - add_ip6_nameservers (NM_IP6_CONFIG (iter->data), globals); - } - - /* And any other random configs with dupe checking */ - for (iter = (GSList *) other_configs; iter;iter = g_slist_next (iter)) { - if (NM_IS_IP4_CONFIG (iter->data)) - add_ip4_nameservers (NM_IP4_CONFIG (iter->data), globals); - else if (NM_IS_IP6_CONFIG (iter->data)) - add_ip6_nameservers (NM_IP6_CONFIG (iter->data), globals); - } - - g_string_append (conf, - "options {\n" - " directory \"" LOCALSTATEDIR "/named\";\n" - " forward only;\n" - " recursion yes;\n" - " listen-on-v6 { ::1; };\n" - " listen-on { 127.0.0.1; };\n" - " forwarders {\n"); - - for (i = 0; i < globals->len; i++) { - char *ns = g_ptr_array_index (globals, i); - - g_string_append_printf (conf, " %s;\n", ns); - g_free (ns); - } - g_ptr_array_free (globals, TRUE); - - g_string_append (conf, - " };\n" - "};\n\n"); - - /* Build up the list of any split DNS zones, avoiding duplicates */ - zones = g_ptr_array_sized_new (4); - for (iter = (GSList *) vpn_configs; iter;iter = g_slist_next (iter)) { - if (NM_IS_IP4_CONFIG (iter->data)) - add_zone (G_OBJECT (iter->data), zones); - else if (NM_IS_IP6_CONFIG (iter->data)) - add_zone (G_OBJECT (iter->data), zones); - } - - /* Add all the zones to the config */ - for (i = 0; i < zones->len; i++) { - ZoneInfo *z = g_ptr_array_index (zones, i); - - g_string_append_printf (conf, - "zone \"%s\" IN {\n" - " type forward;\n" - " forward only;\n" - " forwarders {\n", - z->domain); - - /* Add each nameserver for this zone */ - for (j = 0; j < z->servers->len; j++) { - g_string_append_printf (conf, - " %s;\n", - (const char *) g_ptr_array_index (z->servers, j)); - } - - g_string_append (conf, - " };\n" - "};\n\n"); - - zone_free (z); - } - g_ptr_array_free (zones, TRUE); - - /* Write out the config file */ - if (!g_file_set_contents (CONFFILE, conf->str, -1, &error)) { - nm_log_warn (LOGD_DNS, "Failed to write named config file %s: (%d) %s", - CONFFILE, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); - g_clear_error (&error); - goto out; - } - ignored = chmod (CONFFILE, 0644); - - nm_log_dbg (LOGD_DNS, "BIND local caching DNS configuration:"); - nm_log_dbg (LOGD_DNS, "%s", conf->str); - - if (priv->pid) { - /* Send it SIGHUP to reload the new configuration */ - if (kill (priv->pid, SIGHUP) == 0) - success = TRUE; - else { - /* Sigh... some error. Kill it and restart */ - nm_dns_plugin_child_kill (NM_DNS_PLUGIN (self)); - priv->pid = 0; - } - } - - if (!success) { - /* Spawn it */ - priv->pid = start_bind (self); - if (priv->pid) - success = TRUE; - } - -out: - g_string_free (conf, TRUE); - return success; -} - -/****************************************************************/ - -static void -child_quit (NMDnsPlugin *plugin, gint status) -{ - NMDnsBind *self = NM_DNS_BIND (plugin); - gboolean failed = TRUE; - int err; - - if (WIFEXITED (status)) { - err = WEXITSTATUS (status); - if (err) { - nm_log_warn (LOGD_DNS, "named exited with error %d", err); - } else - failed = FALSE; - } else if (WIFSTOPPED (status)) { - nm_log_warn (LOGD_DNS, "named stopped unexpectedly with signal %d", WSTOPSIG (status)); - } else if (WIFSIGNALED (status)) { - nm_log_warn (LOGD_DNS, "named died with signal %d", WTERMSIG (status)); - } else { - nm_log_warn (LOGD_DNS, "named died from an unknown cause"); - } - unlink (CONFFILE); - - if (failed) - g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); -} - -/****************************************************************/ - -static gboolean -init (NMDnsPlugin *plugin) -{ - return TRUE; -} - -static gboolean -is_caching (NMDnsPlugin *plugin) -{ - return TRUE; -} - -static const char * -get_name (NMDnsPlugin *plugin) -{ - return "bind"; -} - -/****************************************************************/ - -NMDnsBind * -nm_dns_bind_new (void) -{ - return (NMDnsBind *) g_object_new (NM_TYPE_DNS_BIND, NULL); -} - -static void -nm_dns_bind_init (NMDnsBind *self) -{ -} - -static void -dispose (GObject *object) -{ - unlink (CONFFILE); - - G_OBJECT_CLASS (nm_dns_bind_parent_class)->dispose (object); -} - -static void -nm_dns_bind_class_init (NMDnsBindClass *dns_class) -{ - NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (dns_class); - GObjectClass *object_class = G_OBJECT_CLASS (dns_class); - - g_type_class_add_private (dns_class, sizeof (NMDnsBindPrivate)); - - object_class->dispose = dispose; - - plugin_class->init = init; - plugin_class->child_quit = child_quit; - plugin_class->is_caching = is_caching; - plugin_class->update = update; - plugin_class->get_name = get_name; -} - diff --git a/src/dns-manager/nm-dns-bind.h b/src/dns-manager/nm-dns-bind.h deleted file mode 100644 index d3ab3819..00000000 --- a/src/dns-manager/nm-dns-bind.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* 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, 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, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2010 Red Hat, Inc. - */ - -#ifndef NM_DNS_BIND_H -#define NM_DNS_BIND_H - -#include <glib.h> -#include <glib-object.h> - -#include "nm-dns-plugin.h" - -#define NM_TYPE_DNS_BIND (nm_dns_bind_get_type ()) -#define NM_DNS_BIND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_BIND, NMDnsBind)) -#define NM_DNS_BIND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_BIND, NMDnsBindClass)) -#define NM_IS_DNS_BIND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_BIND)) -#define NM_IS_DNS_BIND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_BIND)) -#define NM_DNS_BIND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_BIND, NMDnsBindClass)) - -typedef struct { - NMDnsPlugin parent; -} NMDnsBind; - -typedef struct { - NMDnsPluginClass parent; -} NMDnsBindClass; - -GType nm_dns_bind_get_type (void); - -NMDnsBind *nm_dns_bind_new (void); - -#endif /* NM_DNS_BIND_H */ - diff --git a/src/dns-manager/nm-dns-dnsmasq.c b/src/dns-manager/nm-dns-dnsmasq.c index 5d37e374..e07240c5 100644 --- a/src/dns-manager/nm-dns-dnsmasq.c +++ b/src/dns-manager/nm-dns-dnsmasq.c @@ -39,9 +39,9 @@ G_DEFINE_TYPE (NMDnsDnsmasq, nm_dns_dnsmasq, NM_TYPE_DNS_PLUGIN) #define NM_DNS_DNSMASQ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasqPrivate)) -#define PIDFILE LOCALSTATEDIR "/run/nm-dns-dnsmasq.pid" -#define CONFFILE LOCALSTATEDIR "/run/nm-dns-dnsmasq.conf" -#define CONFDIR SYSCONFDIR "/NetworkManager/dnsmasq.d" +#define PIDFILE NMRUNDIR "/dnsmasq.pid" +#define CONFFILE NMRUNDIR "/dnsmasq.conf" +#define CONFDIR NMCONFDIR "/dnsmasq.d" typedef struct { guint32 foo; @@ -253,10 +253,11 @@ update (NMDnsPlugin *plugin, NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin); GString *conf; GSList *iter; - const char *argv[12]; + const char *argv[15]; GError *error = NULL; int ignored; GPid pid = 0; + guint idx = 0; /* Kill the old dnsmasq; there doesn't appear to be a way to get dnsmasq * to reread the config file using SIGHUP or similar. This is a small race @@ -306,18 +307,23 @@ update (NMDnsPlugin *plugin, nm_log_dbg (LOGD_DNS, "dnsmasq local caching DNS configuration:"); nm_log_dbg (LOGD_DNS, "%s", conf->str); - argv[0] = find_dnsmasq (); - argv[1] = "--no-resolv"; /* Use only commandline */ - argv[2] = "--keep-in-foreground"; - argv[3] = "--no-hosts"; /* don't use /etc/hosts to resolve */ - argv[4] = "--bind-interfaces"; - argv[5] = "--pid-file=" PIDFILE; - argv[6] = "--listen-address=127.0.0.1"; /* Should work for both 4 and 6 */ - argv[7] = "--conf-file=" CONFFILE; - argv[8] = "--cache-size=400"; - argv[9] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */ - argv[10] = "--conf-dir=" CONFDIR; - argv[11] = NULL; + argv[idx++] = find_dnsmasq (); + argv[idx++] = "--no-resolv"; /* Use only commandline */ + argv[idx++] = "--keep-in-foreground"; + argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */ + argv[idx++] = "--bind-interfaces"; + argv[idx++] = "--pid-file=" PIDFILE; + argv[idx++] = "--listen-address=127.0.0.1"; /* Should work for both 4 and 6 */ + argv[idx++] = "--conf-file=" CONFFILE; + argv[idx++] = "--cache-size=400"; + argv[idx++] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */ + + /* dnsmasq exits if the conf dir is not present */ + if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR)) + argv[idx++] = "--conf-dir=" CONFDIR; + + argv[idx++] = NULL; + g_warn_if_fail (idx <= G_N_ELEMENTS (argv)); /* And finally spawn dnsmasq */ pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq"); diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index 38ef08ea..38691f37 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -40,17 +40,11 @@ #include "nm-ip4-config.h" #include "nm-ip6-config.h" #include "nm-logging.h" -#include "backends/nm-backend.h" #include "NetworkManagerUtils.h" #include "nm-posix-signals.h" #include "nm-dns-plugin.h" #include "nm-dns-dnsmasq.h" -#include "nm-dns-bind.h" - -#ifdef HAVE_SELINUX -#include <selinux/selinux.h> -#endif #ifndef RESOLV_CONF #define RESOLV_CONF "/etc/resolv.conf" @@ -208,7 +202,7 @@ merge_one_ip6_config (NMResolvConfData *rc, NMIP6Config *src, const char *iface) } -#if defined(TARGET_SUSE) +#if defined(NETCONFIG_PATH) /**********************************/ /* SUSE */ @@ -232,7 +226,7 @@ run_netconfig (GError **error, gint *stdin_fd) char *tmp; GPid pid = -1; - argv[0] = "/sbin/netconfig"; + argv[0] = NETCONFIG_PATH; argv[1] = "modify"; argv[2] = "--service"; argv[3] = "NetworkManager"; @@ -756,7 +750,7 @@ update_dns (NMDnsManager *self, success = dispatch_resolvconf (domain, searches, nameservers, iface, error); #endif -#ifdef TARGET_SUSE +#ifdef NETCONFIG_PATH if (success == FALSE) { success = dispatch_netconfig (domain, searches, nameservers, nis_domain, nis_servers, @@ -767,9 +761,6 @@ update_dns (NMDnsManager *self, if (success == FALSE) success = update_resolv_conf (domain, searches, nameservers, iface, error); - if (success) - nm_backend_update_dns (); - if (searches) g_strfreev (searches); if (nameservers) @@ -1055,10 +1046,7 @@ load_plugins (NMDnsManager *self, const char **plugins) for (iter = plugins; iter && *iter; iter++) { if (!strcasecmp (*iter, "dnsmasq")) plugin = NM_DNS_PLUGIN (nm_dns_dnsmasq_new ()); - else if (!strcasecmp (*iter, "bind")) { - plugin = NM_DNS_PLUGIN (nm_dns_bind_new ()); - nm_log_warn (LOGD_DNS, "The BIND plugin is experimental!"); - } else { + else { nm_log_warn (LOGD_DNS, "Unknown DNS plugin '%s'", *iter);\ continue; } |