Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37650847
en ru br
Репозитории ALT
S:1.44.0-alt2
5.1: 0.7.3-alt2.git20101007.M51.1
4.1: 0.7.1-alt5.M41.5
www.altlinux.org/Changes

Группа :: Система/Настройка/Сеть
Пакет: NetworkManager

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: alt-set-iwconfig-essid.patch
Скачать


diff --git a/NetworkManager/src/nm-device-wifi.c b/NetworkManager/src/nm-device-wifi.c
index d9fa842..c0b90cb 100644
--- a/NetworkManager/src/nm-device-wifi.c
+++ b/NetworkManager/src/nm-device-wifi.c
@@ -161,6 +161,7 @@ struct _NMDeviceWifiPrivate {
 	guint32           failed_link_count;
 	guint             periodic_source_id;
 	guint             link_timeout_id;
+	guint             iwconfig_timeout_id;
 
 	/* Static options from driver */
 	guint8            we_version;
@@ -462,6 +463,7 @@ nm_device_wifi_init (NMDeviceWifi * self)
 	memset (&(priv->hw_addr), 0, sizeof (struct ether_addr));
 
 	nm_device_set_device_type (NM_DEVICE (self), NM_DEVICE_TYPE_WIFI);
+	priv->iwconfig_timeout_id = 0;
 }
 
 static guint32 iw_freq_to_uint32 (struct iw_freq *freq)
@@ -2186,6 +2188,65 @@ schedule_state_handler (NMDeviceWifi *self,
 	return TRUE;
 }
 
+#define IWCONFIG_PATH "/sbin/iwconfig"
+
+static void
+set_ssid_iwconfig(const char *iface, const char *ssid)
+{
+	GPtrArray *iwconfig_argv = NULL;
+	GPid	pid = -1;
+	GError *error = NULL;
+
+	iwconfig_argv = g_ptr_array_new ();
+	g_ptr_array_add (iwconfig_argv, (gpointer) IWCONFIG_PATH);
+
+	g_ptr_array_add (iwconfig_argv, (gpointer) iface);
+	g_ptr_array_add (iwconfig_argv, (gpointer) "essid");
+	g_ptr_array_add (iwconfig_argv, (gpointer) ssid);
+	g_ptr_array_add (iwconfig_argv, NULL);
+
+	if (!g_spawn_async (NULL, (char **) iwconfig_argv->pdata, NULL,
+			G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+			NULL, NULL, &pid, &error))
+	{
+		nm_warning ("iwconfig failed to start.  error: '%s'", error->message);
+		g_error_free (error);
+	}
+
+	g_ptr_array_free (iwconfig_argv, TRUE);
+}
+
+static void
+remove_iwconfig_timeout (NMDeviceWifi *self)
+{
+	NMDeviceWifiPrivate *priv;
+
+	g_return_if_fail (self != NULL);
+	priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
+
+	if (priv->iwconfig_timeout_id) {
+		g_source_remove (priv->iwconfig_timeout_id);
+		priv->iwconfig_timeout_id = 0;
+	}
+}
+
+/* if wpa_supplicant failed to scan call iwconfig with empty essid */
+static gboolean
+iwconfig_timeout_cb (gpointer user_data)
+{
+	NMDevice *              dev = NM_DEVICE (user_data);
+	NMDeviceWifi * self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
+
+	g_assert (dev);
+
+	priv->iwconfig_timeout_id = 0;
+
+	set_ssid_iwconfig(nm_device_get_iface(dev), "");
+
+	return FALSE;
+}
+
 static gboolean
 supplicant_iface_state_cb_handler (gpointer user_data)
 {
@@ -2208,6 +2269,9 @@ supplicant_iface_state_cb_handler (gpointer user_data)
 
 		/* Request a scan to get latest results */
 		cancel_pending_scan (self);
+		if (!priv->iwconfig_timeout_id) {
+			priv->iwconfig_timeout_id = g_timeout_add (10000, iwconfig_timeout_cb, self);
+		}
 		request_wireless_scan (self);
 	} else if (task->new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) {
 		cleanup_association_attempt (self, FALSE);
@@ -2236,7 +2300,6 @@ supplicant_iface_state_cb (NMSupplicantInterface * iface,
 	                        FALSE);
 }
 
-
 static gboolean
 supplicant_iface_connection_state_cb_handler (gpointer user_data)
 {
@@ -2743,6 +2806,8 @@ real_act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
 	NMConnection *connection;
 	GSList *iter;
 
+	remove_iwconfig_timeout (self);
+
 	/* If the user is trying to connect to an AP that NM doesn't yet know about
 	 * (hidden network or something), create an fake AP from the security
 	 * settings in the connection to use until the AP is recognized from the
@@ -2906,6 +2971,19 @@ real_act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
 	                       self);
 	priv->supplicant.iface_error_id = id;
 
+	{
+		const GByteArray *ssid;
+		char *printable_ssid = NULL;
+
+		ssid = nm_setting_wireless_get_ssid (s_wireless);
+		if (ssid)
+		{
+			printable_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
+			set_ssid_iwconfig (iface, printable_ssid);
+			g_free (printable_ssid);
+		}
+	}
+
 	if (!nm_supplicant_interface_set_config (priv->supplicant.iface, config)) {
 		nm_warning ("Activation (%s/wireless): couldn't send wireless "
 			"configuration to the supplicant.", iface);
@@ -3207,6 +3285,8 @@ nm_device_wifi_dispose (GObject *object)
 		priv->state_to_disconnected_id = 0;
 	}
 
+	remove_iwconfig_timeout (self);
+
 	G_OBJECT_CLASS (nm_device_wifi_parent_class)->dispose (object);
 }
 
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin