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