mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-16 19:20:20 +01:00
dispatcher: pass CONNECTION_FILENAME to dispatcher scripts
(cherry picked from commit bd2deace70)
This commit is contained in:
parent
3572160f55
commit
1a97ff2953
9 changed files with 31 additions and 0 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#define NM_DISPATCHER_DBUS_PATH "/org/freedesktop/nm_dispatcher"
|
||||
|
||||
#define NMD_CONNECTION_PROPS_PATH "path"
|
||||
#define NMD_CONNECTION_PROPS_FILENAME "filename"
|
||||
|
||||
#define NMD_DEVICE_PROPS_INTERFACE "interface"
|
||||
#define NMD_DEVICE_PROPS_IP_INTERFACE "ip-interface"
|
||||
|
|
|
|||
|
|
@ -334,6 +334,7 @@ nm_dispatcher_utils_construct_envp (const char *action,
|
|||
{
|
||||
const char *iface = NULL, *ip_iface = NULL;
|
||||
const char *uuid = NULL, *id = NULL, *path;
|
||||
const char *filename = NULL;
|
||||
NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN;
|
||||
GVariant *value;
|
||||
char **envp = NULL, *path_item;
|
||||
|
|
@ -349,6 +350,10 @@ nm_dispatcher_utils_construct_envp (const char *action,
|
|||
if (!strcmp (action, "hostname"))
|
||||
goto done;
|
||||
|
||||
/* config filename */
|
||||
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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ path=/org/freedesktop/NetworkManager/Devices/0
|
|||
PATH=
|
||||
CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311
|
||||
CONNECTION_ID=Random Connection
|
||||
CONNECTION_FILENAME=/callouts/tests/dispatcher-old-down
|
||||
DEVICE_IFACE=wlan0
|
||||
DEVICE_IP_IFACE=wlan0
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ domains=hsd1.mn.comcast.net.
|
|||
PATH=
|
||||
CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311
|
||||
CONNECTION_ID=Random Connection
|
||||
CONNECTION_FILENAME=/callouts/tests/dispatcher-old-up
|
||||
DEVICE_IFACE=wlan0
|
||||
DEVICE_IP_IFACE=wlan0
|
||||
IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ domains=hsd1.mn.comcast.net.
|
|||
PATH=
|
||||
CONNECTION_UUID=355653c0-34d3-4777-ad25-f9a498b7ef8e
|
||||
CONNECTION_ID=Random Connection
|
||||
CONNECTION_FILENAME=/callouts/tests/dispatcher-old-vpn-down
|
||||
DEVICE_IFACE=wlan0
|
||||
DEVICE_IP_IFACE=tun0
|
||||
IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ domains=hsd1.mn.comcast.net.
|
|||
PATH=
|
||||
CONNECTION_UUID=355653c0-34d3-4777-ad25-f9a498b7ef8e
|
||||
CONNECTION_ID=Random Connection
|
||||
CONNECTION_FILENAME=/callouts/tests/dispatcher-old-vpn-up
|
||||
DEVICE_IFACE=wlan0
|
||||
DEVICE_IP_IFACE=tun0
|
||||
IP4_ADDRESS_0=192.168.1.119/24 192.168.1.1
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
static gboolean
|
||||
parse_main (GKeyFile *kf,
|
||||
const char *filename,
|
||||
GVariant **out_con_dict,
|
||||
GVariant **out_con_props,
|
||||
char **out_expected_iface,
|
||||
|
|
@ -82,6 +83,11 @@ parse_main (GKeyFile *kf,
|
|||
g_variant_builder_add (&props, "{sv}",
|
||||
"connection-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));
|
||||
*out_con_props = g_variant_builder_end (&props);
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -358,6 +364,7 @@ get_dispatcher_file (const char *file,
|
|||
return FALSE;
|
||||
|
||||
if (!parse_main (kf,
|
||||
file,
|
||||
out_con_dict,
|
||||
out_con_props,
|
||||
out_expected_iface,
|
||||
|
|
|
|||
|
|
@ -166,6 +166,12 @@
|
|||
The name (ID) of the connection profile.
|
||||
</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>DEVICE_IFACE</varname></term>
|
||||
<listitem><para>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "nm-dhcp6-config.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-settings-connection.h"
|
||||
|
||||
#define CALL_TIMEOUT (1000 * 60 * 10) /* 10 minutes for all scripts */
|
||||
|
||||
|
|
@ -474,6 +475,7 @@ _dispatcher_call (DispatcherAction action,
|
|||
|
||||
if (connection) {
|
||||
GVariant *connection_dict;
|
||||
const char *filename;
|
||||
|
||||
connection_dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_NO_SECRETS);
|
||||
connection_hash = nm_utils_connection_dict_to_hash (connection_dict);
|
||||
|
|
@ -483,6 +485,12 @@ _dispatcher_call (DispatcherAction action,
|
|||
value_hash_add_object_path (connection_props,
|
||||
NMD_CONNECTION_PROPS_PATH,
|
||||
nm_connection_get_path (connection));
|
||||
filename = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection));
|
||||
if (filename) {
|
||||
value_hash_add_str (connection_props,
|
||||
NMD_CONNECTION_PROPS_FILENAME,
|
||||
filename);
|
||||
}
|
||||
} else {
|
||||
connection_hash = value_hash_create ();
|
||||
connection_props = value_hash_create ();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue