diff options
| author | Michael Biebl <biebl@debian.org> | 2016-01-20 16:26:51 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-01-20 16:26:51 +0100 |
| commit | 494f296a3baab08522617b24b1f126d8f9a17502 (patch) | |
| tree | c8ef32fb0dd1c4ff35a0b38e787abb58692de0cd /callouts/nm-dispatcher-utils.c | |
| parent | 54f6333410ffd570e62717d9e77c5c987175e397 (diff) | |
Imported Upstream version 1.1.90 upstream/1.1.90
Diffstat (limited to 'callouts/nm-dispatcher-utils.c')
| -rw-r--r-- | callouts/nm-dispatcher-utils.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/callouts/nm-dispatcher-utils.c b/callouts/nm-dispatcher-utils.c index e7a6f6a2..6079d019 100644 --- a/callouts/nm-dispatcher-utils.c +++ b/callouts/nm-dispatcher-utils.c @@ -22,7 +22,6 @@ #include <string.h> -#include <glib-object.h> #include <nm-dbus-interface.h> #include <nm-connection.h> @@ -30,6 +29,7 @@ #include <nm-setting-ip6-config.h> #include <nm-setting-connection.h> +#include "nm-default.h" #include "nm-dispatcher-api.h" #include "nm-utils.h" @@ -331,30 +331,46 @@ nm_dispatcher_utils_construct_envp (const char *action, const char *vpn_ip_iface, GVariant *vpn_ip4_props, GVariant *vpn_ip6_props, - char **out_iface) + char **out_iface, + const char **out_error_message) { 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; GSList *items = NULL, *iter; guint i; GVariant *con_setting; + const char *error_message_backup; + + if (!out_error_message) + out_error_message = &error_message_backup; g_return_val_if_fail (action != NULL, NULL); g_return_val_if_fail (out_iface != NULL, NULL); g_return_val_if_fail (*out_iface == NULL, NULL); /* Hostname changes don't require a device nor contain a connection */ - if (!strcmp (action, "hostname")) + if (!strcmp (action, NMD_ACTION_HOSTNAME)) goto done; - /* config filename */ + /* Connection properties */ + if (!g_variant_lookup (connection_props, NMD_CONNECTION_PROPS_PATH, "&o", &path)) { + *out_error_message = "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. */ @@ -363,7 +379,7 @@ nm_dispatcher_utils_construct_envp (const char *action, /* interface name */ if (!g_variant_lookup (device_props, NMD_DEVICE_PROPS_INTERFACE, "&s", &iface)) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_INTERFACE "!"); + *out_error_message = "Missing or invalid required value " NMD_DEVICE_PROPS_INTERFACE "!"; return NULL; } if (!*iface) @@ -373,7 +389,7 @@ nm_dispatcher_utils_construct_envp (const char *action, value = g_variant_lookup_value (device_props, NMD_DEVICE_PROPS_IP_INTERFACE, NULL); if (value) { if (!g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) { - g_warning ("Invalid value " NMD_DEVICE_PROPS_IP_INTERFACE "!"); + *out_error_message = "Invalid value " NMD_DEVICE_PROPS_IP_INTERFACE "!"; return NULL; } g_variant_unref (value); @@ -382,14 +398,14 @@ nm_dispatcher_utils_construct_envp (const char *action, /* Device type */ if (!g_variant_lookup (device_props, NMD_DEVICE_PROPS_TYPE, "u", NULL)) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_TYPE "!"); + *out_error_message = "Missing or invalid required value " NMD_DEVICE_PROPS_TYPE "!"; return NULL; } /* Device state */ value = g_variant_lookup_value (device_props, NMD_DEVICE_PROPS_STATE, G_VARIANT_TYPE_UINT32); if (!value) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_STATE "!"); + *out_error_message = "Missing or invalid required value " NMD_DEVICE_PROPS_STATE "!"; return NULL; } dev_state = g_variant_get_uint32 (value); @@ -397,25 +413,25 @@ nm_dispatcher_utils_construct_envp (const char *action, /* device itself */ if (!g_variant_lookup (device_props, NMD_DEVICE_PROPS_PATH, "o", NULL)) { - g_warning ("Missing or invalid required value " NMD_DEVICE_PROPS_PATH "!"); + *out_error_message = "Missing or invalid required value " NMD_DEVICE_PROPS_PATH "!"; return NULL; } /* UUID and ID */ con_setting = g_variant_lookup_value (connection_dict, NM_SETTING_CONNECTION_SETTING_NAME, NM_VARIANT_TYPE_SETTING); if (!con_setting) { - g_warning ("Failed to read connection setting"); + *out_error_message = "Failed to read connection setting"; return NULL; } if (!g_variant_lookup (con_setting, NM_SETTING_CONNECTION_UUID, "&s", &uuid)) { - g_warning ("Connection hash did not contain the UUID"); + *out_error_message = "Connection hash did not contain the UUID"; g_variant_unref (con_setting); return NULL; } if (!g_variant_lookup (con_setting, NM_SETTING_CONNECTION_ID, "&s", &id)) { - g_warning ("Connection hash did not contain the ID"); + *out_error_message = "Connection hash did not contain the ID"; g_variant_unref (con_setting); return NULL; } @@ -462,6 +478,7 @@ nm_dispatcher_utils_construct_envp (const char *action, envp[i] = (char *) iter->data; g_slist_free (items); + *out_error_message = NULL; return envp; } |