diff options
| author | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
| commit | 58f8be580039b0575b197b9573a1c92745d96d30 (patch) | |
| tree | 2c226233f623a0dcb529be0eb8cdf97e4a2ae0c0 /src/platform/wifi | |
| parent | 45cb5bb3c0e6edb887cf69b417fcaf7053814a9b (diff) | |
New upstream version 1.5.90 upstream/1.5.90
Diffstat (limited to 'src/platform/wifi')
| -rw-r--r-- | src/platform/wifi/wifi-utils-nl80211.c | 2 | ||||
| -rw-r--r-- | src/platform/wifi/wifi-utils-wext.c | 17 | ||||
| -rw-r--r-- | src/platform/wifi/wifi-utils.c | 28 | ||||
| -rw-r--r-- | src/platform/wifi/wifi-utils.h | 2 |
4 files changed, 18 insertions, 31 deletions
diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c index 2e222eb8..ac51678f 100644 --- a/src/platform/wifi/wifi-utils-nl80211.c +++ b/src/platform/wifi/wifi-utils-nl80211.c @@ -34,7 +34,7 @@ #include "wifi-utils-private.h" #include "wifi-utils-nl80211.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-utils.h" diff --git a/src/platform/wifi/wifi-utils-wext.c b/src/platform/wifi/wifi-utils-wext.c index d4ed86eb..af8cf2de 100644 --- a/src/platform/wifi/wifi-utils-wext.c +++ b/src/platform/wifi/wifi-utils-wext.c @@ -31,7 +31,7 @@ #include "wifi-utils-private.h" #include "wifi-utils-wext.h" #include "nm-utils.h" -#include "nm-platform-utils.h" +#include "platform/nm-platform-utils.h" /* Hacks necessary to #include wireless.h; yay for WEXT */ #ifndef __user @@ -369,7 +369,7 @@ wifi_wext_get_qual (WifiData *data) return wext_qual_to_percent (&stats.qual, &wext->max_qual); } -/*********************/ +/*****************************************************************************/ /* OLPC Mesh-only functions */ static guint32 @@ -441,7 +441,7 @@ wifi_wext_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len) return FALSE; } -/*********************/ +/*****************************************************************************/ static gboolean wext_can_scan (WifiDataWext *wext) @@ -662,8 +662,15 @@ wifi_wext_is_wifi (const char *iface) struct iwreq iwr; gboolean is_wifi = FALSE; - if (!nmp_utils_device_exists (iface)) - return FALSE; + /* performing an ioctl on a non-existing name may cause the automatic + * loading of kernel modules, which should be avoided. + * + * Usually, we should thus make sure that an inteface with this name + * exists. + * + * Note that wifi_wext_is_wifi() has only one caller which just verified + * that an interface with this name exists. + */ fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (fd >= 0) { diff --git a/src/platform/wifi/wifi-utils.c b/src/platform/wifi/wifi-utils.c index 2ce6eb77..b8da02c1 100644 --- a/src/platform/wifi/wifi-utils.c +++ b/src/platform/wifi/wifi-utils.c @@ -56,7 +56,7 @@ wifi_data_free (WifiData *data) g_free (data); } -/***************************************************************/ +/*****************************************************************************/ WifiData * wifi_utils_init (const char *iface, int ifindex, gboolean check_scan) @@ -183,39 +183,19 @@ wifi_utils_deinit (WifiData *data) } gboolean -wifi_utils_is_wifi (int ifindex, const char *ifname) +wifi_utils_is_wifi (int dirfd, const char *ifname) { - int fd_sysnet; - int fd_phy80211; - char ifname_verified[IFNAMSIZ]; + g_return_val_if_fail (dirfd >= 0, FALSE); - g_return_val_if_fail (ifindex > 0, FALSE); - - fd_sysnet = nmp_utils_sysctl_open_netdir (ifindex, ifname, ifname_verified); - if (fd_sysnet < 0) - return FALSE; - - /* there might have been a race and ifname might be wrong. Below for checking - * wext, use the possibly improved name that we just verified. */ - ifname = ifname_verified; - - fd_phy80211 = openat (fd_sysnet, "phy80211", O_CLOEXEC); - close (fd_sysnet); - - if (fd_phy80211 >= 0) { - close (fd_phy80211); + if (faccessat (dirfd, "phy80211", F_OK, 0) == 0) return TRUE; - } - #if HAVE_WEXT if (wifi_wext_is_wifi (ifname)) return TRUE; #endif - return FALSE; } - /* OLPC Mesh-only functions */ guint32 diff --git a/src/platform/wifi/wifi-utils.h b/src/platform/wifi/wifi-utils.h index 3dca2ac1..4fd5a80b 100644 --- a/src/platform/wifi/wifi-utils.h +++ b/src/platform/wifi/wifi-utils.h @@ -28,7 +28,7 @@ typedef struct WifiData WifiData; -gboolean wifi_utils_is_wifi (int ifindex, const char *ifname); +gboolean wifi_utils_is_wifi (int dirfd, const char *ifname); WifiData *wifi_utils_init (const char *iface, int ifindex, gboolean check_scan); |