Merge commit 'origin/master' into btdun

This commit is contained in:
Dan Williams 2009-10-07 12:20:47 -07:00
commit 6f502e9116
8 changed files with 88 additions and 108 deletions

View file

@ -11,7 +11,7 @@
<property name="Speed" type="u" access="read"> <property name="Speed" type="u" access="read">
<tp:docstring> <tp:docstring>
Design speed of the device. Design speed of the device, in megabits/second (Mb/s).
</tp:docstring> </tp:docstring>
</property> </property>

View file

@ -134,8 +134,10 @@ update (NMSettingsConnectionInterface *connection,
NMSettingsConnectionInterfaceUpdateFunc callback, NMSettingsConnectionInterfaceUpdateFunc callback,
gpointer user_data) gpointer user_data)
{ {
g_object_ref (connection);
nm_settings_connection_interface_emit_updated (connection); nm_settings_connection_interface_emit_updated (connection);
callback (connection, NULL, user_data); callback (connection, NULL, user_data);
g_object_unref (connection);
return TRUE; return TRUE;
} }
@ -183,8 +185,10 @@ do_delete (NMSettingsConnectionInterface *connection,
NMSettingsConnectionInterfaceDeleteFunc callback, NMSettingsConnectionInterfaceDeleteFunc callback,
gpointer user_data) gpointer user_data)
{ {
g_object_ref (connection);
g_signal_emit_by_name (connection, "removed"); g_signal_emit_by_name (connection, "removed");
callback (connection, NULL, user_data); callback (connection, NULL, user_data);
g_object_unref (connection);
return TRUE; return TRUE;
} }

View file

@ -575,35 +575,35 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared)
for (iter = list; iter; iter = g_slist_next (iter)) { for (iter = list; iter; iter = g_slist_next (iter)) {
ShareRule *rule = (ShareRule *) iter->data; ShareRule *rule = (ShareRule *) iter->data;
char *envp[1] = { NULL }; char *envp[1] = { NULL };
char *argv[6]; char **argv;
char *cmd; char *cmd;
int status;
GError *error = NULL;
argv[0] = IPTABLES_PATH; cmd = g_strdup_printf ("%s --table %s %s %s",
argv[1] = "--table"; IPTABLES_PATH,
argv[2] = rule->table; rule->table,
shared ? "--insert" : "--delete",
rule->rule);
if (!cmd)
continue;
if (shared) argv = g_strsplit (cmd, " ", 0);
argv[3] = "--insert"; if (argv && argv[0]) {
else int status;
argv[3] = "--delete"; GError *error = NULL;
argv[4] = rule->rule; nm_info ("Executing: %s", cmd);
argv[5] = NULL; if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
share_child_setup, NULL, NULL, NULL, &status, &error)) {
cmd = g_strjoinv (" ", argv); nm_info ("Error executing command: (%d) %s",
nm_info ("Executing: %s", cmd); error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
} else if (WEXITSTATUS (status))
nm_info ("** Command returned exit status %d.", WEXITSTATUS (status));
}
g_free (cmd); g_free (cmd);
if (argv)
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, g_strfreev (argv);
share_child_setup, NULL, NULL, NULL, &status, &error)) {
nm_info ("Error executing command: (%d) %s",
error ? error->code : 0, (error && error->message) ? error->message : "unknown");
if (error)
g_error_free (error);
} else if (WEXITSTATUS (status))
nm_info ("** Command returned exit status %d.", WEXITSTATUS (status));
} }
g_slist_free (list); g_slist_free (list);

View file

