summary refs log tree commit diff
path: root/callouts
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2016-08-26 02:18:32 +0200
committerMichael Biebl <biebl@debian.org>2016-08-26 02:18:32 +0200
commit7514efc2f38c9ace4557d4e69d68e7d380389030 (patch)
tree7fb00fda86cfcc2ca377f191633a7cfdbfea7ca3 /callouts
parentd6201f5d8daada3d64a0a3e0038e14eebec683ce (diff)
Imported Upstream version 1.4.0 upstream/1.4.0
Diffstat (limited to 'callouts')
-rw-r--r--callouts/Makefile.am2
-rw-r--r--callouts/Makefile.in16
-rw-r--r--callouts/nm-dispatcher-api.h60
-rw-r--r--callouts/nm-dispatcher-utils.c13
-rw-r--r--callouts/nm-dispatcher-utils.h3
-rw-r--r--callouts/nm-dispatcher.c3
-rw-r--r--callouts/nm-dispatcher.xml2
-rw-r--r--callouts/tests/Makefile.am2
-rw-r--r--callouts/tests/Makefile.in16
-rw-r--r--callouts/tests/dispatcher-connectivity-full23
-rw-r--r--callouts/tests/dispatcher-connectivity-unknown22
-rw-r--r--callouts/tests/test-dispatcher-envp.c73
12 files changed, 125 insertions, 110 deletions
diff --git a/callouts/Makefile.am b/callouts/Makefile.am
index 5279b2f4..82d7e755 100644
--- a/callouts/Makefile.am
+++ b/callouts/Makefile.am
@@ -28,8 +28,8 @@ libexec_PROGRAMS = \
 
 
 nm_dispatcher_SOURCES = \
+	$(top_srcdir)/shared/nm-dispatcher-api.h \
 	nm-dispatcher.c \
-	nm-dispatcher-api.h \
 	nm-dispatcher-utils.c \
 	nm-dispatcher-utils.h
 
