#include <NetworkManager.h>
#include <libnm-util/nm-connection.h>
#include <libnm-util/nm-setting-ip4-config.h>
+#include <libnm-util/nm-setting-connection.h>
#include <libnm-glib/nm-dhcp4-config.h>
#include <libnm-glib/nm-device.h>
}
static char **
-construct_envp (NMIP4Config *ip4_config, NMDHCP4Config *dhcp4_config)
+construct_envp (const char *uuid, NMIP4Config *ip4_config, NMDHCP4Config *dhcp4_config)
{
guint32 env_size = 0;
char **envp;
+ 1 /* domains */
+ 1 /* hostname */
+ g_slist_length (routes)
- + 1 /* routes length */;
+ + 1 /* routes length */
+ + 1 /* connection UUID */;
if (dhcp4_config) {
options = nm_dhcp4_config_get_options (dhcp4_config);
envp = g_new0 (char *, env_size + 1);
+ if (uuid)
+ envp[envp_idx++] = g_strdup_printf ("CONNECTION_UUID=%s", uuid);
+
/* IP4 config stuff */
for (iter = addresses, num = 0; iter; iter = g_slist_next (iter)) {
NMIP4Address *addr = (NMIP4Address *) iter->data;
const char *iface,
const char *parent_iface,
NMDeviceType type,
+ const char *uuid,
NMIP4Config *ip4_config,
NMDHCP4Config *dhcp4_config)
{
}
g_dir_close (dir);
- envp = construct_envp (ip4_config, dhcp4_config);
+ envp = construct_envp (uuid, ip4_config, dhcp4_config);
for (iter = scripts; iter; iter = g_slist_next (iter)) {
gchar *argv[4];
{
Dispatcher *d = g_object_get_data (G_OBJECT (h), "dispatcher");
NMConnection *connection;
- char *iface = NULL;
- char *parent_iface = NULL;
+ char *iface = NULL, *parent_iface = NULL;
+ const char *uuid = NULL;
NMDeviceType type = NM_DEVICE_TYPE_UNKNOWN;
NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN;
NMDevice *device = NULL;
d->quit_timeout = g_timeout_add (10000, quit_timeout_cb, NULL);
connection = nm_connection_new_from_hash (connection_hash, error);
- if (!connection) {
+ if (connection) {
+ NMSettingConnection *s_con;
+
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ if (s_con)
+ uuid = nm_setting_connection_get_uuid (s_con);
+ } else {
g_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark ((*error)->domain)),
}
dispatch:
- dispatch_scripts (action, iface, parent_iface, type, ip4_config, dhcp4_config);
+ dispatch_scripts (action, iface, parent_iface, type, uuid, ip4_config, dhcp4_config);
if (device)
g_object_unref (device);