@ -921,15 +921,14 @@ supplicant_mgr_state_cb (NMSupplicantInterface * iface,
static NMSupplicantConfig * static NMSupplicantConfig *
build_supplicant_config (NMDeviceEthernet *self) build_supplicant_config (NMDeviceEthernet *self)
{ {
DBusGProxy *proxy;
const char *con_path; const char *con_path;
NMSupplicantConfig *config = NULL; NMSupplicantConfig *config = NULL;
NMSetting8021x *security; NMSetting8021x *security;
NMConnection *connection; NMConnection *connection;
connection = nm_act_request_get_connection (nm_device_get_act_request (NM_DEVICE (self))); connection = nm_act_request_get_connection (nm_device_get_act_request (NM_DEVICE (self)));
proxy = g_object_get_data (G_OBJECT (connection), "dbus-proxy"); g_return_val_if_fail (connection, NULL);
con_path = dbus_g_proxy_get_path (proxy); con_path = nm_connection_get_path (connection);
config = nm_supplicant_config_new (); config = nm_supplicant_config_new ();
if (!config) if (!config)

View file

@ -109,6 +109,11 @@ nm_phasechange (void *data, int arg)
break; break;
} }
g_message ("nm-ppp-plugin: (%s): status %d / phase '%s'",
__func__,
ppp_status,
ppp_phase);
if (ppp_status != NM_PPP_STATUS_UNKNOWN) { if (ppp_status != NM_PPP_STATUS_UNKNOWN) {
dbus_g_proxy_call_no_reply (proxy, "SetState", dbus_g_proxy_call_no_reply (proxy, "SetState",
G_TYPE_UINT, ppp_status, G_TYPE_INVALID, G_TYPE_UINT, ppp_status, G_TYPE_INVALID,
@ -161,8 +166,10 @@ nm_ip_up (void *data, int arg)
g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (DBUS_IS_G_PROXY (proxy));
g_message ("nm-ppp-plugin: (%s): ip-up event", __func__);
if (!opts.ouraddr) { if (!opts.ouraddr) {
g_warning ("Didn't receive an internal IP from pppd!"); g_warning ("nm-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__);
nm_phasechange (NULL, PHASE_DEAD); nm_phasechange (NULL, PHASE_DEAD);
return; return;
} }
@ -224,9 +231,11 @@ nm_ip_up (void *data, int arg)
g_hash_table_insert (hash, NM_PPP_IP4_CONFIG_WINS, val); g_hash_table_insert (hash, NM_PPP_IP4_CONFIG_WINS, val);
} }
g_message ("nm-ppp-plugin: (%s): sending Ip4Config to NetworkManager...", __func__);
dbus_g_proxy_call_no_reply (proxy, "SetIp4Config", dbus_g_proxy_call_no_reply (proxy, "SetIp4Config",
DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID, DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID,
G_TYPE_INVALID); G_TYPE_INVALID);
g_hash_table_destroy (hash); g_hash_table_destroy (hash);
} }
@ -258,18 +267,25 @@ get_credentials (char *username, char *password)
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), -1); g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), -1);
g_message ("nm-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__);
dbus_g_proxy_call (proxy, "NeedSecrets", &err, dbus_g_proxy_call (proxy, "NeedSecrets", &err,
G_TYPE_INVALID, G_TYPE_INVALID,
G_TYPE_STRING, &my_username, G_TYPE_STRING, &my_username,
G_TYPE_STRING, &my_password, G_TYPE_STRING, &my_password,
G_TYPE_INVALID); G_TYPE_INVALID);
if (err) { if (err) {
g_warning ("Could not get secrets: %s", err->message); g_warning ("nm-ppp-plugin: (%s): could not get secrets: (%d) %s",
__func__,
err ? err->code : -1,
err->message ? err->message : "(unknown)");
g_error_free (err); g_error_free (err);
return -1; return -1;
} }
g_message ("nm-ppp-plugin: (%s): got credentials from NetworkManager", __func__);
if (my_username) { if (my_username) {
len = strlen (my_username) + 1; len = strlen (my_username) + 1;
len = len < MAXNAMELEN ? len : MAXNAMELEN; len = len < MAXNAMELEN ? len : MAXNAMELEN;
@ -298,6 +314,8 @@ nm_exit_notify (void *data, int arg)
{ {
g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (DBUS_IS_G_PROXY (proxy));
g_message ("nm-ppp-plugin: (%s): cleaning up", __func__);
g_object_unref (proxy); g_object_unref (proxy);
proxy = NULL; proxy = NULL;
} }
@ -310,9 +328,14 @@ plugin_init (void)
g_type_init (); g_type_init ();
g_message ("nm-ppp-plugin: (%s): initializing", __func__);
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err); bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
if (!bus) { if (!bus) {
g_warning ("Couldn't connect to system bus: %s", err->message); g_warning ("nm-pppd-plugin: (%s): couldn't connect to system bus: (%d) %s",
__func__,
err ? err->code : -1,
err && err->message ? err->message : "(unknown)");
g_error_free (err); g_error_free (err);
return -1; return -1;
} }

View file

@ -91,51 +91,21 @@ nm_default_wired_connection_get_device (NMDefaultWiredConnection *wired)
return NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (wired)->device; return NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (wired)->device;
} }
static GByteArray *
dup_wired_mac (NMConnection *connection)
{
NMSettingWired *s_wired;
const GByteArray *mac;
GByteArray *dup;
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
if (!s_wired)
return NULL;
mac = nm_setting_wired_get_mac_address (s_wired);
if (!mac || (mac->len != ETH_ALEN))
return NULL;
dup = g_byte_array_sized_new (ETH_ALEN);
g_byte_array_append (dup, mac->data, ETH_ALEN);
return dup;
}
static gboolean static gboolean
update (NMSettingsConnectionInterface *connection, update (NMSettingsConnectionInterface *connection,
NMSettingsConnectionInterfaceUpdateFunc callback, NMSettingsConnectionInterfaceUpdateFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection); NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
GByteArray *mac;
gboolean failed = FALSE;
/* Ensure object stays alive across signal emission */ /* Keep the object alive over try-update since it might get removed
g_object_ref (self); * from the settings service there, but we still need it for the callback.
/* Save a copy of the current MAC address just in case the user
* changed it when updating the connection.
*/ */
mac = dup_wired_mac (NM_CONNECTION (self)); g_object_ref (connection);
g_signal_emit (self, signals[TRY_UPDATE], 0);
g_signal_emit (self, signals[TRY_UPDATE], 0, &failed); callback (connection, NULL, user_data);
if (!failed) g_object_unref (connection);
g_signal_emit (connection, signals[DELETED], 0, mac); return TRUE;
g_byte_array_free (mac, TRUE);
g_object_unref (self);
return parent_settings_connection_iface->update (connection, callback, user_data);
} }
static gboolean static gboolean
@ -144,16 +114,9 @@ do_delete (NMSettingsConnectionInterface *connection,
gpointer user_data) gpointer user_data)
{ {
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection); NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
GByteArray *mac; NMDefaultWiredConnectionPrivate *priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (connection);
g_object_ref (self);
mac = dup_wired_mac (NM_CONNECTION (self));
g_signal_emit (self, signals[DELETED], 0, mac);
g_byte_array_free (mac, TRUE);
g_object_unref (self);
g_signal_emit (self, signals[DELETED], 0, priv->mac);
return parent_settings_connection_iface->delete (connection, callback, user_data); return parent_settings_connection_iface->delete (connection, callback, user_data);
} }
@ -283,22 +246,6 @@ set_property (GObject *object, guint prop_id,
} }
} }
static gboolean
try_update_signal_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
const GValue *handler_return,
gpointer data)
{
if (g_value_get_boolean (handler_return)) {
g_value_set_boolean (return_accu, TRUE);
/* Stop */
return FALSE;
}
/* Continue if handler didn't fail */
return TRUE;
}
static void static void
nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass) nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass)
{ {
@ -341,9 +288,9 @@ nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass)
g_signal_new ("try-update", g_signal_new ("try-update",
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
0, try_update_signal_accumulator, NULL, 0, NULL, NULL,
_nm_marshal_BOOLEAN__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_BOOLEAN, 0); G_TYPE_NONE, 0);
/* The 'deleted' signal is used to signal intentional deletions (like /* The 'deleted' signal is used to signal intentional deletions (like
* updating or user-requested deletion) rather than using the * updating or user-requested deletion) rather than using the

View file

@ -1109,6 +1109,11 @@ cleanup:
NULL); NULL);
} }
static void
delete_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer user_data)
{
}
static gboolean static gboolean
default_wired_try_update (NMDefaultWiredConnection *wired, default_wired_try_update (NMDefaultWiredConnection *wired,
NMSysconfigSettings *self) NMSysconfigSettings *self)
@ -1129,6 +1134,10 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), FALSE); remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), FALSE);
if (add_new_connection (self, NM_CONNECTION (wired), &error)) { if (add_new_connection (self, NM_CONNECTION (wired), &error)) {
nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (wired),
delete_cb,
NULL);
g_object_set_data (G_OBJECT (nm_default_wired_connection_get_device (wired)), g_object_set_data (G_OBJECT (nm_default_wired_connection_get_device (wired)),
DEFAULT_WIRED_TAG, DEFAULT_WIRED_TAG,
NULL); NULL);

View file

@ -248,18 +248,16 @@ udev_device_added (SCPluginIfupdown *self, GUdevDevice *device)
* we want to either unmanage the device or lock it * we want to either unmanage the device or lock it
*/ */
exported = (NMIfupdownConnection *) g_hash_table_lookup (priv->iface_connections, iface); exported = (NMIfupdownConnection *) g_hash_table_lookup (priv->iface_connections, iface);
if (!exported) { if (!exported && !g_hash_table_lookup (priv->well_known_interfaces, iface)) {
PLUGIN_PRINT("SCPlugin-Ifupdown", PLUGIN_PRINT("SCPlugin-Ifupdown",
"device added (path: %s, iface: %s): no exported connection", path, iface); "device added (path: %s, iface: %s): no ifupdown configuration found.", path, iface);
return; return;
} }
if (!g_hash_table_lookup (priv->well_known_interfaces, iface))
return;
g_hash_table_insert (priv->well_known_ifaces, g_strdup (iface), g_object_ref (device)); g_hash_table_insert (priv->well_known_ifaces, g_strdup (iface), g_object_ref (device));
bind_device_to_connection (self, device, exported); if (exported)
bind_device_to_connection (self, device, exported);
if (ALWAYS_UNMANAGE || priv->unmanage_well_known) if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);