diff --git a/callouts/Makefile.in b/callouts/Makefile.in
index 14c5dcb5..9543cf8b 100644
--- a/callouts/Makefile.in
+++ b/callouts/Makefile.in
@@ -93,8 +93,9 @@ host_triplet = @host@
 libexec_PROGRAMS = nm-dispatcher$(EXEEXT)
 subdir = callouts
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
-	$(top_srcdir)/m4/compiler_warnings.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \
+	$(top_srcdir)/m4/ax_lib_readline.m4 \
+	$(top_srcdir)/m4/compiler_options.m4 \
 	$(top_srcdir)/m4/gettext.m4 \
 	$(top_srcdir)/m4/gnome-code-coverage.m4 \
 	$(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \
@@ -307,6 +308,7 @@ DHCLIENT_PATH = @DHCLIENT_PATH@
 DHCPCD_PATH = @DHCPCD_PATH@
 DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@
 DLLTOOL = @DLLTOOL@
+DL_LIBS = @DL_LIBS@
 DNSMASQ_PATH = @DNSMASQ_PATH@
 DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@
 DSYMUTIL = @DSYMUTIL@
@@ -363,13 +365,14 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
 INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
 INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
 IPTABLES_PATH = @IPTABLES_PATH@
+JANSSON_CFLAGS = @JANSSON_CFLAGS@
+JANSSON_LIBS = @JANSSON_LIBS@
 KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
 LCOV = @LCOV@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@
 LIBAUDIT_LIBS = @LIBAUDIT_LIBS@
-LIBDL = @LIBDL@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBM = @LIBM@
@@ -381,6 +384,8 @@ LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@
 LIBSOUP_LIBS = @LIBSOUP_LIBS@
+LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@
+LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@
 LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@
 LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@
 LIBTOOL = @LIBTOOL@
@@ -441,6 +446,8 @@ QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
 READLINE_LIBS = @READLINE_LIBS@
+SANITIZERS = @SANITIZERS@
+SANITIZER_ENV = @SANITIZER_ENV@
 SED = @SED@
 SELINUX_CFLAGS = @SELINUX_CFLAGS@
 SELINUX_LIBS = @SELINUX_LIBS@
@@ -476,6 +483,7 @@ ac_ct_AR = @ac_ct_AR@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_RANLIB = @ac_ct_RANLIB@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
@@ -562,8 +570,8 @@ dbusservice_DATA = \
 	nm-dispatcher.conf
 
 nm_dispatcher_SOURCES = \
+	$(top_srcdir)/shared/nm-dispatcher-api.h \
 	nm-dispatcher.c \
-	nm-dispatcher-api.h \
 	nm-dispatcher-utils.c \
 	nm-dispatcher-utils.h
 
diff --git a/callouts/nm-dispatcher-api.h b/callouts/nm-dispatcher-api.h
deleted file mode 100644
index d702ba68..00000000
--- a/callouts/nm-dispatcher-api.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- 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 - 2012 Red Hat, Inc.
- */
-
-#define NMD_SCRIPT_DIR_DEFAULT  NMCONFDIR "/dispatcher.d"
-#define NMD_SCRIPT_DIR_PRE_UP   NMD_SCRIPT_DIR_DEFAULT "/pre-up.d"
-#define NMD_SCRIPT_DIR_PRE_DOWN NMD_SCRIPT_DIR_DEFAULT "/pre-down.d"
-#define NMD_SCRIPT_DIR_NO_WAIT  NMD_SCRIPT_DIR_DEFAULT "/no-wait.d"
-
-#define NM_DISPATCHER_DBUS_SERVICE   "org.freedesktop.nm_dispatcher"
-#define NM_DISPATCHER_DBUS_INTERFACE "org.freedesktop.nm_dispatcher"
-#define NM_DISPATCHER_DBUS_PATH      "/org/freedesktop/nm_dispatcher"
-
-#define NMD_CONNECTION_PROPS_PATH         "path"
-#define NMD_CONNECTION_PROPS_FILENAME     "filename"
-#define NMD_CONNECTION_PROPS_EXTERNAL     "external"
-
-#define NMD_DEVICE_PROPS_INTERFACE        "interface"
-#define NMD_DEVICE_PROPS_IP_INTERFACE     "ip-interface"
-#define NMD_DEVICE_PROPS_TYPE             "type"
-#define NMD_DEVICE_PROPS_STATE            "state"
-#define NMD_DEVICE_PROPS_PATH             "path"
-
-/* Actions */
-#define NMD_ACTION_HOSTNAME     "hostname"
-#define NMD_ACTION_PRE_UP       "pre-up"
-#define NMD_ACTION_UP           "up"
-#define NMD_ACTION_PRE_DOWN     "pre-down"
-#define NMD_ACTION_DOWN         "down"
-#define NMD_ACTION_VPN_PRE_UP   "vpn-pre-up"
-#define NMD_ACTION_VPN_UP       "vpn-up"
-#define NMD_ACTION_VPN_PRE_DOWN "vpn-pre-down"
-#define NMD_ACTION_VPN_DOWN     "vpn-down"
-#define NMD_ACTION_DHCP4_CHANGE "dhcp4-change"
-#define NMD_ACTION_DHCP6_CHANGE "dhcp6-change"
-
-typedef enum {
-	DISPATCH_RESULT_UNKNOWN = 0,
-	DISPATCH_RESULT_SUCCESS = 1,
-	DISPATCH_RESULT_EXEC_FAILED = 2,
-	DISPATCH_RESULT_FAILED = 3,
-	DISPATCH_RESULT_TIMEOUT = 4,
-} DispatchResult;
-
diff --git a/callouts/nm-dispatcher-utils.c b/callouts/nm-dispatcher-utils.c
index 015bb070..78ef8dd2 100644
--- a/callouts/nm-dispatcher-utils.c
+++ b/callouts/nm-dispatcher-utils.c
@@ -327,6 +327,7 @@ nm_dispatcher_utils_construct_envp (const char *action,
                                     GVariant *device_ip6_props,
                                     GVariant *device_dhcp4_props,
                                     GVariant *device_dhcp6_props,
+                                    const char *connectivity_state,
                                     const char *vpn_ip_iface,
                                     GVariant *vpn_ip4_props,
                                     GVariant *vpn_ip6_props,
@@ -352,9 +353,11 @@ nm_dispatcher_utils_construct_envp (const char *action,
 	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, NMD_ACTION_HOSTNAME))
+	/* Hostname and connectivity changes don't require a device nor contain a connection */
+	if (   !strcmp (action, NMD_ACTION_HOSTNAME)
+	    || !strcmp (action, NMD_ACTION_CONNECTIVITY_CHANGE)) {
 		goto done;
+	}
 
 	/* Connection properties */
 	if (!g_variant_lookup (connection_props, NMD_CONNECTION_PROPS_PATH, "&o", &path)) {
@@ -465,6 +468,12 @@ nm_dispatcher_utils_construct_envp (const char *action,
 		*out_iface = g_strdup (iface);
 
  done:
+	/* The connectivity_state value will only be meaningful for 'connectivity-change' events
+	 * (otherwise it will be "UNKNOWN"), so we only set the environment variable in those cases.
+	 */
+	if (connectivity_state && strcmp(connectivity_state, "UNKNOWN"))
+		items = g_slist_prepend (items, g_strdup_printf ("CONNECTIVITY_STATE=%s", connectivity_state));
+
 	path = g_getenv ("PATH");
 	if (path) {
 		path_item = g_strdup_printf ("PATH=%s", path);
diff --git a/callouts/nm-dispatcher-utils.h b/callouts/nm-dispatcher-utils.h
index 40a0d41f..6a10d4c3 100644
--- a/callouts/nm-dispatcher-utils.h
+++ b/callouts/nm-dispatcher-utils.h
@@ -21,8 +21,6 @@
 #ifndef __NETWORKMANAGER_DISPATCHER_UTILS_H__
 #define __NETWORKMANAGER_DISPATCHER_UTILS_H__
 
-#include "nm-default.h"
-
 char **
 nm_dispatcher_utils_construct_envp (const char *action,
                                     GVariant *connection_dict,
@@ -32,6 +30,7 @@ nm_dispatcher_utils_construct_envp (const char *action,
                                     GVariant *device_ip6_props,
                                     GVariant *device_dhcp4_props,
                                     GVariant *device_dhcp6_props,
+                                    const char *connectivity_state,
                                     const char *vpn_ip_iface,
                                     GVariant *vpn_ip4_props,
                                     GVariant *vpn_ip6_props,
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c
index 7ddffb04..94bd1324 100644
--- a/callouts/nm-dispatcher.c
+++ b/callouts/nm-dispatcher.c
@@ -80,6 +80,7 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
                GVariant *device_ip6_props,
                GVariant *device_dhcp4_props,
                GVariant *device_dhcp6_props,
+               const char *connectivity_state,
                const char *vpn_ip_iface,
                GVariant *vpn_ip4_props,
                GVariant *vpn_ip6_props,
@@ -668,6 +669,7 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
                GVariant *device_ip6_props,
                GVariant *device_dhcp4_props,
                GVariant *device_dhcp6_props,
+               const char *connectivity_state,
                const char *vpn_ip_iface,
                GVariant *vpn_ip4_props,
                GVariant *vpn_ip6_props,
@@ -699,6 +701,7 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
 	                                                    device_ip6_props,
 	                                                    device_dhcp4_props,
 	                                                    device_dhcp6_props,
+	                                                    connectivity_state,
 	                                                    vpn_ip_iface,
 	                                                    vpn_ip4_props,
 	                                                    vpn_ip6_props,
diff --git a/callouts/nm-dispatcher.xml b/callouts/nm-dispatcher.xml
index 27f15fe5..6268f970 100644
--- a/callouts/nm-dispatcher.xml
+++ b/callouts/nm-dispatcher.xml
@@ -13,6 +13,7 @@
         @device_ip6_config: Properties of the device's IPv6 configuration.
         @device_dhcp4_config: Properties of the device's DHCPv4 configuration.
         @device_dhcp6_config: Properties of the device's DHCPv6 configuration.
+        @connectivity_state: Current connectivity state: unknown, none, limited, portal or full.
         @vpn_ip_iface: VPN interface name.
         @vpn_ip4_config: Properties of the VPN's IPv4 configuration.
         @vpn_ip6_config: Properties of the VPN's IPv6 configuration.
@@ -30,6 +31,7 @@
       <arg name="device_ip6_config" type="a{sv}" direction="in"/>
       <arg name="device_dhcp4_config" type="a{sv}" direction="in"/>
       <arg name="device_dhcp6_config" type="a{sv}" direction="in"/>
+      <arg name="connectivity_state" type="s" direction="in"/>
       <arg name="vpn_ip_iface" type="s" direction="in"/>
       <arg name="vpn_ip4_config" type="a{sv}" direction="in"/>
       <arg name="vpn_ip6_config" type="a{sv}" direction="in"/>
diff --git a/callouts/tests/Makefile.am b/callouts/tests/Makefile.am
index 6ac15874..2450f372 100644
--- a/callouts/tests/Makefile.am
+++ b/callouts/tests/Makefile.am
@@ -32,6 +32,8 @@ TESTS = test-dispatcher-envp
 endif
 
 EXTRA_DIST= \
+	dispatcher-connectivity-full \
+	dispatcher-connectivity-unknown \
 	dispatcher-down \
 	dispatcher-external \
 	dispatcher-up \
diff --git a/callouts/tests/Makefile.in b/callouts/tests/Makefile.in
index a4a80afb..9f79b951 100644
--- a/callouts/tests/Makefile.in
+++ b/callouts/tests/Makefile.in
@@ -92,8 +92,9 @@ host_triplet = @host@
 @ENABLE_TESTS_TRUE@TESTS = test-dispatcher-envp$(EXEEXT)
 subdir = callouts/tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
-	$(top_srcdir)/m4/compiler_warnings.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \
+	$(top_srcdir)/m4/ax_lib_readline.m4 \
+	$(top_srcdir)/m4/compiler_options.m4 \
 	$(top_srcdir)/m4/gettext.m4 \
 	$(top_srcdir)/m4/gnome-code-coverage.m4 \
 	$(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \
@@ -427,6 +428,7 @@ DHCLIENT_PATH = @DHCLIENT_PATH@
 DHCPCD_PATH = @DHCPCD_PATH@
 DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@
 DLLTOOL = @DLLTOOL@
+DL_LIBS = @DL_LIBS@
 DNSMASQ_PATH = @DNSMASQ_PATH@
 DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@
 DSYMUTIL = @DSYMUTIL@
@@ -483,13 +485,14 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
 INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
 INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
 IPTABLES_PATH = @IPTABLES_PATH@
+JANSSON_CFLAGS = @JANSSON_CFLAGS@
+JANSSON_LIBS = @JANSSON_LIBS@
 KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
 LCOV = @LCOV@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@
 LIBAUDIT_LIBS = @LIBAUDIT_LIBS@
-LIBDL = @LIBDL@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBM = @LIBM@
@@ -501,6 +504,8 @@ LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@
 LIBSOUP_LIBS = @LIBSOUP_LIBS@
+LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@
+LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@
 LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@
 LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@
 LIBTOOL = @LIBTOOL@
@@ -561,6 +566,8 @@ QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
 READLINE_LIBS = @READLINE_LIBS@
+SANITIZERS = @SANITIZERS@
+SANITIZER_ENV = @SANITIZER_ENV@
 SED = @SED@
 SELINUX_CFLAGS = @SELINUX_CFLAGS@
 SELINUX_LIBS = @SELINUX_LIBS@
@@ -596,6 +603,7 @@ ac_ct_AR = @ac_ct_AR@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_RANLIB = @ac_ct_RANLIB@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
@@ -679,6 +687,8 @@ with_valgrind = @with_valgrind@
 @ENABLE_TESTS_TRUE@	$(GLIB_LIBS)
 
 EXTRA_DIST = \
+	dispatcher-connectivity-full \
+	dispatcher-connectivity-unknown \
 	dispatcher-down \
 	dispatcher-external \
 	dispatcher-up \
diff --git a/callouts/tests/dispatcher-connectivity-full b/callouts/tests/dispatcher-connectivity-full
new file mode 100644
index 00000000..c370bc35
--- /dev/null
+++ b/callouts/tests/dispatcher-connectivity-full
@@ -0,0 +1,23 @@
+[main]
+action=connectiviy-change
+expected-iface=wlan0
+uuid=3fd2a33a-d81b-423f-ae99-e6baba742311
+id=Random Connection
+connectivity-state=FULL
+
+[device]
+state=30
+ip-interface=wlan0
+type=2
+interface=wlan0
+path=/org/freedesktop/NetworkManager/Devices/0
+
+[env]
+PATH=
+CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311
+CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Connections/5
+CONNECTION_ID=Random Connection
+CONNECTION_FILENAME=/callouts/tests/dispatcher-connectivity-full
+DEVICE_IFACE=wlan0
+DEVICE_IP_IFACE=wlan0
+CONNECTIVITY_STATE=FULL
diff --git a/callouts/tests/dispatcher-connectivity-unknown b/callouts/tests/dispatcher-connectivity-unknown
new file mode 100644
index 00000000..9622d017
--- /dev/null
+++ b/callouts/tests/dispatcher-connectivity-unknown
@@ -0,0 +1,22 @@
+[main]
+action=connectiviy-change
+expected-iface=wlan0
+uuid=3fd2a33a-d81b-423f-ae99-e6baba742311
+id=Random Connection
+connectivity-state=UNKNOWN
+
+[device]
+state=30
+ip-interface=wlan0
+type=2
+interface=wlan0
+path=/org/freedesktop/NetworkManager/Devices/0
+
+[env]
+PATH=
+CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311
+CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Connections/5
+CONNECTION_ID=Random Connection
+CONNECTION_FILENAME=/callouts/tests/dispatcher-connectivity-unknown
+DEVICE_IFACE=wlan0
+DEVICE_IP_IFACE=wlan0
diff --git a/callouts/tests/test-dispatcher-envp.c b/callouts/tests/test-dispatcher-envp.c
index 9cdaa3b5..8636f097 100644
--- a/callouts/tests/test-dispatcher-envp.c
+++ b/callouts/tests/test-dispatcher-envp.c
@@ -28,7 +28,7 @@
 #include "nm-dispatcher-utils.h"
 #include "nm-dispatcher-api.h"
 
-#include "nm-test-utils.h"
+#include "nm-utils/nm-test-utils.h"
 
 /*******************************************/
 
@@ -39,6 +39,7 @@ parse_main (GKeyFile *kf,
             GVariant **out_con_props,
             char **out_expected_iface,
             char **out_action,
+            char **out_connectivity_state,
             char **out_vpn_ip_iface,
             GError **error)
 {
@@ -51,6 +52,7 @@ parse_main (GKeyFile *kf,
 	if (*out_expected_iface == NULL)
 		return FALSE;
 
+	*out_connectivity_state = g_key_file_get_string (kf, "main", "connectivity-state", NULL);
 	*out_vpn_ip_iface = g_key_file_get_string (kf, "main", "vpn-ip-iface", NULL);
 
 	*out_action = g_key_file_get_string (kf, "main", "action", error);
@@ -359,6 +361,7 @@ get_dispatcher_file (const char *file,
                      GVariant **out_device_ip6_props,
                      GVariant **out_device_dhcp4_props,
                      GVariant **out_device_dhcp6_props,
+                     char **out_connectivity_state,
                      char **out_vpn_ip_iface,
                      GVariant **out_vpn_ip4_props,
                      GVariant **out_vpn_ip6_props,
@@ -379,6 +382,7 @@ get_dispatcher_file (const char *file,
 	g_assert (out_device_ip6_props && !*out_device_ip6_props);
 	g_assert (out_device_dhcp4_props && !*out_device_dhcp4_props);
 	g_assert (out_device_dhcp6_props && !*out_device_dhcp6_props);
+	g_assert (out_connectivity_state && !*out_connectivity_state);
 	g_assert (out_vpn_ip_iface && !*out_vpn_ip_iface);
 	g_assert (out_vpn_ip4_props && !*out_vpn_ip4_props);
 	g_assert (out_vpn_ip6_props && !*out_vpn_ip6_props);
@@ -396,6 +400,7 @@ get_dispatcher_file (const char *file,
 	                 out_con_props,
 	                 out_expected_iface,
 	                 out_action,
+	                 out_connectivity_state,
 	                 out_vpn_ip_iface,
 	                 error))
 		goto out;
@@ -444,25 +449,27 @@ out:
 static void
 test_generic (const char *file, const char *override_vpn_ip_iface)
 {
-	GVariant *con_dict = NULL;
-	GVariant *con_props = NULL;
-	GVariant *device_props = NULL;
-	GVariant *device_ip4_props = NULL;
-	GVariant *device_ip6_props = NULL;
-	GVariant *device_dhcp4_props = NULL;
-	GVariant *device_dhcp6_props = NULL;
-	char *vpn_ip_iface = NULL;
-	GVariant *vpn_ip4_props = NULL;
-	GVariant *vpn_ip6_props = NULL;
-	char *expected_iface = NULL;
-	char *action = NULL;
-	char *out_iface = NULL;
+	gs_unref_variant GVariant *con_dict = NULL;
+	gs_unref_variant GVariant *con_props = NULL;
+	gs_unref_variant GVariant *device_props = NULL;
+	gs_unref_variant GVariant *device_ip4_props = NULL;
+	gs_unref_variant GVariant *device_ip6_props = NULL;
+	gs_unref_variant GVariant *device_dhcp4_props = NULL;
+	gs_unref_variant GVariant *device_dhcp6_props = NULL;
+	gs_free char *connectivity_change = NULL;
+	gs_free char *vpn_ip_iface = NULL;
+	gs_unref_variant GVariant *vpn_ip4_props = NULL;
+	gs_unref_variant GVariant *vpn_ip6_props = NULL;
+	gs_free char *expected_iface = NULL;
+	gs_free char *action = NULL;
+	gs_free char *out_iface = NULL;
 	const char *error_message = NULL;
-	GHashTable *expected_env = NULL;
+	gs_unref_hashtable GHashTable *expected_env = NULL;
 	GError *error = NULL;
 	gboolean success;
 	char *p;
-	char **denv, **iter;
+	gs_strfreev char **denv = NULL;
+	char **iter;
 
 	/* Read in the test file */
 	p = g_build_filename (SRCDIR, file, NULL);
@@ -474,6 +481,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
 	                               &device_ip6_props,
 	                               &device_dhcp4_props,
 	                               &device_dhcp6_props,
+	                               &connectivity_change,
 	                               &vpn_ip_iface,
 	                               &vpn_ip4_props,
 	                               &vpn_ip6_props,
@@ -494,6 +502,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
 	                                           device_ip6_props,
 	                                           device_dhcp4_props,
 	                                           device_dhcp6_props,
+	                                           connectivity_change,
 	                                           override_vpn_ip_iface ? override_vpn_ip_iface : vpn_ip_iface,
 	                                           vpn_ip4_props,
 	                                           vpn_ip6_props,
@@ -545,28 +554,6 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
 	}
 
 	g_assert_cmpstr (expected_iface, ==, out_iface);
-
-	g_strfreev (denv);
-	g_free (out_iface);
-	g_free (vpn_ip_iface);
-	g_free (expected_iface);
-	g_free (action);
-	g_variant_unref (con_dict);
-	g_variant_unref (con_props);
-	g_variant_unref (device_props);
-	if (device_ip4_props)
-		g_variant_unref (device_ip4_props);
-	if (device_ip6_props)
-		g_variant_unref (device_ip6_props);
-	if (device_dhcp4_props)
-		g_variant_unref (device_dhcp4_props);
-	if (device_dhcp6_props)
-		g_variant_unref (device_dhcp6_props);
-	if (vpn_ip4_props)
-		g_variant_unref (vpn_ip4_props);
-	if (vpn_ip6_props)
-		g_variant_unref (vpn_ip6_props);
-	g_hash_table_destroy (expected_env);
 }
 
 /*******************************************/
@@ -602,6 +589,15 @@ test_external (void)
 }
 
 static void
+test_connectivity_changed (void)
+{
+	/* These tests will check that the CONNECTIVITY_STATE environment
+	 * variable is only defined for known states, such as 'full'. */
+	test_generic ("dispatcher-connectivity-unknown", NULL);
+	test_generic ("dispatcher-connectivity-full", NULL);
+}
+
+static void
 test_up_empty_vpn_iface (void)
 {
 	/* Test that an empty VPN iface variable, like is passed through D-Bus
@@ -624,6 +620,7 @@ main (int argc, char **argv)
 	g_test_add_func ("/dispatcher/vpn_up", test_vpn_up);
 	g_test_add_func ("/dispatcher/vpn_down", test_vpn_down);
 	g_test_add_func ("/dispatcher/external", test_external);
+	g_test_add_func ("/dispatcher/connectivity_changed", test_connectivity_changed);
 
 	g_test_add_func ("/dispatcher/up_empty_vpn_iface", test_up_empty_vpn_iface);