Commit 1c435dc8 authored by Dan Winship's avatar Dan Winship

dispatcher: merge branch 'danw/dispatcher-external-bgo742588'

https://bugzilla.gnome.org/show_bug.cgi?id=742588
parents 1bc942b1 849ae9ee
......@@ -32,6 +32,7 @@
#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"
......
......@@ -333,8 +333,9 @@ 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;
gboolean external;
NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN;
GVariant *value;
char **envp = NULL, *path_item;
......@@ -350,10 +351,20 @@ 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_EXTERNAL, "b", &external) && external)
items = g_slist_prepend (items, g_strdup ("CONNECTION_EXTERNAL=1"));
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.
*/
......
......@@ -33,7 +33,8 @@ TESTS = test-dispatcher-envp
endif
EXTRA_DIST= \
dispatcher-old-down \
dispatcher-old-up \
dispatcher-old-vpn-down \
dispatcher-old-vpn-up
dispatcher-down \
dispatcher-external \
dispatcher-up \
dispatcher-vpn-down \
dispatcher-vpn-up
......@@ -14,8 +14,9 @@ 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-old-down
CONNECTION_FILENAME=/callouts/tests/dispatcher-down
DEVICE_IFACE=wlan0
DEVICE_IP_IFACE=wlan0
[main]
action=up
expected-iface=virbr0
uuid=92bbc2fb-7304-46be-8ebb-6093dbe19a6a
id=virbr0
external=1
[device]
state=100
ip-interface=virbr0
type=13
interface=virbr0
path=/org/freedesktop/NetworkManager/Devices/0
[ip4]
addresses=192.168.122.1/24 0.0.0.0
domains=
gateway=0.0.0.0
[env]
PATH=
CONNECTION_UUID=92bbc2fb-7304-46be-8ebb-6093dbe19a6a
CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Connections/5
CONNECTION_FILENAME=/callouts/tests/dispatcher-external
CONNECTION_ID=virbr0
CONNECTION_EXTERNAL=1
DEVICE_IFACE=virbr0
DEVICE_IP_IFACE=virbr0
IP4_NUM_ADDRESSES=1
IP4_ADDRESS_0=192.168.122.1/24 0.0.0.0
IP4_GATEWAY=0.0.0.0
IP4_NUM_ROUTES=0
......@@ -33,8 +33,9 @@ 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-old-up
CONNECTION_FILENAME=/callouts/tests/dispatcher-up
DEVICE_IFACE=wlan0
DEVICE_IP_IFACE=wlan0
IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1
......
......@@ -33,8 +33,9 @@ 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-old-vpn-down
CONNECTION_FILENAME=/callouts/tests/dispatcher-vpn-down
DEVICE_IFACE=wlan0
DEVICE_IP_IFACE=tun0
IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1
......
......@@ -33,8 +33,9 @@ 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-old-vpn-up
CONNECTION_FILENAME=/callouts/tests/dispatcher-vpn-up
DEVICE_IFACE=wlan0
DEVICE_IP_IFACE=tun0
IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1
......
......@@ -81,13 +81,21 @@ 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");
g_variant_builder_add (&props, "{sv}",
"filename",
g_variant_new_string (filename));
if (g_key_file_get_boolean (kf, "main", "external", NULL)) {
g_variant_builder_add (&props, "{sv}",
"external",
g_variant_new_boolean (TRUE));
}
*out_con_props = g_variant_builder_end (&props);
return TRUE;
......@@ -537,27 +545,33 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
/*******************************************/
static void
test_old_up (void)
test_up (void)
{
test_generic ("dispatcher-up", NULL);
}
static void
test_down (void)
{
test_generic ("dispatcher-old-up", NULL);
test_generic ("dispatcher-down", NULL);
}
static void
test_old_down (void)
test_vpn_up (void)
{
test_generic ("dispatcher-old-down", NULL);
test_generic ("dispatcher-vpn-up", NULL);
}
static void
test_old_vpn_up (void)
test_vpn_down (void)
{
test_generic ("dispatcher-old-vpn-up", NULL);
test_generic ("dispatcher-vpn-down", NULL);
}
static void
test_old_vpn_down (void)
test_external (void)
{
test_generic ("dispatcher-old-vpn-down", NULL);
test_generic ("dispatcher-external", NULL);
}
static void
......@@ -566,7 +580,7 @@ test_up_empty_vpn_iface (void)
/* Test that an empty VPN iface variable, like is passed through D-Bus
* from NM, is ignored by the dispatcher environment construction code.
*/
test_generic ("dispatcher-old-up", "");
test_generic ("dispatcher-up", "");
}
/*******************************************/
......@@ -580,10 +594,11 @@ main (int argc, char **argv)
g_type_init ();
#endif
g_test_add_func ("/dispatcher/old_up", test_old_up);
g_test_add_func ("/dispatcher/old_down", test_old_down);
g_test_add_func ("/dispatcher/old_vpn_up", test_old_vpn_up);
g_test_add_func ("/dispatcher/old_vpn_down", test_old_vpn_down);
g_test_add_func ("/dispatcher/up", test_up);
g_test_add_func ("/dispatcher/down", test_down);
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/up_empty_vpn_iface", test_up_empty_vpn_iface);
......
......@@ -166,12 +166,25 @@
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>
The backing file name of the connection profile (if any).
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>CONNECTION_EXTERNAL</varname></term>
<listitem><para>
If "1", this indicates that the connection describes a
network configuration created outside of NetworkManager.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>DEVICE_IFACE</varname></term>
<listitem><para>
......
......@@ -491,6 +491,11 @@ _dispatcher_call (DispatcherAction action,
NMD_CONNECTION_PROPS_FILENAME,
filename);
}
if (nm_settings_connection_get_nm_generated_assumed (NM_SETTINGS_CONNECTION (connection))) {
value_hash_add_bool (connection_props,
NMD_CONNECTION_PROPS_EXTERNAL,
TRUE);
}
} else {
connection_hash = value_hash_create ();
connection_props = value_hash_create ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment