Module Name: src
Committed By: nia
Date: Mon Jan 10 22:14:01 UTC 2022
Modified Files:
src/usr.sbin/sysinst: net.c
Log Message:
sysinst(8): Avoid asking Wi-Fi questions about non-Wi-Fi devices.
To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/sysinst/net.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/sysinst/net.c
diff -u src/usr.sbin/sysinst/net.c:1.37 src/usr.sbin/sysinst/net.c:1.38
--- src/usr.sbin/sysinst/net.c:1.37 Mon Jan 10 12:17:48 2022
+++ src/usr.sbin/sysinst/net.c Mon Jan 10 22:14:01 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: net.c,v 1.37 2022/01/10 12:17:48 nia Exp $ */
+/* $NetBSD: net.c,v 1.38 2022/01/10 22:14:01 nia Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -47,6 +47,7 @@
#include <net/if.h>
#include <net/if_media.h>
#include <netinet/in.h>
+#include <net80211/ieee80211_ioctl.h>
#include <err.h>
#include <stdio.h>
@@ -1137,6 +1138,23 @@ config_wlan(char *inter)
{
FILE *wpa_conf = NULL;
char wpa_cmd[256];
+ int sock;
+ struct ifreq ifr = {0};
+ struct ieee80211_nwid nwid = {0};
+
+ strlcpy(ifr.ifr_name, inter, sizeof(ifr.ifr_name));
+ ifr.ifr_data = &nwid;
+
+ sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sock == -1)
+ return 0;
+
+ /* skip non-WLAN devices */
+ if (ioctl(sock, SIOCG80211NWID, &ifr) == -1) {
+ close(sock);
+ return 0;
+ }
+ close(sock);
if (!file_mode_match(WPA_SUPPLICANT, S_IFREG))
return 0;