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">
<tp:docstring>
Design speed of the device.
Design speed of the device, in megabits/second (Mb/s).
</tp:docstring>
</property>

View file

@ -134,8 +134,10 @@ update (NMSettingsConnectionInterface *connection,
NMSettingsConnectionInterfaceUpdateFunc callback,
gpointer user_data)
{
g_object_ref (connection);
nm_settings_connection_interface_emit_updated (connection);
callback (connection, NULL, user_data);
g_object_unref (connection);
return TRUE;
}
@ -183,8 +185,10 @@ do_delete (NMSettingsConnectionInterface *connection,
NMSettingsConnectionInterfaceDeleteFunc callback,
gpointer user_data)
{
g_object_ref (connection);
g_signal_emit_by_name (connection, "removed");
callback (connection, NULL, user_data);
g_object_unref (connection);
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)) {
ShareRule *rule = (ShareRule *) iter->data;
char *envp[1] = { NULL };
char *argv[6];
char **argv;
char *cmd;
int status;
GError *error = NULL;
argv[0] = IPTABLES_PATH;
argv[1] = "--table";
argv[2] = rule->table;
cmd = g_strdup_printf ("%s --table %s %s %s",
IPTABLES_PATH,
rule->table,
shared ? "--insert" : "--delete",
rule->rule);
if (!cmd)
continue;
if (shared)
argv[3] = "--insert";
else
argv[3] = "--delete";
argv = g_strsplit (cmd, " ", 0);
if (argv && argv[0]) {
int status;
GError *error = NULL;
argv[4] = rule->rule;
argv[5] = NULL;
cmd = g_strjoinv (" ", argv);
nm_info ("Executing: %s", cmd);
nm_info ("Executing: %s", cmd);
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)) {
nm_info ("Error executing command: (%d) %s",
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);
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)) {
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));
if (argv)
g_strfreev (argv);
}
g_slist_free (list);

View file

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

View file

@ -109,6 +109,11 @@ nm_phasechange (void *data, int arg)
break;
}
g_message ("nm-ppp-plugin: (%s): status %d / phase '%s'",
__func__,
ppp_status,
ppp_phase);
if (ppp_status != NM_PPP_STATUS_UNKNOWN) {
dbus_g_proxy_call_no_reply (proxy, "SetState",
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_message ("nm-ppp-plugin: (%s): ip-up event", __func__);
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);
return;
}
@ -224,9 +231,11 @@ nm_ip_up (void *data, int arg)
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_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID,
G_TYPE_INVALID);
DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID,
G_TYPE_INVALID);
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_message ("nm-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__);
dbus_g_proxy_call (proxy, "NeedSecrets", &err,
G_TYPE_INVALID,
G_TYPE_STRING, &my_username,
G_TYPE_STRING, &my_password,
G_TYPE_INVALID);
G_TYPE_INVALID,
G_TYPE_STRING, &my_username,
G_TYPE_STRING, &my_password,
G_TYPE_INVALID);
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);
return -1;
}
g_message ("nm-ppp-plugin: (%s): got credentials from NetworkManager", __func__);
if (my_username) {
len = strlen (my_username) + 1;
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_message ("nm-ppp-plugin: (%s): cleaning up", __func__);
g_object_unref (proxy);
proxy = NULL;
}
@ -310,9 +328,14 @@ plugin_init (void)
g_type_init ();
g_message ("nm-ppp-plugin: (%s): initializing", __func__);
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
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);
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;
}
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
update (NMSettingsConnectionInterface *connection,
NMSettingsConnectionInterfaceUpdateFunc callback,
gpointer user_data)
{
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
GByteArray *mac;
gboolean failed = FALSE;
/* Ensure object stays alive across signal emission */
g_object_ref (self);
/* Save a copy of the current MAC address just in case the user
* changed it when updating the connection.
/* Keep the object alive over try-update since it might get removed
* from the settings service there, but we still need it for the callback.
*/
mac = dup_wired_mac (NM_CONNECTION (self));
g_signal_emit (self, signals[TRY_UPDATE], 0, &failed);
if (!failed)
g_signal_emit (connection, signals[DELETED], 0, mac);
g_byte_array_free (mac, TRUE);
g_object_unref (self);
return parent_settings_connection_iface->update (connection, callback, user_data);
g_object_ref (connection);
g_signal_emit (self, signals[TRY_UPDATE], 0);
callback (connection, NULL, user_data);
g_object_unref (connection);
return TRUE;
}
static gboolean
@ -144,16 +114,9 @@ do_delete (NMSettingsConnectionInterface *connection,
gpointer user_data)
{
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
GByteArray *mac;
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);
NMDefaultWiredConnectionPrivate *priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (connection);
g_signal_emit (self, signals[DELETED], 0, priv->mac);
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
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_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0, try_update_signal_accumulator, NULL,
_nm_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/* The 'deleted' signal is used to signal intentional deletions (like
* updating or user-requested deletion) rather than using the

View file

@ -1109,6 +1109,11 @@ cleanup:
NULL);
}
static void
delete_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer user_data)
{
}
static gboolean
default_wired_try_update (NMDefaultWiredConnection *wired,
NMSysconfigSettings *self)
@ -1129,6 +1134,10 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), FALSE);
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)),
DEFAULT_WIRED_TAG,
NULL);

View file

@ -248,18 +248,16 @@ udev_device_added (SCPluginIfupdown *self, GUdevDevice *device)
* we want to either unmanage the device or lock it
*/
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",
"device added (path: %s, iface: %s): no exported connection", path, iface);
"device added (path: %s, iface: %s): no ifupdown configuration found.", path, iface);
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));
bind_device_to_connection (self, device, exported);
if (exported)
bind_device_to_connection (self, device, exported);
if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);