dispatcher: expose connection D-Bus path
authorDan Winship <danw@redhat.com>
Thu, 18 Dec 2014 14:06:56 +0000 (09:06 -0500)
committerDan Winship <danw@redhat.com>
Mon, 19 Jan 2015 16:17:37 +0000 (11:17 -0500)
src/nm-dispatcher.c was passing the connection's D-Bus path to the
dispatcher, which was then ignoring it. Meanwhile,
test-dispatcher-envp was passing a fake D-Bus path with the wrong name
(which didn't actually matter since
nm_dispatcher_utils_construct_envp() ignored it anyway).

Fix it so that the path gets exposed as CONNECTION_DBUS_PATH, and
adjust the tests for that.

callouts/nm-dispatcher-utils.c
callouts/tests/dispatcher-down
callouts/tests/dispatcher-up
callouts/tests/dispatcher-vpn-down
callouts/tests/dispatcher-vpn-up
callouts/tests/test-dispatcher-envp.c
man/NetworkManager.xml

index e84b566..dd761f7 100644 (file)
@@ -333,7 +333,7 @@ nm_dispatcher_utils_construct_envp (const char *action,
                                     char **out_iface)
 {
        const char *iface = NULL, *ip_iface = NULL;
-       const char *uuid = NULL, *id = NULL, *path;
+       const char *uuid = NULL, *id = NULL, *path = NULL;
        const char *filename = NULL;
        NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN;
        GVariant *value;
@@ -350,10 +350,17 @@ nm_dispatcher_utils_construct_envp (const char *action,
        if (!strcmp (action, "hostname"))
                goto done;
 
-       /* config filename */
+       /* Connection properties */
+       if (!g_variant_lookup (connection_props, NMD_CONNECTION_PROPS_PATH, "&o", &path)) {
+               g_warning ("Missing or invalid required value " NMD_CONNECTION_PROPS_PATH "!");
+               return NULL;
+       }
+       items = g_slist_prepend (items, g_strdup_printf ("CONNECTION_DBUS_PATH=%s", path));
+
        if (g_variant_lookup (connection_props, NMD_CONNECTION_PROPS_FILENAME, "&s", &filename))
                items = g_slist_prepend (items, g_strdup_printf ("CONNECTION_FILENAME=%s", filename));
 
+
        /* Canonicalize the VPN interface name; "" is used when passing it through
         * D-Bus so make sure that's fixed up here.
         */
index da97d3f..f766595 100644 (file)
@@ -14,6 +14,7 @@ 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-down
 DEVICE_IFACE=wlan0
index 78cfada..463409e 100644 (file)
@@ -33,6 +33,7 @@ domains=hsd1.mn.comcast.net.
 [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-up
 DEVICE_IFACE=wlan0
index eb4dc2c..18267f8 100644 (file)
@@ -33,6 +33,7 @@ domains=hsd1.mn.comcast.net.
 [env]
 PATH=
 CONNECTION_UUID=355653c0-34d3-4777-ad25-f9a498b7ef8e
+CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Connections/5
 CONNECTION_ID=Random Connection
 CONNECTION_FILENAME=/callouts/tests/dispatcher-vpn-down
 DEVICE_IFACE=wlan0
index 8ae78a3..181ecb5 100644 (file)
@@ -33,6 +33,7 @@ domains=hsd1.mn.comcast.net.
 [env]
 PATH=
 CONNECTION_UUID=355653c0-34d3-4777-ad25-f9a498b7ef8e
+CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Connections/5
 CONNECTION_ID=Random Connection
 CONNECTION_FILENAME=/callouts/tests/dispatcher-vpn-up
 DEVICE_IFACE=wlan0
index abccf61..3c0a470 100644 (file)
@@ -81,7 +81,7 @@ parse_main (GKeyFile *kf,
 
        g_variant_builder_init (&props, G_VARIANT_TYPE ("a{sv}"));
        g_variant_builder_add (&props, "{sv}",
-                              "connection-path",
+                              NMD_CONNECTION_PROPS_PATH,
                               g_variant_new_object_path ("/org/freedesktop/NetworkManager/Connections/5"));
        /* Strip out the non-fixed portion of the filename */
        filename = strstr (filename, "/callouts");
index 26f84e5..6b2d886 100644 (file)
             The name (ID) of the connection profile.
           </para></listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>CONNECTION_DBUS_PATH</varname></term>
+          <listitem><para>
+            The NetworkManager D-Bus path of the connection.
+          </para></listitem>
+        </varlistentry>
         <varlistentry>
           <term><varname>CONNECTION_FILENAME</varname></term>
           <listitem><para>