diff options
Diffstat (limited to 'debian')
| -rw-r--r-- | debian/patches/Force-online-state-with-unmanaged-devices.patch | 258 |
1 files changed, 129 insertions, 129 deletions
diff --git a/debian/patches/Force-online-state-with-unmanaged-devices.patch b/debian/patches/Force-online-state-with-unmanaged-devices.patch index 8c031b1c..13368ecc 100644 --- a/debian/patches/Force-online-state-with-unmanaged-devices.patch +++ b/debian/patches/Force-online-state-with-unmanaged-devices.patch @@ -12,7 +12,7 @@ Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=512286 1 file changed, 115 insertions(+) diff --git a/src/nm-manager.c b/src/nm-manager.c -index 778e3b9..d0cc527 100644 +index a04ca0e..ddb9094 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -52,6 +52,8 @@ @@ -24,165 +24,165 @@ index 778e3b9..d0cc527 100644 /*****************************************************************************/ typedef struct { -@@ -187,6 +189,10 @@ typedef struct { - GFileMonitor *fw_monitor; - guint fw_changed_id; +@@ -186,6 +188,10 @@ typedef struct { + GFileMonitor *fw_monitor; + guint fw_changed_id; -+ /* ifupdown state file monitor */ -+ GFileMonitor *ifstate_monitor; -+ gboolean ifstate_force_online; ++ /* ifupdown state file monitor */ ++ GFileMonitor *ifstate_monitor; ++ gboolean ifstate_force_online; + - guint timestamp_update_id; + guint timestamp_update_id; - guint devices_inited_id; -@@ -1430,6 +1436,27 @@ find_best_device_state (NMManager *manager) - return best_state; + guint devices_inited_id; +@@ -1433,6 +1439,27 @@ find_best_device_state(NMManager *manager) + return best_state; } +static NMState -+find_unmanaged_state (NMManager *self, NMState current_state) ++find_unmanaged_state(NMManager *self, NMState current_state) +{ -+ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); -+ NMState new_state = current_state; -+ NMDevice *device; -+ -+ c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) { -+ NMDeviceState state = nm_device_get_state (device); -+ -+ if (state == NM_DEVICE_STATE_UNMANAGED) { -+ const char *iface = nm_device_get_ip_iface (device); -+ if (priv->ifstate_force_online) { -+ new_state = NM_STATE_CONNECTED_GLOBAL; -+ nm_log_dbg (LOGD_CORE, "Unmanaged device found: %s; state CONNECTED forced.", iface); -+ } -+ } -+ } -+ return new_state; ++ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); ++ NMState new_state = current_state; ++ NMDevice *device; ++ ++ c_list_for_each_entry(device, &priv->devices_lst_head, devices_lst) { ++ NMDeviceState state = nm_device_get_state(device); ++ ++ if (state == NM_DEVICE_STATE_UNMANAGED) { ++ const char *iface = nm_device_get_ip_iface(device); ++ if (priv->ifstate_force_online) { ++ new_state = NM_STATE_CONNECTED_GLOBAL; ++ nm_log_dbg(LOGD_CORE, "Unmanaged device found: %s; state CONNECTED forced.", iface); ++ } ++ } ++ } ++ return new_state; +} + static void - nm_manager_update_metered (NMManager *self) + nm_manager_update_metered(NMManager *self) { -@@ -1476,6 +1503,9 @@ nm_manager_update_state (NMManager *self) - else - new_state = find_best_device_state (self); +@@ -1479,6 +1506,9 @@ nm_manager_update_state(NMManager *self) + else + new_state = find_best_device_state(self); -+ if (new_state != NM_STATE_CONNECTED_GLOBAL) -+ new_state = find_unmanaged_state (self, new_state); -+ - if ( new_state >= NM_STATE_CONNECTED_LOCAL - && priv->connectivity_state == NM_CONNECTIVITY_FULL) { - new_state = NM_STATE_CONNECTED_GLOBAL; -@@ -6566,6 +6596,62 @@ impl_manager_check_connectivity (NMDBusObject *obj, - nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE); ++ if (new_state != NM_STATE_CONNECTED_GLOBAL) ++ new_state = find_unmanaged_state(self, new_state); ++ + if (new_state >= NM_STATE_CONNECTED_LOCAL && priv->connectivity_state == NM_CONNECTIVITY_FULL) { + new_state = NM_STATE_CONNECTED_GLOBAL; + } +@@ -6581,6 +6611,62 @@ impl_manager_set_logging(NMDBusObject * obj, + g_dbus_method_invocation_return_value(invocation, NULL); } +static void -+check_ifstate_file (gpointer user_data) ++check_ifstate_file(gpointer user_data) +{ -+ NMManager *self = NM_MANAGER (user_data); -+ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); -+ GIOChannel *channel; -+ gchar *line; -+ gboolean online = FALSE; -+ -+ channel = g_io_channel_new_file (IFUPDOWN_STATE_FILE, "r", NULL); -+ if (!channel) { -+ nm_log_warn (LOGD_CORE, "Error: failed to open %s", IFUPDOWN_STATE_FILE); -+ return; -+ } -+ -+ while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL) -+ != G_IO_STATUS_EOF && !online) { -+ g_strstrip (line); -+ if (strlen (line) > 0 && g_strcmp0 (line, "lo=lo") != 0) { -+ online = TRUE; -+ } -+ g_free (line); -+ } -+ -+ g_io_channel_shutdown (channel, FALSE, NULL); -+ g_io_channel_unref (channel); -+ -+ if (priv->ifstate_force_online != online) { -+ priv->ifstate_force_online = online; -+ nm_manager_update_state (self); -+ } ++ NMManager *self = NM_MANAGER(user_data); ++ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); ++ GIOChannel *channel; ++ gchar *line; ++ gboolean online = FALSE; ++ ++ channel = g_io_channel_new_file(IFUPDOWN_STATE_FILE, "r", NULL); ++ if (!channel) { ++ nm_log_warn(LOGD_CORE, "Error: failed to open %s", IFUPDOWN_STATE_FILE); ++ return; ++ } ++ ++ while (g_io_channel_read_line(channel, &line, NULL, NULL, NULL) ++ != G_IO_STATUS_EOF && !online) { ++ g_strstrip(line); ++ if (strlen(line) > 0 && g_strcmp0(line, "lo=lo") != 0) { ++ online = TRUE; ++ } ++ g_free(line); ++ } ++ ++ g_io_channel_shutdown(channel, FALSE, NULL); ++ g_io_channel_unref(channel); ++ ++ if (priv->ifstate_force_online != online) { ++ priv->ifstate_force_online = online; ++ nm_manager_update_state(self); ++ } +} + +static void -+ifstate_file_changed (GFileMonitor *monitor, -+ GFile *file, -+ GFile *other_file, -+ GFileMonitorEvent event_type, -+ gpointer user_data) ++ifstate_file_changed(GFileMonitor *monitor, ++ GFile *file, ++ GFile *other_file, ++ GFileMonitorEvent event_type, ++ gpointer user_data) +{ -+ switch (event_type) { -+// case G_FILE_MONITOR_EVENT_CREATED: ++ switch (event_type) { ++// case G_FILE_MONITOR_EVENT_CREATED: +//#if GLIB_CHECK_VERSION(2,23,4) -+// case G_FILE_MONITOR_EVENT_MOVED: ++// case G_FILE_MONITOR_EVENT_MOVED: +//#endif -+// case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: -+ case G_FILE_MONITOR_EVENT_CHANGED: -+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: -+ nm_log_dbg (LOGD_CORE, "ifupdown state file %s was changed", IFUPDOWN_STATE_FILE); -+ check_ifstate_file (user_data); -+ break; -+ default: -+ break; -+ } ++// case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: ++ case G_FILE_MONITOR_EVENT_CHANGED: ++ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: ++ nm_log_dbg(LOGD_CORE, "ifupdown state file %s was changed", IFUPDOWN_STATE_FILE); ++ check_ifstate_file(user_data); ++ break; ++ default: ++ break; ++ } +} + static void - start_factory (NMDeviceFactory *factory, gpointer user_data) - { -@@ -6749,6 +6835,9 @@ nm_manager_start (NMManager *self, GError **error) - nm_clear_g_source (&priv->devices_inited_id); - priv->devices_inited_id = g_idle_add_full (G_PRIORITY_LOW + 10, devices_inited_cb, self, NULL); + impl_manager_get_logging(NMDBusObject * obj, + const NMDBusInterfaceInfoExtended *interface_info, +@@ -6910,6 +6996,9 @@ nm_manager_start(NMManager *self, GError **error) + nm_clear_g_source(&priv->devices_inited_id); + priv->devices_inited_id = g_idle_add_full(G_PRIORITY_LOW + 10, devices_inited_cb, self, NULL); -+ /* Trigger ifupdown state file check */ -+ check_ifstate_file (self); ++ /* Trigger ifupdown state file check */ ++ check_ifstate_file(self); + - return TRUE; + return TRUE; } -@@ -7603,6 +7692,22 @@ nm_manager_init (NMManager *self) - KERNEL_FIRMWARE_DIR); - } - -+ /* Monitor the ifupdown state file */ -+ file = g_file_new_for_path (IFUPDOWN_STATE_FILE); -+ priv->ifstate_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); -+ g_object_unref (file); -+ -+ if (priv->ifstate_monitor) { -+ g_signal_connect (priv->ifstate_monitor, "changed", -+ G_CALLBACK (ifstate_file_changed), -+ self); -+ nm_log_info (LOGD_CORE, "monitoring ifupdown state file '%s'.", -+ IFUPDOWN_STATE_FILE); -+ } else { -+ nm_log_warn (LOGD_CORE, "failed to monitor ifupdown state file '%s'.", -+ IFUPDOWN_STATE_FILE); -+ } -+ - /* Update timestamps in active connections */ - priv->timestamp_update_id = g_timeout_add_seconds (300, (GSourceFunc) periodic_update_active_connection_timestamps, self); +@@ -7789,6 +7878,22 @@ nm_manager_init(NMManager *self) + _LOGW(LOGD_CORE, "failed to monitor kernel firmware directory '%s'.", KERNEL_FIRMWARE_DIR); + } -@@ -7882,6 +7987,16 @@ dispose (GObject *object) - g_clear_object (&priv->fw_monitor); - } ++ /* Monitor the ifupdown state file */ ++ file = g_file_new_for_path(IFUPDOWN_STATE_FILE); ++ priv->ifstate_monitor = g_file_monitor_file(file, G_FILE_MONITOR_NONE, NULL, NULL); ++ g_object_unref(file); ++ ++ if (priv->ifstate_monitor) { ++ g_signal_connect(priv->ifstate_monitor, "changed", ++ G_CALLBACK(ifstate_file_changed), ++ self); ++ nm_log_info(LOGD_CORE, "monitoring ifupdown state file '%s'.", ++ IFUPDOWN_STATE_FILE); ++ } else { ++ nm_log_warn(LOGD_CORE, "failed to monitor ifupdown state file '%s'.", ++ IFUPDOWN_STATE_FILE); ++ } ++ + /* Update timestamps in active connections */ + priv->timestamp_update_id = + g_timeout_add_seconds(300, +@@ -8072,6 +8177,16 @@ dispose(GObject *object) + g_clear_object(&priv->fw_monitor); + } -+ if (priv->ifstate_monitor) { -+ g_signal_handlers_disconnect_by_func (priv->ifstate_monitor, ifstate_file_changed, self); ++ if (priv->ifstate_monitor) { ++ g_signal_handlers_disconnect_by_func(priv->ifstate_monitor, ifstate_file_changed, self); + -+ if (priv->ifstate_force_online) -+ g_source_remove (priv->ifstate_force_online); ++ if (priv->ifstate_force_online) ++ g_source_remove(priv->ifstate_force_online); + -+ g_file_monitor_cancel (priv->ifstate_monitor); -+ g_clear_object (&priv->ifstate_monitor); -+ } ++ g_file_monitor_cancel(priv->ifstate_monitor); ++ g_clear_object(&priv->ifstate_monitor); ++ } + - if (priv->rfkill_mgr) { - g_signal_handlers_disconnect_by_func (priv->rfkill_mgr, rfkill_manager_rfkill_changed_cb, self); - g_clear_object (&priv->rfkill_mgr); + if (priv->rfkill_mgr) { + g_signal_handlers_disconnect_by_func(priv->rfkill_mgr, + rfkill_manager_rfkill_changed_cb, |