diff options
| author | Michael Biebl <biebl@debian.org> | 2011-05-04 21:35:41 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2011-05-04 21:35:41 +0200 |
| commit | 9f806e97a24bba61417ae312fcc0da40914266fb (patch) | |
| tree | 4a25723414ceac11b4cba0558aa16f6f4b459f4b /callouts | |
| parent | 8baa1aca8dfd35e3190d7d5655eb83b5b901e263 (diff) | |
Imported Upstream version 0.8.999 upstream/0.8.999
Diffstat (limited to 'callouts')
| -rw-r--r-- | callouts/Makefile.am | 35 | ||||
| -rw-r--r-- | callouts/Makefile.in | 396 | ||||
| -rw-r--r-- | callouts/nm-dispatcher-action.c | 303 | ||||
| -rw-r--r-- | callouts/nm-dispatcher-action.h | 1 | ||||
| -rw-r--r-- | callouts/nm-dispatcher-utils.c | 509 | ||||
| -rw-r--r-- | callouts/nm-dispatcher-utils.h | 41 | ||||
| -rw-r--r-- | callouts/nm-dispatcher.xml | 40 | ||||
| -rw-r--r-- | callouts/tests/Makefile.am | 38 | ||||
| -rw-r--r-- | callouts/tests/Makefile.in | 645 | ||||
| -rw-r--r-- | callouts/tests/dispatcher-old-down | 19 | ||||
| -rw-r--r-- | callouts/tests/dispatcher-old-up | 55 | ||||
| -rw-r--r-- | callouts/tests/dispatcher-old-vpn-down | 54 | ||||
| -rw-r--r-- | callouts/tests/dispatcher-old-vpn-up | 54 | ||||
| -rw-r--r-- | callouts/tests/test-dispatcher-envp.c | 615 |
14 files changed, 2469 insertions, 336 deletions
diff --git a/callouts/Makefile.am b/callouts/Makefile.am index 9fcdd6c7..4a1ea7ca 100644 --- a/callouts/Makefile.am +++ b/callouts/Makefile.am @@ -1,3 +1,13 @@ +SUBDIRS=. tests + +########################################### +# Test libraries +########################################### + +noinst_LTLIBRARIES = \ + libtest-dispatcher-envp.la + + dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = \ nm-dhcp-client.conf \ @@ -41,7 +51,9 @@ nm_avahi_autoipd_action_LDADD = \ nm_dispatcher_action_SOURCES = \ nm-dispatcher-action.c \ - nm-dispatcher-action.h + nm-dispatcher-action.h \ + nm-dispatcher-utils.c \ + nm-dispatcher-utils.h nm_dispatcher_action_CPPFLAGS = \ -I${top_srcdir} \ @@ -54,7 +66,6 @@ nm_dispatcher_action_CPPFLAGS = \ -DLIBEXECDIR=\"$(libexecdir)\" nm_dispatcher_action_LDADD = \ - $(top_builddir)/libnm-glib/libnm-glib.la \ $(top_builddir)/libnm-util/libnm-util.la \ $(DBUS_LIBS) \ $(GLIB_LIBS) @@ -62,6 +73,26 @@ nm_dispatcher_action_LDADD = \ nm-dispatcher-glue.h: nm-dispatcher.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_dispatcher --mode=glib-server --output=$@ $< +########################################### +# dispatcher envp +########################################### + +libtest_dispatcher_envp_la_SOURCES = \ + nm-dispatcher-utils.c \ + nm-dispatcher-utils.h + +libtest_dispatcher_envp_la_CPPFLAGS = \ + -I${top_srcdir}/include \ + -I${top_srcdir}/libnm-util \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) + +libtest_dispatcher_envp_la_LIBADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) + + udevrulesdir = $(UDEV_BASE_DIR)/rules.d udevrules_DATA = 77-nm-olpc-mesh.rules diff --git a/callouts/Makefile.in b/callouts/Makefile.in index 54912dfb..763d7fb2 100644 --- a/callouts/Makefile.in +++ b/callouts/Makefile.in @@ -16,6 +16,7 @@ @SET_MAKE@ + VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ @@ -41,17 +42,34 @@ subdir = callouts 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/gtk-doc.m4 $(top_srcdir)/m4/intltool.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)/configure.ac + $(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)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +am__DEPENDENCIES_1 = +libtest_dispatcher_envp_la_DEPENDENCIES = \ + $(top_builddir)/libnm-util/libnm-util.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_libtest_dispatcher_envp_la_OBJECTS = \ + libtest_dispatcher_envp_la-nm-dispatcher-utils.lo +libtest_dispatcher_envp_la_OBJECTS = \ + $(am_libtest_dispatcher_envp_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent am__installdirs = "$(DESTDIR)$(libexecdir)" \ "$(DESTDIR)$(dbusactivationdir)" "$(DESTDIR)$(dbusservicedir)" \ "$(DESTDIR)$(udevrulesdir)" @@ -60,26 +78,22 @@ am_nm_avahi_autoipd_action_OBJECTS = \ nm_avahi_autoipd_action-nm-avahi-autoipd-action.$(OBJEXT) nm_avahi_autoipd_action_OBJECTS = \ $(am_nm_avahi_autoipd_action_OBJECTS) -am__DEPENDENCIES_1 = nm_avahi_autoipd_action_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) -am__v_lt_0 = --silent am_nm_dhcp_client_action_OBJECTS = \ nm_dhcp_client_action-nm-dhcp-client-action.$(OBJEXT) nm_dhcp_client_action_OBJECTS = $(am_nm_dhcp_client_action_OBJECTS) nm_dhcp_client_action_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_nm_dispatcher_action_OBJECTS = \ - nm_dispatcher_action-nm-dispatcher-action.$(OBJEXT) + nm_dispatcher_action-nm-dispatcher-action.$(OBJEXT) \ + nm_dispatcher_action-nm-dispatcher-utils.$(OBJEXT) nm_dispatcher_action_OBJECTS = $(am_nm_dispatcher_action_OBJECTS) nm_dispatcher_action_DEPENDENCIES = \ - $(top_builddir)/libnm-glib/libnm-glib.la \ $(top_builddir)/libnm-util/libnm-util.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ @@ -104,12 +118,21 @@ am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(nm_avahi_autoipd_action_SOURCES) \ +SOURCES = $(libtest_dispatcher_envp_la_SOURCES) \ + $(nm_avahi_autoipd_action_SOURCES) \ $(nm_dhcp_client_action_SOURCES) \ $(nm_dispatcher_action_SOURCES) -DIST_SOURCES = $(nm_avahi_autoipd_action_SOURCES) \ +DIST_SOURCES = $(libtest_dispatcher_envp_la_SOURCES) \ + $(nm_avahi_autoipd_action_SOURCES) \ $(nm_dhcp_client_action_SOURCES) \ $(nm_dispatcher_action_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -132,11 +155,41 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' DATA = $(dbusactivation_DATA) $(dbusservice_DATA) $(udevrules_DATA) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir ETAGS = etags CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" ACLOCAL = @ACLOCAL@ -ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ @@ -145,13 +198,15 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -163,6 +218,7 @@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCLIENT_VERSION = @DHCLIENT_VERSION@ DHCPCD_PATH = @DHCPCD_PATH@ DISABLE_DEPRECATED = @DISABLE_DEPRECATED@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -171,6 +227,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ @@ -179,8 +236,8 @@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ -GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ @@ -195,13 +252,23 @@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ +IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ +IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LD = @LD@ LDFLAGS = @LDFLAGS@ @@ -209,6 +276,8 @@ LIBDL = @LIBDL@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ LIBM = @LIBM@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ @@ -217,13 +286,15 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ -MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ -MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -249,13 +320,12 @@ PKGCONFIG_PATH = @PKGCONFIG_PATH@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POFILES = @POFILES@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ -PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ -PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -269,11 +339,15 @@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ @@ -321,6 +395,14 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +SUBDIRS = . tests + +########################################### +# Test libraries +########################################### +noinst_LTLIBRARIES = \ + libtest-dispatcher-envp.la + dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = \ nm-dhcp-client.conf \ @@ -357,7 +439,9 @@ nm_avahi_autoipd_action_LDADD = \ nm_dispatcher_action_SOURCES = \ nm-dispatcher-action.c \ - nm-dispatcher-action.h + nm-dispatcher-action.h \ + nm-dispatcher-utils.c \ + nm-dispatcher-utils.h nm_dispatcher_action_CPPFLAGS = \ -I${top_srcdir} \ @@ -370,11 +454,29 @@ nm_dispatcher_action_CPPFLAGS = \ -DLIBEXECDIR=\"$(libexecdir)\" nm_dispatcher_action_LDADD = \ - $(top_builddir)/libnm-glib/libnm-glib.la \ $(top_builddir)/libnm-util/libnm-util.la \ $(DBUS_LIBS) \ $(GLIB_LIBS) + +########################################### +# dispatcher envp +########################################### +libtest_dispatcher_envp_la_SOURCES = \ + nm-dispatcher-utils.c \ + nm-dispatcher-utils.h + +libtest_dispatcher_envp_la_CPPFLAGS = \ + -I${top_srcdir}/include \ + -I${top_srcdir}/libnm-util \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) + +libtest_dispatcher_envp_la_LIBADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) + udevrulesdir = $(UDEV_BASE_DIR)/rules.d udevrules_DATA = 77-nm-olpc-mesh.rules dbusactivationdir = $(datadir)/dbus-1/system-services @@ -396,7 +498,7 @@ EXTRA_DIST = \ nm-dispatcher.xml all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am + $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj @@ -430,6 +532,17 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libtest-dispatcher-envp.la: $(libtest_dispatcher_envp_la_OBJECTS) $(libtest_dispatcher_envp_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libtest_dispatcher_envp_la_OBJECTS) $(libtest_dispatcher_envp_la_LIBADD) $(LIBS) install-libexecPROGRAMS: $(libexec_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(libexecdir)" || $(MKDIR_P) "$(DESTDIR)$(libexecdir)" @@ -489,9 +602,11 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_dispatcher_envp_la-nm-dispatcher-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm_avahi_autoipd_action-nm-avahi-autoipd-action.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm_dhcp_client_action-nm-dhcp-client-action.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm_dispatcher_action-nm-dispatcher-action.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm_dispatcher_action-nm-dispatcher-utils.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -520,6 +635,14 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +libtest_dispatcher_envp_la-nm-dispatcher-utils.lo: nm-dispatcher-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtest_dispatcher_envp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtest_dispatcher_envp_la-nm-dispatcher-utils.lo -MD -MP -MF $(DEPDIR)/libtest_dispatcher_envp_la-nm-dispatcher-utils.Tpo -c -o libtest_dispatcher_envp_la-nm-dispatcher-utils.lo `test -f 'nm-dispatcher-utils.c' || echo '$(srcdir)/'`nm-dispatcher-utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtest_dispatcher_envp_la-nm-dispatcher-utils.Tpo $(DEPDIR)/libtest_dispatcher_envp_la-nm-dispatcher-utils.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-dispatcher-utils.c' object='libtest_dispatcher_envp_la-nm-dispatcher-utils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtest_dispatcher_envp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtest_dispatcher_envp_la-nm-dispatcher-utils.lo `test -f 'nm-dispatcher-utils.c' || echo '$(srcdir)/'`nm-dispatcher-utils.c + nm_avahi_autoipd_action-nm-avahi-autoipd-action.o: nm-avahi-autoipd-action.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_avahi_autoipd_action_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm_avahi_autoipd_action-nm-avahi-autoipd-action.o -MD -MP -MF $(DEPDIR)/nm_avahi_autoipd_action-nm-avahi-autoipd-action.Tpo -c -o nm_avahi_autoipd_action-nm-avahi-autoipd-action.o `test -f 'nm-avahi-autoipd-action.c' || echo '$(srcdir)/'`nm-avahi-autoipd-action.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm_avahi_autoipd_action-nm-avahi-autoipd-action.Tpo $(DEPDIR)/nm_avahi_autoipd_action-nm-avahi-autoipd-action.Po @@ -568,6 +691,22 @@ nm_dispatcher_action-nm-dispatcher-action.obj: nm-dispatcher-action.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dispatcher_action_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm_dispatcher_action-nm-dispatcher-action.obj `if test -f 'nm-dispatcher-action.c'; then $(CYGPATH_W) 'nm-dispatcher-action.c'; else $(CYGPATH_W) '$(srcdir)/nm-dispatcher-action.c'; fi` +nm_dispatcher_action-nm-dispatcher-utils.o: nm-dispatcher-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dispatcher_action_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm_dispatcher_action-nm-dispatcher-utils.o -MD -MP -MF $(DEPDIR)/nm_dispatcher_action-nm-dispatcher-utils.Tpo -c -o nm_dispatcher_action-nm-dispatcher-utils.o `test -f 'nm-dispatcher-utils.c' || echo '$(srcdir)/'`nm-dispatcher-utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm_dispatcher_action-nm-dispatcher-utils.Tpo $(DEPDIR)/nm_dispatcher_action-nm-dispatcher-utils.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-dispatcher-utils.c' object='nm_dispatcher_action-nm-dispatcher-utils.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dispatcher_action_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm_dispatcher_action-nm-dispatcher-utils.o `test -f 'nm-dispatcher-utils.c' || echo '$(srcdir)/'`nm-dispatcher-utils.c + +nm_dispatcher_action-nm-dispatcher-utils.obj: nm-dispatcher-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dispatcher_action_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm_dispatcher_action-nm-dispatcher-utils.obj -MD -MP -MF $(DEPDIR)/nm_dispatcher_action-nm-dispatcher-utils.Tpo -c -o nm_dispatcher_action-nm-dispatcher-utils.obj `if test -f 'nm-dispatcher-utils.c'; then $(CYGPATH_W) 'nm-dispatcher-utils.c'; else $(CYGPATH_W) '$(srcdir)/nm-dispatcher-utils.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm_dispatcher_action-nm-dispatcher-utils.Tpo $(DEPDIR)/nm_dispatcher_action-nm-dispatcher-utils.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-dispatcher-utils.c' object='nm_dispatcher_action-nm-dispatcher-utils.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dispatcher_action_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm_dispatcher_action-nm-dispatcher-utils.obj `if test -f 'nm-dispatcher-utils.c'; then $(CYGPATH_W) 'nm-dispatcher-utils.c'; else $(CYGPATH_W) '$(srcdir)/nm-dispatcher-utils.c'; fi` + mostlyclean-libtool: -rm -f *.lo @@ -634,6 +773,76 @@ uninstall-udevrulesDATA: echo " ( cd '$(DESTDIR)$(udevrulesdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(udevrulesdir)" && rm -f $$files +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -644,10 +853,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) mkid -fID $$unique tags: TAGS -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ @@ -666,7 +888,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ fi; \ fi ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -716,24 +938,53 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done check-am: all-am check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am -all-am: Makefile $(PROGRAMS) $(DATA) -installdirs: + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) +installdirs: installdirs-recursive +installdirs-am: for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(dbusactivationdir)" "$(DESTDIR)$(dbusservicedir)" "$(DESTDIR)$(udevrulesdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ @@ -752,26 +1003,26 @@ maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-am +clean: clean-recursive clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ - mostlyclean-am + clean-noinstLTLIBRARIES mostlyclean-am -distclean: distclean-am +distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -html: html-am +html: html-recursive html-am: -info: info-am +info: info-recursive info-am: @@ -779,72 +1030,75 @@ install-data-am: install-dbusactivationDATA install-dbusserviceDATA \ install-udevrulesDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook -install-dvi: install-dvi-am +install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libexecPROGRAMS -install-html: install-html-am +install-html: install-html-recursive install-html-am: -install-info: install-info-am +install-info: install-info-recursive install-info-am: install-man: -install-pdf: install-pdf-am +install-pdf: install-pdf-recursive install-pdf-am: -install-ps: install-ps-am +install-ps: install-ps-recursive install-ps-am: installcheck-am: -maintainer-clean: maintainer-clean-am +maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool -pdf: pdf-am +pdf: pdf-recursive pdf-am: -ps: ps-am +ps: ps-recursive ps-am: uninstall-am: uninstall-dbusactivationDATA uninstall-dbusserviceDATA \ uninstall-libexecPROGRAMS uninstall-udevrulesDATA -.MAKE: all check install install-am install-data-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libexecPROGRAMS clean-libtool ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am \ - install-data-hook install-dbusactivationDATA \ - install-dbusserviceDATA install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-libexecPROGRAMS \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-strip install-udevrulesDATA installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-dbusactivationDATA \ - uninstall-dbusserviceDATA uninstall-libexecPROGRAMS \ - uninstall-udevrulesDATA +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ + ctags-recursive install install-am install-data-am \ + install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic \ + clean-libexecPROGRAMS clean-libtool clean-noinstLTLIBRARIES \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-data-hook \ + install-dbusactivationDATA install-dbusserviceDATA install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-libexecPROGRAMS install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip install-udevrulesDATA \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-dbusactivationDATA uninstall-dbusserviceDATA \ + uninstall-libexecPROGRAMS uninstall-udevrulesDATA nm-dispatcher-glue.h: nm-dispatcher.xml diff --git a/callouts/nm-dispatcher-action.c b/callouts/nm-dispatcher-action.c index 8040853f..54186a98 100644 --- a/callouts/nm-dispatcher-action.c +++ b/callouts/nm-dispatcher-action.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2008 Red Hat, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. */ #include <syslog.h> @@ -35,15 +35,9 @@ #include <dbus/dbus-glib-lowlevel.h> #include <dbus/dbus-glib.h> -#include <NetworkManager.h> -#include "nm-glib-compat.h" -#include <libnm-util/nm-connection.h> -#include <libnm-util/nm-setting-ip4-config.h> -#include <libnm-util/nm-setting-connection.h> -#include <libnm-glib/nm-dhcp4-config.h> -#include <libnm-glib/nm-device.h> #include "nm-dispatcher-action.h" +#include "nm-dispatcher-utils.h" #define NMD_SCRIPT_DIR SYSCONFDIR "/NetworkManager/dispatcher.d" @@ -84,11 +78,18 @@ typedef struct { } Dispatcher; static gboolean -nm_dispatcher_action (Handler *obj, +nm_dispatcher_action (Handler *h, const char *action, - GHashTable *connection, + GHashTable *connection_hash, GHashTable *connection_props, GHashTable *device_props, + GHashTable *device_ip4_props, + GHashTable *device_ip6_props, + GHashTable *device_dhcp4_props, + GHashTable *device_dhcp6_props, + const char *vpn_ip_iface, + GHashTable *vpn_ip4_props, + GHashTable *vpn_ip6_props, GError **error); #include "nm-dispatcher-glue.h" @@ -220,178 +221,13 @@ child_setup (gpointer user_data G_GNUC_UNUSED) setpgid (pid, pid); } -typedef struct { - char **envp; - guint32 i; -} EnvAddInfo; - static void -add_one_option_to_envp (gpointer key, gpointer value, gpointer user_data) -{ - EnvAddInfo *info = (EnvAddInfo *) user_data; - char *ucased; - - ucased = g_ascii_strup (key, -1); - info->envp[info->i++] = g_strdup_printf ("DHCP4_%s=%s", ucased, (char *) value); - g_free (ucased); -} - -static char ** -construct_envp (const char *uuid, NMIP4Config *ip4_config, NMDHCP4Config *dhcp4_config) -{ - guint32 env_size = 0; - char **envp; - guint32 envp_idx = 0; - GHashTable *options = NULL; - GSList *addresses, *routes, *iter; - GArray *nameservers; - GPtrArray *domains; - guint32 num, i; - GString *tmp; - - if (!ip4_config) - return g_new0 (char *, 1); - - addresses = (GSList *) nm_ip4_config_get_addresses (ip4_config); - nameservers = (GArray *) nm_ip4_config_get_nameservers (ip4_config); - domains = (GPtrArray *) nm_ip4_config_get_domains (ip4_config); - routes = (GSList *) nm_ip4_config_get_routes (ip4_config); - - env_size = g_slist_length (addresses) - + 1 /* addresses length */ - + 1 /* nameservers */ - + 1 /* domains */ - + 1 /* hostname */ - + g_slist_length (routes) - + 1 /* routes length */ - + 1 /* connection UUID */; - - if (dhcp4_config) { - options = nm_dhcp4_config_get_options (dhcp4_config); - env_size += g_hash_table_size (options); - } - - envp = g_new0 (char *, env_size + 1); - - if (uuid) - envp[envp_idx++] = g_strdup_printf ("CONNECTION_UUID=%s", uuid); - - /* IP4 config stuff */ - for (iter = addresses, num = 0; iter; iter = g_slist_next (iter)) { - NMIP4Address *addr = (NMIP4Address *) iter->data; - char str_addr[INET_ADDRSTRLEN + 1]; - char str_gw[INET_ADDRSTRLEN + 1]; - struct in_addr tmp_addr; - guint32 prefix = nm_ip4_address_get_prefix (addr); - - memset (str_addr, 0, sizeof (str_addr)); - tmp_addr.s_addr = nm_ip4_address_get_address (addr); - if (!inet_ntop (AF_INET, &tmp_addr, str_addr, sizeof (str_addr))) - continue; - - memset (str_gw, 0, sizeof (str_gw)); - tmp_addr.s_addr = nm_ip4_address_get_gateway (addr); - inet_ntop (AF_INET, &tmp_addr, str_gw, sizeof (str_gw)); - - tmp = g_string_sized_new (25 + strlen (str_addr) + strlen (str_gw)); - g_string_append_printf (tmp, "IP4_ADDRESS_%d=%s/%d %s", num++, str_addr, prefix, str_gw); - envp[envp_idx++] = tmp->str; - g_string_free (tmp, FALSE); - } - if (num) - envp[envp_idx++] = g_strdup_printf ("IP4_NUM_ADDRESSES=%d", num); - - if (nameservers && nameservers->len) { - gboolean first = TRUE; - - tmp = g_string_new ("IP4_NAMESERVERS="); - for (i = 0; i < nameservers->len; i++) { - struct in_addr addr; - char buf[INET_ADDRSTRLEN + 1]; - - addr.s_addr = g_array_index (nameservers, guint32, i); - memset (buf, 0, sizeof (buf)); - if (inet_ntop (AF_INET, &addr, buf, sizeof (buf))) { - if (!first) - g_string_append_c (tmp, ' '); - g_string_append (tmp, buf); - first = FALSE; - } - } - envp[envp_idx++] = tmp->str; - g_string_free (tmp, FALSE); - } - - if (domains && domains->len) { - tmp = g_string_new ("IP4_DOMAINS="); - for (i = 0; i < domains->len; i++) { - if (i > 0) - g_string_append_c (tmp, ' '); - g_string_append (tmp, (char *) g_ptr_array_index (domains, i)); - } - envp[envp_idx++] = tmp->str; - g_string_free (tmp, FALSE); - } - - for (iter = routes, num = 0; iter; iter = g_slist_next (iter)) { - NMIP4Route *route = (NMIP4Route *) iter->data; - char str_addr[INET_ADDRSTRLEN + 1]; - char str_nh[INET_ADDRSTRLEN + 1]; - struct in_addr tmp_addr; - guint32 prefix = nm_ip4_route_get_prefix (route); - guint32 metric = nm_ip4_route_get_metric (route); - - memset (str_addr, 0, sizeof (str_addr)); - tmp_addr.s_addr = nm_ip4_route_get_dest (route); - if (!inet_ntop (AF_INET, &tmp_addr, str_addr, sizeof (str_addr))) - continue; - - memset (str_nh, 0, sizeof (str_nh)); - tmp_addr.s_addr = nm_ip4_route_get_next_hop (route); - inet_ntop (AF_INET, &tmp_addr, str_nh, sizeof (str_nh)); - - tmp = g_string_sized_new (30 + strlen (str_addr) + strlen (str_nh)); - g_string_append_printf (tmp, "IP4_ROUTE_%d=%s/%d %s %d", num++, str_addr, prefix, str_nh, metric); - envp[envp_idx++] = tmp->str; - g_string_free (tmp, FALSE); - } - envp[envp_idx++] = g_strdup_printf ("IP4_NUM_ROUTES=%d", num); - - /* DHCP stuff */ - if (dhcp4_config && options) { - EnvAddInfo info; - - info.envp = envp; - info.i = envp_idx; - g_hash_table_foreach (options, add_one_option_to_envp, &info); - } - - if (debug) { - char **p; - - g_message ("------------ Script Environment ------------"); - for (p = envp; *p; p++) - g_message (" %s", *p); - g_message ("\n"); - } - - return envp; -} - -static void -dispatch_scripts (const char *action, - const char *iface, - const char *parent_iface, - NMDeviceType type, - const char *uuid, - NMIP4Config *ip4_config, - NMDHCP4Config *dhcp4_config) +dispatch_scripts (const char *action, const char *iface, char **envp) { GDir *dir; const char *filename; GSList *scripts = NULL, *iter; GError *error = NULL; - char **envp = NULL; if (!(dir = g_dir_open (NMD_SCRIPT_DIR, 0, &error))) { g_warning ("g_dir_open() could not open '" NMD_SCRIPT_DIR "'. '%s'", @@ -429,8 +265,6 @@ dispatch_scripts (const char *action, } g_dir_close (dir); - envp = construct_envp (uuid, ip4_config, dhcp4_config); - for (iter = scripts; iter; iter = g_slist_next (iter)) { gchar *argv[4]; gint status = -1; @@ -458,8 +292,6 @@ dispatch_scripts (const char *action, } } - g_strfreev (envp); - g_slist_foreach (scripts, (GFunc) g_free, NULL); g_slist_free (scripts); } @@ -470,18 +302,18 @@ nm_dispatcher_action (Handler *h, GHashTable *connection_hash, GHashTable *connection_props, GHashTable *device_props, + GHashTable *device_ip4_props, + GHashTable *device_ip6_props, + GHashTable *device_dhcp4_props, + GHashTable *device_dhcp6_props, + const char *vpn_ip_iface, + GHashTable *vpn_ip4_props, + GHashTable *vpn_ip6_props, GError **error) { Dispatcher *d = g_object_get_data (G_OBJECT (h), "dispatcher"); - NMConnection *connection; - char *iface = NULL, *parent_iface = NULL; - const char *uuid = NULL; - NMDeviceType type = NM_DEVICE_TYPE_UNKNOWN; - NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN; - NMDevice *device = NULL; - NMDHCP4Config *dhcp4_config = NULL; - NMIP4Config *ip4_config = NULL; - GValue *value; + char **envp, **p; + char *iface = NULL; /* Back off the quit timeout */ if (d->quit_timeout) @@ -489,83 +321,30 @@ nm_dispatcher_action (Handler *h, if (!d->persist) d->quit_timeout = g_timeout_add_seconds (10, quit_timeout_cb, NULL); - /* Hostname changes don't require a device nor contain a connection */ - if (!strcmp (action, "hostname")) - goto dispatch; - - connection = nm_connection_new_from_hash (connection_hash, error); - if (connection) { - NMSettingConnection *s_con; - - s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); - if (s_con) - uuid = nm_setting_connection_get_uuid (s_con); - } else { - g_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d", - __func__, - g_type_name (nm_connection_lookup_setting_type_by_quark ((*error)->domain)), - (*error)->message, (*error)->code); - /* Don't fail on this error yet */ - g_error_free (*error); - *error = NULL; - } - - /* interface name */ - value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_INTERFACE); - if (!value || !G_VALUE_HOLDS_STRING (value)) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_INTERFACE "!"); - goto out; - } - iface = (char *) g_value_get_string (value); - - /* IP interface name */ - value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_IP_INTERFACE); - if (value) { - if (!G_VALUE_HOLDS_STRING (value)) { - g_warning ("Invalid required value " NMD_DEVICE_PROPS_IP_INTERFACE "!"); - goto out; - } - parent_iface = iface; - iface = (char *) g_value_get_string (value); - } - - /* Device type */ - value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_TYPE); - if (!value || !G_VALUE_HOLDS_UINT (value)) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_TYPE "!"); - goto out; - } - type = g_value_get_uint (value); - - /* Device state */ - value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_STATE); - if (!value || !G_VALUE_HOLDS_UINT (value)) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_STATE "!"); - goto out; - } - dev_state = g_value_get_uint (value); - - /* device itself */ - value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_PATH); - if (!value || (G_VALUE_TYPE (value) != DBUS_TYPE_G_OBJECT_PATH)) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_PATH "!"); - goto out; - } - device = NM_DEVICE (nm_device_new (d->g_connection, (const char *) g_value_get_boxed (value))); + envp = nm_dispatcher_utils_construct_envp (action, + connection_hash, + connection_props, + device_props, + device_ip4_props, + device_ip6_props, + device_dhcp4_props, + device_dhcp6_props, + vpn_ip_iface, + vpn_ip4_props, + vpn_ip6_props, + &iface); - /* Get the DHCP4 config */ - if (device && (dev_state == NM_DEVICE_STATE_ACTIVATED)) { - dhcp4_config = nm_device_get_dhcp4_config (device); - ip4_config = nm_device_get_ip4_config (device); + if (debug) { + g_message ("------------ Script Environment ------------"); + for (p = envp; *p; p++) + g_message (" %s", *p); + g_message ("\n"); } -dispatch: - dispatch_scripts (action, iface, parent_iface, type, uuid, ip4_config, dhcp4_config); - - if (device) - g_object_unref (device); + dispatch_scripts (action, iface, envp); + g_strfreev (envp); + g_free (iface); -out: return TRUE; } diff --git a/callouts/nm-dispatcher-action.h b/callouts/nm-dispatcher-action.h index 39aefd8f..e4f2fab2 100644 --- a/callouts/nm-dispatcher-action.h +++ b/callouts/nm-dispatcher-action.h @@ -22,7 +22,6 @@ #define NM_DISPATCHER_DBUS_IFACE "org.freedesktop.nm_dispatcher" #define NM_DISPATCHER_DBUS_PATH "/org/freedesktop/nm_dispatcher" -#define NMD_CONNECTION_PROPS_SERVICE_NAME "service-name" #define NMD_CONNECTION_PROPS_PATH "path" #define NMD_DEVICE_PROPS_INTERFACE "interface" diff --git a/callouts/nm-dispatcher-utils.c b/callouts/nm-dispatcher-utils.c new file mode 100644 index 00000000..97ee1a4b --- /dev/null +++ b/callouts/nm-dispatcher-utils.c @@ -0,0 +1,509 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 - 2011 Red Hat, Inc. + */ + +#include <config.h> +#include <string.h> + +#include <glib-object.h> + +#include <NetworkManager.h> +#include <nm-dbus-glib-types.h> +#include <nm-connection.h> +#include <nm-setting-ip4-config.h> +#include <nm-setting-ip6-config.h> +#include <nm-setting-connection.h> + +#include "nm-dispatcher-action.h" +#include "nm-utils.h" + +#include "nm-dispatcher-utils.h" + +static GSList * +construct_basic_items (GSList *list, + const char *uuid, + const char *id, + const char *iface, + const char *ip_iface) +{ + if (uuid) + list = g_slist_prepend (list, g_strdup_printf ("CONNECTION_UUID=%s", uuid)); + if (id) + list = g_slist_prepend (list, g_strdup_printf ("CONNECTION_ID=%s", id)); + if (iface) + list = g_slist_prepend (list, g_strdup_printf ("DEVICE_IFACE=%s", iface)); + if (ip_iface) + list = g_slist_prepend (list, g_strdup_printf ("DEVICE_IP_IFACE=%s", ip_iface)); + return list; +} + +static GSList * +add_domains (GSList *items, + GHashTable *hash, + const char *prefix, + const char four_or_six) +{ + GValue *val; + GPtrArray *domains = NULL; + GString *tmp; + guint i; + + /* Search domains */ + val = g_hash_table_lookup (hash, "domains"); + if (!val || !G_VALUE_HOLDS (val, DBUS_TYPE_G_ARRAY_OF_STRING)) + return items; + + domains = (GPtrArray *) g_value_get_boxed (val); + if (!domains || (domains->len == 0)) + return items; + + tmp = g_string_new (NULL); + g_string_append_printf (tmp, "%sIP%c_DOMAINS=", prefix, four_or_six); + for (i = 0; i < domains->len; i++) { + if (i > 0) + g_string_append_c (tmp, ' '); + g_string_append (tmp, (char *) g_ptr_array_index (domains, i)); + } + items = g_slist_prepend (items, tmp->str); + g_string_free (tmp, FALSE); + + return items; +} + +static GSList * +construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix) +{ + GSList *addresses = NULL, *routes = NULL, *iter; + GArray *dns = NULL, *wins = NULL; + guint32 num, i; + GString *tmp; + GValue *val; + + if (ip4_config == NULL) + return items; + + if (prefix == NULL) + prefix = ""; + + /* IP addresses */ + val = g_hash_table_lookup (ip4_config, "addresses"); + if (val) + addresses = nm_utils_ip4_addresses_from_gvalue (val); + + for (iter = addresses, num = 0; iter; iter = g_slist_next (iter)) { + NMIP4Address *addr = (NMIP4Address *) iter->data; + char str_addr[INET_ADDRSTRLEN + 1]; + char str_gw[INET_ADDRSTRLEN + 1]; + struct in_addr tmp_addr; + guint32 ip_prefix = nm_ip4_address_get_prefix (addr); + char *addrtmp; + + memset (str_addr, 0, sizeof (str_addr)); + tmp_addr.s_addr = nm_ip4_address_get_address (addr); + if (!inet_ntop (AF_INET, &tmp_addr, str_addr, sizeof (str_addr))) + continue; + + memset (str_gw, 0, sizeof (str_gw)); + tmp_addr.s_addr = nm_ip4_address_get_gateway (addr); + inet_ntop (AF_INET, &tmp_addr, str_gw, sizeof (str_gw)); + + addrtmp = g_strdup_printf ("%sIP4_ADDRESS_%d=%s/%d %s", prefix, num++, str_addr, ip_prefix, str_gw); + items = g_slist_prepend (items, addrtmp); + } + if (num) + items = g_slist_prepend (items, g_strdup_printf ("%sIP4_NUM_ADDRESSES=%d", prefix, num)); + if (addresses) { + g_slist_foreach (addresses, (GFunc) nm_ip4_address_unref, NULL); + g_slist_free (addresses); + } + + /* DNS servers */ + val = g_hash_table_lookup (ip4_config, "nameservers"); + if (val && G_VALUE_HOLDS (val, DBUS_TYPE_G_UINT_ARRAY)) + dns = (GArray *) g_value_get_boxed (val); + + if (dns && (dns->len > 0)) { + gboolean first = TRUE; + + tmp = g_string_new (NULL); + g_string_append_printf (tmp, "%sIP4_NAMESERVERS=", prefix); + for (i = 0; i < dns->len; i++) { + struct in_addr addr; + char buf[INET_ADDRSTRLEN + 1]; + + addr.s_addr = g_array_index (dns, guint32, i); + memset (buf, 0, sizeof (buf)); + if (inet_ntop (AF_INET, &addr, buf, sizeof (buf))) { + if (!first) + g_string_append_c (tmp, ' '); + g_string_append (tmp, buf); + first = FALSE; + } + } + items = g_slist_prepend (items, tmp->str); + g_string_free (tmp, FALSE); + } + + /* Search domains */ + items = add_domains (items, ip4_config, prefix, '4'); + + /* WINS servers */ + val = g_hash_table_lookup (ip4_config, "wins-servers"); + if (val && G_VALUE_HOLDS (val, DBUS_TYPE_G_UINT_ARRAY)) + wins = (GArray *) g_value_get_boxed (val); + + if (wins && wins->len) { + gboolean first = TRUE; + + tmp = g_string_new (NULL); + g_string_append_printf (tmp, "%sIP4_WINS_SERVERS=", prefix); + for (i = 0; i < wins->len; i++) { + struct in_addr addr; + char buf[INET_ADDRSTRLEN + 1]; + + addr.s_addr = g_array_index (wins, guint32, i); + memset (buf, 0, sizeof (buf)); + if (inet_ntop (AF_INET, &addr, buf, sizeof (buf))) { + if (!first) + g_string_append_c (tmp, ' '); + g_string_append (tmp, buf); + first = FALSE; + } + } + items = g_slist_prepend (items, tmp->str); + g_string_free (tmp, FALSE); + } + + /* Static routes */ + val = g_hash_table_lookup (ip4_config, "routes"); + if (val) + routes = nm_utils_ip4_routes_from_gvalue (val); + + for (iter = routes, num = 0; iter; iter = g_slist_next (iter)) { + NMIP4Route *route = (NMIP4Route *) iter->data; + char str_addr[INET_ADDRSTRLEN + 1]; + char str_nh[INET_ADDRSTRLEN + 1]; + struct in_addr tmp_addr; + guint32 ip_prefix = nm_ip4_route_get_prefix (route); + guint32 metric = nm_ip4_route_get_metric (route); + char *routetmp; + + memset (str_addr, 0, sizeof (str_addr)); + tmp_addr.s_addr = nm_ip4_route_get_dest (route); + if (!inet_ntop (AF_INET, &tmp_addr, str_addr, sizeof (str_addr))) + continue; + + memset (str_nh, 0, sizeof (str_nh)); + tmp_addr.s_addr = nm_ip4_route_get_next_hop (route); + inet_ntop (AF_INET, &tmp_addr, str_nh, sizeof (str_nh)); + + routetmp = g_strdup_printf ("%sIP4_ROUTE_%d=%s/%d %s %d", prefix, num++, str_addr, ip_prefix, str_nh, metric); + items = g_slist_prepend (items, routetmp); + } + items = g_slist_prepend (items, g_strdup_printf ("%sIP4_NUM_ROUTES=%d", prefix, num)); + if (routes) { + g_slist_foreach (routes, (GFunc) nm_ip4_route_unref, NULL); + g_slist_free (routes); + } + + return items; +} + +static GSList * +construct_device_dhcp4_items (GSList *items, GHashTable *dhcp4_config) +{ + GHashTableIter iter; + const char *key, *tmp; + GValue *val; + char *ucased; + + if (dhcp4_config == NULL) + return items; + + g_hash_table_iter_init (&iter, dhcp4_config); + while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) { + ucased = g_ascii_strup (key, -1); + tmp = g_value_get_string (val); + items = g_slist_prepend (items, g_strdup_printf ("DHCP4_%s=%s", ucased, tmp)); + g_free (ucased); + } + return items; +} + +static GSList * +construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix) +{ + GSList *addresses = NULL, *routes = NULL, *dns = NULL, *iter; + guint32 num; + GString *tmp; + GValue *val; + + if (ip6_config == NULL) + return items; + + if (prefix == NULL) + prefix = ""; + + /* IP addresses */ + val = g_hash_table_lookup (ip6_config, "addresses"); + if (val) + addresses = nm_utils_ip6_addresses_from_gvalue (val); + + for (iter = addresses, num = 0; iter; iter = g_slist_next (iter)) { + NMIP6Address *addr = (NMIP6Address *) iter->data; + char str_addr[INET6_ADDRSTRLEN + 1]; + char str_gw[INET6_ADDRSTRLEN + 1]; + const struct in6_addr *tmp_addr; + guint32 ip_prefix = nm_ip6_address_get_prefix (addr); + char *addrtmp; + + memset (str_addr, 0, sizeof (str_addr)); + tmp_addr = nm_ip6_address_get_address (addr); + if (!inet_ntop (AF_INET6, &tmp_addr, str_addr, sizeof (str_addr))) + continue; + + memset (str_gw, 0, sizeof (str_gw)); + tmp_addr = nm_ip6_address_get_gateway (addr); + inet_ntop (AF_INET6, &tmp_addr, str_gw, sizeof (str_gw)); + + addrtmp = g_strdup_printf ("%sIP6_ADDRESS_%d=%s/%d %s", prefix, num++, str_addr, ip_prefix, str_gw); + items = g_slist_prepend (items, addrtmp); + } + if (num) + items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ADDRESSES=%d", prefix, num)); + if (addresses) { + g_slist_foreach (addresses, (GFunc) nm_ip6_address_unref, NULL); + g_slist_free (addresses); + } + + /* DNS servers */ + val = g_hash_table_lookup (ip6_config, "nameservers"); + if (val) + dns = nm_utils_ip6_dns_from_gvalue (val); + + if (g_slist_length (dns)) { + tmp = g_string_new (NULL); + g_string_append_printf (tmp, "%sIP6_NAMESERVERS=", prefix); + + for (iter = dns; iter; iter = g_slist_next (iter)) { + const struct in6_addr *addr = iter->data; + gboolean first = TRUE; + char buf[INET6_ADDRSTRLEN + 1]; + + memset (buf, 0, sizeof (buf)); + if (inet_ntop (AF_INET6, addr, buf, sizeof (buf))) { + if (!first) + g_string_append_c (tmp, ' '); + g_string_append (tmp, buf); + first = FALSE; + } + } + + items = g_slist_prepend (items, tmp->str); + g_string_free (tmp, FALSE); + } + + /* Search domains */ + items = add_domains (items, ip6_config, prefix, '6'); + + /* Static routes */ + val = g_hash_table_lookup (ip6_config, "routes"); + if (val) + routes = nm_utils_ip6_routes_from_gvalue (val); + + for (iter = routes, num = 0; iter; iter = g_slist_next (iter)) { + NMIP6Route *route = (NMIP6Route *) iter->data; + char str_addr[INET6_ADDRSTRLEN + 1]; + char str_nh[INET6_ADDRSTRLEN + 1]; + const struct in6_addr *tmp_addr; + guint32 ip_prefix = nm_ip6_route_get_prefix (route); + guint32 metric = nm_ip6_route_get_metric (route); + char *routetmp; + + memset (str_addr, 0, sizeof (str_addr)); + tmp_addr = nm_ip6_route_get_dest (route); + if (!inet_ntop (AF_INET6, &tmp_addr, str_addr, sizeof (str_addr))) + continue; + + memset (str_nh, 0, sizeof (str_nh)); + tmp_addr = nm_ip6_route_get_next_hop (route); + inet_ntop (AF_INET6, &tmp_addr, str_nh, sizeof (str_nh)); + + routetmp = g_strdup_printf ("%sIP6_ROUTE_%d=%s/%d %s %d", prefix, num++, str_addr, ip_prefix, str_nh, metric); + items = g_slist_prepend (items, routetmp); + } + if (num) + items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ROUTES=%d", prefix, num)); + if (routes) { + g_slist_foreach (routes, (GFunc) nm_ip6_route_unref, NULL); + g_slist_free (routes); + } + + return items; +} + +static GSList * +construct_device_dhcp6_items (GSList *items, GHashTable *dhcp6_config) +{ + GHashTableIter iter; + const char *key, *tmp; + GValue *val; + char *ucased; + + if (dhcp6_config == NULL) + return items; + + g_hash_table_iter_init (&iter, dhcp6_config); + while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) { + ucased = g_ascii_strup (key, -1); + tmp = g_value_get_string (val); + items = g_slist_prepend (items, g_strdup_printf ("DHCP6_%s=%s", ucased, tmp)); + g_free (ucased); + } + return items; +} + +char ** +nm_dispatcher_utils_construct_envp (const char *action, + GHashTable *connection_hash, + GHashTable *connection_props, + GHashTable *device_props, + GHashTable *device_ip4_props, + GHashTable *device_ip6_props, + GHashTable *device_dhcp4_props, + GHashTable *device_dhcp6_props, + const char *vpn_ip_iface, + GHashTable *vpn_ip4_props, + GHashTable *vpn_ip6_props, + char **out_iface) +{ + const char *iface = NULL, *ip_iface = NULL; + const char *uuid = NULL, *id = NULL; + NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN; + GValue *value; + char **envp = NULL; + GSList *items = NULL, *iter; + guint i; + GHashTable *con_setting_hash; + + g_return_val_if_fail (action != NULL, NULL); + g_return_val_if_fail (out_iface != NULL, NULL); + g_return_val_if_fail (*out_iface == NULL, NULL); + + /* Hostname changes don't require a device nor contain a connection */ + if (!strcmp (action, "hostname")) + return g_new0 (char *, 1); + + con_setting_hash = g_hash_table_lookup (connection_hash, NM_SETTING_CONNECTION_SETTING_NAME); + if (!con_setting_hash) { + g_warning ("Failed to read connection setting"); + return NULL; + } + + value = g_hash_table_lookup (con_setting_hash, NM_SETTING_CONNECTION_UUID); + if (!value || !G_VALUE_HOLDS (value, G_TYPE_STRING)) { + g_warning ("Connection hash did not contain the UUID"); + return NULL; + } + uuid = g_value_get_string (value); + + value = g_hash_table_lookup (con_setting_hash, NM_SETTING_CONNECTION_ID); + if (!value || !G_VALUE_HOLDS (value, G_TYPE_STRING)) { + g_warning ("Connection hash did not contain the ID"); + return NULL; + } + id = g_value_get_string (value); + + /* interface name */ + value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_INTERFACE); + if (!value || !G_VALUE_HOLDS_STRING (value)) { + g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_INTERFACE "!"); + return NULL; + } + iface = g_value_get_string (value); + + /* IP interface name */ + value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_IP_INTERFACE); + if (value) { + if (!G_VALUE_HOLDS_STRING (value)) { + g_warning ("Invalid required value " NMD_DEVICE_PROPS_IP_INTERFACE "!"); + return NULL; + } + ip_iface = g_value_get_string (value); + } + + /* Device type */ + value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_TYPE); + if (!value || !G_VALUE_HOLDS_UINT (value)) { + g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_TYPE "!"); + return NULL; + } + + /* Device state */ + value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_STATE); + if (!value || !G_VALUE_HOLDS_UINT (value)) { + g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_STATE "!"); + return NULL; + } + dev_state = g_value_get_uint (value); + + /* device itself */ + value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_PATH); + if (!value || (G_VALUE_TYPE (value) != DBUS_TYPE_G_OBJECT_PATH)) { + g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_PATH "!"); + return NULL; + } + + items = construct_basic_items (items, uuid, id, iface, ip_iface); + + /* Device it's aren't valid if the device isn't activated */ + if (iface && (dev_state == NM_DEVICE_STATE_ACTIVATED)) { + items = construct_ip4_items (items, device_ip4_props, NULL); + items = construct_ip6_items (items, device_ip6_props, NULL); + items = construct_device_dhcp4_items (items, device_dhcp4_props); + items = construct_device_dhcp6_items (items, device_dhcp6_props); + } + + if (vpn_ip_iface) { + items = g_slist_prepend (items, g_strdup_printf ("VPN_IP_IFACE=%s", vpn_ip_iface)); + items = construct_ip4_items (items, vpn_ip4_props, "VPN_"); + items = construct_ip6_items (items, vpn_ip6_props, "VPN_"); + } + + /* Convert the list to an environment pointer */ + envp = g_new0 (char *, g_slist_length (items) + 1); + for (iter = items, i = 0; iter; iter = g_slist_next (iter), i++) + envp[i] = (char *) iter->data; + g_slist_free (items); + + /* Backwards compat: 'iface' is set in this order: + * 1) VPN interface name + * 2) Device IP interface name + * 3) Device interface anme + */ + if (vpn_ip_iface) + *out_iface = g_strdup (vpn_ip_iface); + else if (ip_iface) + *out_iface = g_strdup (ip_iface); + else + *out_iface = g_strdup (iface); + + return envp; +} + diff --git a/callouts/nm-dispatcher-utils.h b/callouts/nm-dispatcher-utils.h new file mode 100644 index 00000000..33202e0e --- /dev/null +++ b/callouts/nm-dispatcher-utils.h @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 - 2011 Red Hat, Inc. + */ + +#ifndef NM_DISPATCHER_UTILS_H +#define NM_DISPATCHER_UTILS_H + +#include <glib.h> + +char ** +nm_dispatcher_utils_construct_envp (const char *action, + GHashTable *connection_hash, + GHashTable *connection_props, + GHashTable *device_props, + GHashTable *device_ip4_props, + GHashTable *device_ip6_props, + GHashTable *device_dhcp4_props, + GHashTable *device_dhcp6_props, + const char *vpn_ip_iface, + GHashTable *vpn_ip4_props, + GHashTable *vpn_ip6_props, + char **out_iface); + +#endif /* NM_DISPATCHER_UTILS_H */ + diff --git a/callouts/nm-dispatcher.xml b/callouts/nm-dispatcher.xml index 532ae9f3..92780b17 100644 --- a/callouts/nm-dispatcher.xml +++ b/callouts/nm-dispatcher.xml @@ -32,6 +32,46 @@ </tp:docstring> </arg> + <arg name="device_ip4_config" type="a{sv}" direction="in"> + <tp:docstring> + Properties of the device's IPv4 configuration. + </tp:docstring> + </arg> + + <arg name="device_ip6_config" type="a{sv}" direction="in"> + <tp:docstring> + Properties of the device's IPv6 configuration. + </tp:docstring> + </arg> + + <arg name="device_dhcp4_config" type="a{sv}" direction="in"> + <tp:docstring> + Properties of the device's DHCPv4 configuration. + </tp:docstring> + </arg> + + <arg name="device_dhcp6_config" type="a{sv}" direction="in"> + <tp:docstring> + Properties of the device's DHCPv6 configuration. + </tp:docstring> + </arg> + + <arg name="vpn_ip_iface" type="s" direction="in"> + <tp:docstring>VPN interface name.</tp:docstring> + </arg> + + <arg name="vpn_ip4_config" type="a{sv}" direction="in"> + <tp:docstring> + Properties of the VPN's IPv4 configuration. + </tp:docstring> + </arg> + + <arg name="vpn_ip6_config" type="a{sv}" direction="in"> + <tp:docstring> + Properties of the VPN's IPv6 configuration. + </tp:docstring> + </arg> + </method> </interface> </node> diff --git a/callouts/tests/Makefile.am b/callouts/tests/Makefile.am new file mode 100644 index 00000000..6a46b629 --- /dev/null +++ b/callouts/tests/Makefile.am @@ -0,0 +1,38 @@ +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/libnm-util \ + -I$(top_srcdir)/callouts + +noinst_PROGRAMS = \ + test-dispatcher-envp + +####### dispatcher envp ####### + +test_dispatcher_envp_SOURCES = \ + test-dispatcher-envp.c + +test_dispatcher_envp_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) + +test_dispatcher_envp_LDADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/callouts/libtest-dispatcher-envp.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) + +########################################### + +if WITH_TESTS + +check-local: test-dispatcher-envp + $(abs_builddir)/test-dispatcher-envp $(abs_srcdir) + +endif + +EXTRA_DIST= \ + dispatcher-old-down \ + dispatcher-old-up \ + dispatcher-old-vpn-down \ + dispatcher-old-vpn-up + diff --git a/callouts/tests/Makefile.in b/callouts/tests/Makefile.in new file mode 100644 index 00000000..4c8fa909 --- /dev/null +++ b/callouts/tests/Makefile.in @@ -0,0 +1,645 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = test-dispatcher-envp$(EXEEXT) +subdir = callouts/tests +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)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_test_dispatcher_envp_OBJECTS = \ + test_dispatcher_envp-test-dispatcher-envp.$(OBJEXT) +test_dispatcher_envp_OBJECTS = $(am_test_dispatcher_envp_OBJECTS) +am__DEPENDENCIES_1 = +test_dispatcher_envp_DEPENDENCIES = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/callouts/libtest-dispatcher-envp.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(test_dispatcher_envp_SOURCES) +DIST_SOURCES = $(test_dispatcher_envp_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +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@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +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@ +GMODULE_CFLAGS = @GMODULE_CFLAGS@ +GMODULE_LIBS = @GMODULE_LIBS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ +GNUTLS_LIBS = @GNUTLS_LIBS@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +IPTABLES_PATH = @IPTABLES_PATH@ +IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ +IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ +KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDL = @LIBDL@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_LIBS = @LIBNL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ +NM_MICRO_VERSION = @NM_MICRO_VERSION@ +NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_VERSION = @NM_VERSION@ +NSS_CFLAGS = @NSS_CFLAGS@ +NSS_LIBS = @NSS_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_PATH = @PKGCONFIG_PATH@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +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@ +SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +UUID_CFLAGS = @UUID_CFLAGS@ +UUID_LIBS = @UUID_LIBS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/libnm-util \ + -I$(top_srcdir)/callouts + + +####### dispatcher envp ####### +test_dispatcher_envp_SOURCES = \ + test-dispatcher-envp.c + +test_dispatcher_envp_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) + +test_dispatcher_envp_LDADD = \ + $(top_builddir)/libnm-util/libnm-util.la \ + $(top_builddir)/callouts/libtest-dispatcher-envp.la \ + $(GLIB_LIBS) \ + $(DBUS_LIBS) + +EXTRA_DIST = \ + dispatcher-old-down \ + dispatcher-old-up \ + dispatcher-old-vpn-down \ + dispatcher-old-vpn-up + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu callouts/tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu callouts/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +test-dispatcher-envp$(EXEEXT): $(test_dispatcher_envp_OBJECTS) $(test_dispatcher_envp_DEPENDENCIES) + @rm -f test-dispatcher-envp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dispatcher_envp_OBJECTS) $(test_dispatcher_envp_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dispatcher_envp-test-dispatcher-envp.Po@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_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ $< + +.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_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ `$(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_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +test_dispatcher_envp-test-dispatcher-envp.o: test-dispatcher-envp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dispatcher_envp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dispatcher_envp-test-dispatcher-envp.o -MD -MP -MF $(DEPDIR)/test_dispatcher_envp-test-dispatcher-envp.Tpo -c -o test_dispatcher_envp-test-dispatcher-envp.o `test -f 'test-dispatcher-envp.c' || echo '$(srcdir)/'`test-dispatcher-envp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_dispatcher_envp-test-dispatcher-envp.Tpo $(DEPDIR)/test_dispatcher_envp-test-dispatcher-envp.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-dispatcher-envp.c' object='test_dispatcher_envp-test-dispatcher-envp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dispatcher_envp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_dispatcher_envp-test-dispatcher-envp.o `test -f 'test-dispatcher-envp.c' || echo '$(srcdir)/'`test-dispatcher-envp.c + +test_dispatcher_envp-test-dispatcher-envp.obj: test-dispatcher-envp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dispatcher_envp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dispatcher_envp-test-dispatcher-envp.obj -MD -MP -MF $(DEPDIR)/test_dispatcher_envp-test-dispatcher-envp.Tpo -c -o test_dispatcher_envp-test-dispatcher-envp.obj `if test -f 'test-dispatcher-envp.c'; then $(CYGPATH_W) 'test-dispatcher-envp.c'; else $(CYGPATH_W) '$(srcdir)/test-dispatcher-envp.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_dispatcher_envp-test-dispatcher-envp.Tpo $(DEPDIR)/test_dispatcher_envp-test-dispatcher-envp.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-dispatcher-envp.c' object='test_dispatcher_envp-test-dispatcher-envp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dispatcher_envp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_dispatcher_envp-test-dispatcher-envp.obj `if test -f 'test-dispatcher-envp.c'; then $(CYGPATH_W) 'test-dispatcher-envp.c'; else $(CYGPATH_W) '$(srcdir)/test-dispatcher-envp.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +@WITH_TESTS_FALSE@check-local: +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \ + clean-generic clean-libtool clean-noinstPROGRAMS ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + + +########################################### + +@WITH_TESTS_TRUE@check-local: test-dispatcher-envp +@WITH_TESTS_TRUE@ $(abs_builddir)/test-dispatcher-envp $(abs_srcdir) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/callouts/tests/dispatcher-old-down b/callouts/tests/dispatcher-old-down new file mode 100644 index 00000000..4210921d --- /dev/null +++ b/callouts/tests/dispatcher-old-down @@ -0,0 +1,19 @@ +[main] +action=down +iface=wlan0 +uuid=3fd2a33a-d81b-423f-ae99-e6baba742311 +id=Random Connection + +[device] +state=30 +ip-interface=wlan0 +type=2 +interface=wlan0 +path=/org/freedesktop/NetworkManager/Devices/0 + +[env] +CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311 +CONNECTION_ID=Random Connection +DEVICE_IFACE=wlan0 +DEVICE_IP_IFACE=wlan0 + diff --git a/callouts/tests/dispatcher-old-up b/callouts/tests/dispatcher-old-up new file mode 100644 index 00000000..ed15fef5 --- /dev/null +++ b/callouts/tests/dispatcher-old-up @@ -0,0 +1,55 @@ +[main] +action=up +iface=wlan0 +uuid=3fd2a33a-d81b-423f-ae99-e6baba742311 +id=Random Connection + +[device] +state=100 +ip-interface=wlan0 +type=2 +interface=wlan0 +path=/org/freedesktop/NetworkManager/Devices/0 + +[dhcp4] +netbios_name_servers=0.0.0.0 +domain_name_servers=68.87.77.134 68.87.72.134 192.168.1.1 +dhcp_lease_time=86400 +network_number=192.168.1.0 +domain_name=hsd1.mn.comcast.net. +ip_address=192.168.1.119 +dhcp_message_type=5 +dhcp_server_identifier=192.168.1.1 +routers=192.168.1.1 +broadcast_address=192.168.1.255 +subnet_mask=255.255.255.0 +expiry=1304300446 + +[ip4] +addresses=192.168.1.119/24 192.168.1.1 +nameservers=68.87.77.134 68.87.72.134 192.168.1.1 +domains=hsd1.mn.comcast.net. + +[env] +CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311 +CONNECTION_ID=Random Connection +DEVICE_IFACE=wlan0 +DEVICE_IP_IFACE=wlan0 +IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1 +IP4_NUM_ADDRESSES=1 +IP4_NAMESERVERS=68.87.77.134 68.87.72.134 192.168.1.1 +IP4_DOMAINS=hsd1.mn.comcast.net. +IP4_NUM_ROUTES=0 +DHCP4_NETBIOS_NAME_SERVERS=0.0.0.0 +DHCP4_DOMAIN_NAME_SERVERS=68.87.77.134 68.87.72.134 192.168.1.1 +DHCP4_DHCP_LEASE_TIME=86400 +DHCP4_NETWORK_NUMBER=192.168.1.0 +DHCP4_DOMAIN_NAME=hsd1.mn.comcast.net. +DHCP4_IP_ADDRESS=192.168.1.119 +DHCP4_DHCP_MESSAGE_TYPE=5 +DHCP4_DHCP_SERVER_IDENTIFIER=192.168.1.1 +DHCP4_ROUTERS=192.168.1.1 +DHCP4_BROADCAST_ADDRESS=192.168.1.255 +DHCP4_SUBNET_MASK=255.255.255.0 +DHCP4_EXPIRY=1304300446 + diff --git a/callouts/tests/dispatcher-old-vpn-down b/callouts/tests/dispatcher-old-vpn-down new file mode 100644 index 00000000..b45d8ea8 --- /dev/null +++ b/callouts/tests/dispatcher-old-vpn-down @@ -0,0 +1,54 @@ +[main] +action=vpn-down +iface=tun0 +uuid=355653c0-34d3-4777-ad25-f9a498b7ef8e +id=Random Connection + +[device] +state=100 +ip-interface=tun0 +type=2 +interface=wlan0 +path=/org/freedesktop/NetworkManager/Devices/0 + +[dhcp4] +netbios_name_servers=0.0.0.0 +domain_name_servers=68.87.77.134 68.87.72.134 192.168.1.1 +dhcp_lease_time=86400 +network_number=192.168.1.0 +domain_name=hsd1.mn.comcast.net. +ip_address=192.168.1.119 +dhcp_message_type=5 +dhcp_server_identifier=192.168.1.1 +routers=192.168.1.1 +broadcast_address=192.168.1.255 +subnet_mask=255.255.255.0 +expiry=1304349405 + +[ip4] +addresses=192.168.1.119/24 192.168.1.1 +nameservers=68.87.77.134 68.87.72.134 192.168.1.1 +domains=hsd1.mn.comcast.net. + +[env] +CONNECTION_UUID=355653c0-34d3-4777-ad25-f9a498b7ef8e +CONNECTION_ID=Random Connection +DEVICE_IFACE=wlan0 +DEVICE_IP_IFACE=tun0 +IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1 +IP4_NUM_ADDRESSES=1 +IP4_NAMESERVERS=68.87.77.134 68.87.72.134 192.168.1.1 +IP4_DOMAINS=hsd1.mn.comcast.net. +IP4_NUM_ROUTES=0 +DHCP4_NETBIOS_NAME_SERVERS=0.0.0.0 +DHCP4_DOMAIN_NAME_SERVERS=68.87.77.134 68.87.72.134 192.168.1.1 +DHCP4_DHCP_LEASE_TIME=86400 +DHCP4_NETWORK_NUMBER=192.168.1.0 +DHCP4_DOMAIN_NAME=hsd1.mn.comcast.net. +DHCP4_IP_ADDRESS=192.168.1.119 +DHCP4_DHCP_MESSAGE_TYPE=5 +DHCP4_DHCP_SERVER_IDENTIFIER=192.168.1.1 +DHCP4_ROUTERS=192.168.1.1 +DHCP4_BROADCAST_ADDRESS=192.168.1.255 +DHCP4_SUBNET_MASK=255.255.255.0 +DHCP4_EXPIRY=1304349405 diff --git a/callouts/tests/dispatcher-old-vpn-up b/callouts/tests/dispatcher-old-vpn-up new file mode 100644 index 00000000..f3b502de --- /dev/null +++ b/callouts/tests/dispatcher-old-vpn-up @@ -0,0 +1,54 @@ +[main] +action=vpn-up +iface=tun0 +uuid=355653c0-34d3-4777-ad25-f9a498b7ef8e +id=Random Connection + +[device] +state=100 +ip-interface=tun0 +type=2 +interface=wlan0 +path=/org/freedesktop/NetworkManager/Devices/0 + +[dhcp4] +netbios_name_servers=0.0.0.0 +domain_name_servers=68.87.77.134 68.87.72.134 192.168.1.1 +dhcp_lease_time=86400 +network_number=192.168.1.0 +domain_name=hsd1.mn.comcast.net. +ip_address=192.168.1.119 +dhcp_message_type=5 +dhcp_server_identifier=192.168.1.1 +routers=192.168.1.1 +broadcast_address=192.168.1.255 +subnet_mask=255.255.255.0 +expiry=1304349405 + +[ip4] +addresses=192.168.1.119/24 192.168.1.1 +nameservers=68.87.77.134 68.87.72.134 192.168.1.1 +domains=hsd1.mn.comcast.net. + +[env] +CONNECTION_UUID=355653c0-34d3-4777-ad25-f9a498b7ef8e +CONNECTION_ID=Random Connection +DEVICE_IFACE=wlan0 +DEVICE_IP_IFACE=tun0 +IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1 +IP4_NUM_ADDRESSES=1 +IP4_NAMESERVERS=68.87.77.134 68.87.72.134 192.168.1.1 +IP4_DOMAINS=hsd1.mn.comcast.net. +IP4_NUM_ROUTES=0 +DHCP4_NETBIOS_NAME_SERVERS=0.0.0.0 +DHCP4_DOMAIN_NAME_SERVERS=68.87.77.134 68.87.72.134 192.168.1.1 +DHCP4_DHCP_LEASE_TIME=86400 +DHCP4_NETWORK_NUMBER=192.168.1.0 +DHCP4_DOMAIN_NAME=hsd1.mn.comcast.net. +DHCP4_IP_ADDRESS=192.168.1.119 +DHCP4_DHCP_MESSAGE_TYPE=5 +DHCP4_DHCP_SERVER_IDENTIFIER=192.168.1.1 +DHCP4_ROUTERS=192.168.1.1 +DHCP4_BROADCAST_ADDRESS=192.168.1.255 +DHCP4_SUBNET_MASK=255.255.255.0 +DHCP4_EXPIRY=1304349405 diff --git a/callouts/tests/test-dispatcher-envp.c b/callouts/tests/test-dispatcher-envp.c new file mode 100644 index 00000000..b4dbd784 --- /dev/null +++ b/callouts/tests/test-dispatcher-envp.c @@ -0,0 +1,615 @@ +/* -*- 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) 2011 Red Hat, Inc. + * + */ + +#include <config.h> +#include <arpa/inet.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <glib.h> +#include <glib-object.h> + +#include "nm-connection.h" +#include "nm-setting-connection.h" +#include "nm-dispatcher-utils.h" +#include "nm-dbus-glib-types.h" +#include "nm-dispatcher-action.h" +#include "nm-utils.h" + +/*******************************************/ + +static void +value_destroy (gpointer data) +{ + GValue *value = (GValue *) data; + + g_value_unset (value); + g_slice_free (GValue, value); +} + +static GHashTable * +value_hash_create (void) +{ + return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, value_destroy); +} + +static void +value_hash_add (GHashTable *hash, + const char *key, + GValue *value) +{ + g_hash_table_insert (hash, g_strdup (key), value); +} + +static void +value_hash_add_string (GHashTable *hash, + const char *key, + const char *str) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, G_TYPE_STRING); + g_value_set_string (value, str); + + value_hash_add (hash, key, value); +} + +static void +value_hash_add_object_path (GHashTable *hash, + const char *key, + const char *op) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, DBUS_TYPE_G_OBJECT_PATH); + g_value_set_boxed (value, op); + + value_hash_add (hash, key, value); +} + +static void +value_hash_add_uint (GHashTable *hash, + const char *key, + guint32 val) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, G_TYPE_UINT); + g_value_set_uint (value, val); + + value_hash_add (hash, key, value); +} + +static void +value_hash_add_strv (GHashTable *hash, + const char *key, + GPtrArray *array) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, DBUS_TYPE_G_ARRAY_OF_STRING); + g_value_take_boxed (value, array); + value_hash_add (hash, key, value); +} + +static void +value_hash_add_uint_array (GHashTable *hash, + const char *key, + GArray *array) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, DBUS_TYPE_G_UINT_ARRAY); + g_value_take_boxed (value, array); + value_hash_add (hash, key, value); +} + +static gboolean +parse_main (GKeyFile *kf, + GHashTable **out_con_hash, + GHashTable **out_con_props, + char **out_iface, + char **out_action, + GError **error) +{ + char *uuid, *id; + NMConnection *connection; + NMSettingConnection *s_con; + + *out_iface = g_key_file_get_string (kf, "main", "iface", error); + if (*out_iface == NULL) + return FALSE; + + *out_action = g_key_file_get_string (kf, "main", "action", error); + if (*out_action == NULL) + return FALSE; + + uuid = g_key_file_get_string (kf, "main", "uuid", error); + if (uuid == NULL) + return FALSE; + id = g_key_file_get_string (kf, "main", "id", error); + if (id == NULL) + return FALSE; + + connection = nm_connection_new (); + g_assert (connection); + s_con = (NMSettingConnection *) nm_setting_connection_new (); + g_assert (s_con); + g_object_set (s_con, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_ID, id, + NULL); + g_free (uuid); + g_free (id); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + *out_con_hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL); + g_object_unref (connection); + + *out_con_props = value_hash_create (); + value_hash_add_object_path (*out_con_props, "connection-path", "/org/freedesktop/NetworkManager/Connections/5"); + + return TRUE; +} + +static gboolean +parse_device (GKeyFile *kf, GHashTable **out_device_props, GError **error) +{ + char *tmp; + gint i; + + *out_device_props = value_hash_create (); + + i = g_key_file_get_integer (kf, "device", "state", error); + if (i == 0) + return FALSE; + value_hash_add_uint (*out_device_props, NMD_DEVICE_PROPS_STATE, (guint) i); + + i = g_key_file_get_integer (kf, "device", "type", error); + if (i == 0) + return FALSE; + value_hash_add_uint (*out_device_props, NMD_DEVICE_PROPS_TYPE, (guint) i); + + tmp = g_key_file_get_string (kf, "device", "interface", error); + if (tmp == NULL) + return FALSE; + value_hash_add_string (*out_device_props, NMD_DEVICE_PROPS_INTERFACE, tmp); + g_free (tmp); + + tmp = g_key_file_get_string (kf, "device", "ip-interface", error); + if (tmp == NULL) + return FALSE; + value_hash_add_string (*out_device_props, NMD_DEVICE_PROPS_IP_INTERFACE, tmp); + g_free (tmp); + + tmp = g_key_file_get_string (kf, "device", "path", error); + if (tmp == NULL) + return FALSE; + value_hash_add_object_path (*out_device_props, NMD_DEVICE_PROPS_PATH, tmp); + g_free (tmp); + + return TRUE; +} + +static gboolean +add_uint_array (GKeyFile *kf, + GHashTable *props, + const char *section, + const char *key, + GError **error) +{ + char *tmp; + char **split, **iter; + GArray *items; + + tmp = g_key_file_get_string (kf, section, key, error); + if (tmp == NULL) { + g_clear_error (error); + return TRUE; + } + split = g_strsplit_set (tmp, " ", -1); + g_free (tmp); + + if (g_strv_length (split) > 0) { + items = g_array_sized_new (FALSE, TRUE, sizeof (guint32), g_strv_length (split)); + for (iter = split; iter && *iter; iter++) { + if (strlen (g_strstrip (*iter))) { + struct in_addr addr; + + g_assert_cmpint (inet_pton (AF_INET, *iter, &addr), ==, 1); + g_array_append_val (items, addr.s_addr); + } + } + value_hash_add_uint_array (props, key, items); + } + g_strfreev (split); + return TRUE; +} + +static gboolean +parse_ip4 (GKeyFile *kf, GHashTable **out_props, const char *section, GError **error) +{ + char *tmp; + char **split, **iter; + GPtrArray *domains; + GSList *list; + GValue *val; + + *out_props = value_hash_create (); + + /* search domains */ + tmp = g_key_file_get_string (kf, section, "domains", error); + if (tmp == NULL) + return FALSE; + split = g_strsplit_set (tmp, " ", -1); + g_free (tmp); + + if (g_strv_length (split) > 0) { + domains = g_ptr_array_sized_new (g_strv_length (split)); + for (iter = split; iter && *iter; iter++) { + if (strlen (g_strstrip (*iter))) + g_ptr_array_add (domains, g_strdup (*iter)); + } + value_hash_add_strv (*out_props, "domains", domains); + } + g_strfreev (split); + + /* nameservers */ + if (!add_uint_array (kf, *out_props, "ip4", "nameservers", error)) + return FALSE; + /* wins-servers */ + if (!add_uint_array (kf, *out_props, "ip4", "wins-servers", error)) + return FALSE; + + /* Addresses */ + tmp = g_key_file_get_string (kf, section, "addresses", error); + if (tmp == NULL) + return FALSE; + split = g_strsplit_set (tmp, ",", -1); + g_free (tmp); + + if (g_strv_length (split) > 0) { + list = NULL; + for (iter = split; iter && *iter; iter++) { + NMIP4Address *addr; + struct in_addr a; + char *p; + + if (strlen (g_strstrip (*iter)) == 0) + continue; + + addr = nm_ip4_address_new (); + + p = strchr (*iter, '/'); + g_assert (p); + *p++ = '\0'; + + g_assert_cmpint (inet_pton (AF_INET, *iter, &a), ==, 1); + nm_ip4_address_set_address (addr, a.s_addr); + nm_ip4_address_set_prefix (addr, (guint) atoi (p)); + + p = strchr (p, ' '); + g_assert (p); + p++; + + g_assert_cmpint (inet_pton (AF_INET, p, &a), ==, 1); + nm_ip4_address_set_gateway (addr, a.s_addr); + + list = g_slist_append (list, addr); + } + + val = g_slice_new0 (GValue); + g_value_init (val, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT); + nm_utils_ip4_addresses_to_gvalue (list, val); + value_hash_add (*out_props, "addresses", val); + } + g_strfreev (split); + + /* Routes */ + tmp = g_key_file_get_string (kf, section, "routes", error); + g_clear_error (error); + if (tmp) { + split = g_strsplit_set (tmp, ",", -1); + g_free (tmp); + + if (g_strv_length (split) > 0) { + list = NULL; + for (iter = split; iter && *iter; iter++) { + NMIP4Route *route; + struct in_addr a; + char *p; + + if (strlen (g_strstrip (*iter)) == 0) + continue; + + route = nm_ip4_route_new (); + + p = strchr (*iter, '/'); + g_assert (p); + *p++ = '\0'; + + g_assert_cmpint (inet_pton (AF_INET, *iter, &a), ==, 1); + nm_ip4_route_set_dest (route, a.s_addr); + nm_ip4_route_set_prefix (route, (guint) atoi (p)); + + p = strchr (p, ' '); + g_assert (p); + p++; + + g_assert_cmpint (inet_pton (AF_INET, p, &a), ==, 1); + nm_ip4_route_set_next_hop (route, a.s_addr); + + p = strchr (p, ' '); + g_assert (p); + p++; + nm_ip4_route_set_metric (route, (guint) atoi (p)); + + list = g_slist_append (list, route); + } + + val = g_slice_new0 (GValue); + g_value_init (val, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT); + nm_utils_ip4_routes_to_gvalue (list, val); + value_hash_add (*out_props, "routes", val); + } + g_strfreev (split); + } + + return TRUE; +} + +static gboolean +parse_dhcp (GKeyFile *kf, + const char *group_name, + GHashTable **out_props, + GError **error) +{ + char **keys, **iter, *val; + + keys = g_key_file_get_keys (kf, group_name, NULL, error); + if (!keys) + return FALSE; + + *out_props = value_hash_create (); + for (iter = keys; iter && *iter; iter++) { + val = g_key_file_get_string (kf, group_name, *iter, error); + if (!val) + return FALSE; + value_hash_add_string (*out_props, *iter, val); + g_free (val); + } + + return TRUE; +} + +static gboolean +get_dispatcher_file (const char *file, + GHashTable **out_con_hash, + GHashTable **out_con_props, + GHashTable **out_device_props, + GHashTable **out_device_ip4_props, + GHashTable **out_device_ip6_props, + GHashTable **out_device_dhcp4_props, + GHashTable **out_device_dhcp6_props, + const char **out_vpn_ip_iface, + GHashTable **out_vpn_ip4_props, + GHashTable **out_vpn_ip6_props, + char **out_expected_iface, + char **out_action, + GHashTable **out_env, + GError **error) +{ + GKeyFile *kf; + gboolean success = FALSE; + char **keys, **iter, *val; + + kf = g_key_file_new (); + if (!g_key_file_load_from_file (kf, file, G_KEY_FILE_NONE, error)) + return FALSE; + + if (!parse_main (kf, out_con_hash, out_con_props, out_expected_iface, out_action, error)) + goto out; + + if (!parse_device (kf, out_device_props, error)) + goto out; + + if (g_key_file_has_group (kf, "ip4")) { + if (!parse_ip4 (kf, out_device_ip4_props, "ip4", error)) + goto out; + } + + if (g_key_file_has_group (kf, "dhcp4")) { + if (!parse_dhcp (kf, "dhcp4", out_device_dhcp4_props, error)) + goto out; + } + + if (g_key_file_has_group (kf, "dhcp6")) { + if (!parse_dhcp (kf, "dhcp6", out_device_dhcp4_props, error)) + goto out; + } + + g_assert (g_key_file_has_group (kf, "env")); + keys = g_key_file_get_keys (kf, "env", NULL, error); + *out_env = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + for (iter = keys; iter && *iter; iter++) { + val = g_key_file_get_string (kf, "env", *iter, error); + if (!val) + goto out; + g_hash_table_insert (*out_env, + g_strdup_printf ("%s=%s", *iter, val), + GUINT_TO_POINTER (1)); + g_free (val); + } + g_strfreev (keys); + + success = TRUE; + +out: + g_key_file_free (kf); + return success; +} + +/*******************************************/ + +static void +test_generic (const char *path, const char *file) +{ + GHashTable *con_hash = NULL; + GHashTable *con_props = NULL; + GHashTable *device_props = NULL; + GHashTable *device_ip4_props = NULL; + GHashTable *device_ip6_props = NULL; + GHashTable *device_dhcp4_props = NULL; + GHashTable *device_dhcp6_props = NULL; + const char *vpn_ip_iface = NULL; + GHashTable *vpn_ip4_props = NULL; + GHashTable *vpn_ip6_props = NULL; + char *expected_iface = NULL; + char *action = NULL; + char *out_iface = NULL; + GHashTable *expected_env = NULL; + GError *error = NULL; + gboolean success; + char *p; + char **denv, **iter; + + /* Read in the test file */ + p = g_strdup_printf ("%s/%s", path, file); + success = get_dispatcher_file (p, + &con_hash, + &con_props, + &device_props, + &device_ip4_props, + &device_ip6_props, + &device_dhcp4_props, + &device_dhcp6_props, + &vpn_ip_iface, + &vpn_ip4_props, + &vpn_ip6_props, + &expected_iface, + &action, + &expected_env, + &error); + g_free (p); + g_assert_no_error (error); + g_assert (success); + + /* Get the environment from the dispatcher code */ + denv = nm_dispatcher_utils_construct_envp (action, + con_hash, + con_props, + device_props, + device_ip4_props, + device_ip6_props, + device_dhcp4_props, + device_dhcp6_props, + vpn_ip_iface, + vpn_ip4_props, + vpn_ip6_props, + &out_iface); + + /* Print out environment for now */ + g_message ("\n"); + for (iter = denv; iter && *iter; iter++) + g_message (" %s", *iter); + + g_assert_cmpint (g_strv_length (denv), ==, g_hash_table_size (expected_env)); + + { + GHashTableIter k; + const char *key; + g_hash_table_iter_init (&k, expected_env); + while (g_hash_table_iter_next (&k, (gpointer) &key, NULL)) + g_message (" %s", key); + } + + /* Compare dispatcher generated env and expected env */ + for (iter = denv; iter && *iter; iter++) { + gpointer foo; + + foo = g_hash_table_lookup (expected_env, *iter); + if (!foo) + g_warning ("Failed to find %s in environment", *iter); + g_assert (foo); + } + + g_assert_cmpstr (expected_iface, ==, out_iface); +} + +/*******************************************/ + +static void +test_old_up (const char *path) +{ + test_generic (path, "dispatcher-old-up"); +} + +static void +test_old_down (const char *path) +{ + test_generic (path, "dispatcher-old-down"); +} + +static void +test_old_vpn_up (const char *path) +{ + test_generic (path, "dispatcher-old-vpn-up"); +} + +static void +test_old_vpn_down (const char *path) +{ + test_generic (path, "dispatcher-old-vpn-down"); +} + +/*******************************************/ + +#if GLIB_CHECK_VERSION(2,25,12) +typedef GTestFixtureFunc TCFunc; +#else +typedef void (*TCFunc)(void); +#endif + +#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) + +int main (int argc, char **argv) +{ + GTestSuite *suite; + + g_assert (argc > 1); + + g_test_init (&argc, &argv, NULL); + g_type_init (); + + suite = g_test_get_root (); + + g_test_suite_add (suite, TESTCASE (test_old_up, argv[1])); + g_test_suite_add (suite, TESTCASE (test_old_down, argv[1])); + g_test_suite_add (suite, TESTCASE (test_old_vpn_up, argv[1])); + g_test_suite_add (suite, TESTCASE (test_old_vpn_down, argv[1])); + + return g_test_run (); +} + |