2008-11-23 Dan Williams <dcbw@redhat.com>

* callouts/nm-dispatcher-action.c
		- (construct_envp, nm_dispatcher_action): pass connection UUID to
			scripts in the environment



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4329 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-11-24 02:07:20 +00:00
parent 2328650d2e
commit ef20c1bbdc
2 changed files with 25 additions and 7 deletions

View file

@ -1,3 +1,9 @@
2008-11-23 Dan Williams <dcbw@redhat.com>
* callouts/nm-dispatcher-action.c
- (construct_envp, nm_dispatcher_action): pass connection UUID to
scripts in the environment
2008-11-21 Dan Williams <dcbw@redhat.com>
Patch from Tambet Ingo <tambet@gmail.com>

View file

@ -38,6 +38,7 @@
#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>
@ -235,7 +236,7 @@ add_one_option_to_envp (gpointer key, gpointer value, gpointer user_data)
}
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;
@ -261,7 +262,8 @@ construct_envp (NMIP4Config *ip4_config, NMDHCP4Config *dhcp4_config)
+ 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);
@ -270,6 +272,9 @@ construct_envp (NMIP4Config *ip4_config, NMDHCP4Config *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;
@ -377,6 +382,7 @@ dispatch_scripts (const char *action,
const char *iface,
const char *parent_iface,
NMDeviceType type,
const char *uuid,
NMIP4Config *ip4_config,
NMDHCP4Config *dhcp4_config)
{
@ -422,7 +428,7 @@ dispatch_scripts (const char *action,
}
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];
@ -467,8 +473,8 @@ nm_dispatcher_action (Handler *h,
{
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;
@ -483,7 +489,13 @@ nm_dispatcher_action (Handler *h,
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)),
@ -547,7 +559,7 @@ nm_dispatcher_action (Handler *h,
}
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);