]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Try all drivers by default
authorKees Cook <kees@ubuntu.com>
Tue, 12 Oct 2021 18:28:31 +0000 (11:28 -0700)
committerJouni Malinen <j@w1.fi>
Fri, 15 Oct 2021 20:33:11 +0000 (23:33 +0300)
Some distros carry patches to specify driver fallback, but only in
specific conditions (e.g. the systemd service definition[1]). This leaves
other wpa_supplicant instances needing to define fallback themselves,
which leads to places where wpa_supplicant thinks it can't find a
driver[2]. Instead, when -D is not specified, have wpa_supplicant try
all the drivers it was built with in an attempt to find a working one
instead of just giving up if the first doesn't work.

[1] https://salsa.debian.org/debian/wpa/-/blob/debian/unstable/debian/patches/networkd-driver-fallback.patch
[2] https://bugs.launchpad.net/netplan/+bug/1814012

Signed-off-by: Kees Cook <kees@ubuntu.com>
wpa_supplicant/wpa_supplicant.c

index 0f9db267fe9d87cbe153abe3f3c08b4f6608cac3..8edf87c46342c28fd498d23be17ac30f66a323c2 100644 (file)
@@ -4812,8 +4812,13 @@ static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
        }
 
        if (name == NULL) {
-               /* default to first driver in the list */
-               return select_driver(wpa_s, 0);
+               /* Default to first successful driver in the list */
+               for (i = 0; wpa_drivers[i]; i++) {
+                       if (select_driver(wpa_s, i) == 0)
+                               return 0;
+               }
+               /* Drivers have each reported failure, so no wpa_msg() here. */
+               return -1;
        }
 
        do {