From 8da18c894e581a0cf8524f925e4ba6833d4e88be Mon Sep 17 00:00:00 2001 From: phessler Date: Sat, 8 Sep 2018 15:21:03 +0000 Subject: [PATCH] Enforce that "join" and "nwid" may not be used at the same time. OK stsp@ --- sbin/ifconfig/ifconfig.8 | 8 ++++++-- sbin/ifconfig/ifconfig.c | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 91f6d1c3e8f..392c79f0355 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.318 2018/08/29 13:47:19 jca Exp $ +.\" $OpenBSD: ifconfig.8,v 1.319 2018/09/08 15:21:03 phessler Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: August 29 2018 $ +.Dd $Mdocdate: September 8 2018 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -945,6 +945,8 @@ Any necessary or .Cm nwkey arguments should be specified on the same line. +May not be used with +.Cm nwid . .It Cm -join Ar id Remove the network with NWID .Ar id , @@ -991,6 +993,8 @@ Unlike auto-join networks, information about the network is not retained. The empty string allows the interface to connect to any available access points. +May not be used with +.Cm join . .It Cm -nwid Set the NWID to the empty string to allow the interface to connect to any available access point. diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index d14bb54e051..4ba1eb03d1c 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.376 2018/08/15 14:43:30 florian Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.377 2018/09/08 15:21:03 phessler Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -1670,6 +1670,10 @@ setifnwid(const char *val, int d) struct ieee80211_nwid nwid; int len; + if (strlen(joinname) != 0) { + errx(1, "nwid and join may not be used at the same time"); + } + if (d != 0) { /* no network id is especially desired */ memset(&nwid, 0, sizeof(nwid)); @@ -1693,6 +1697,10 @@ setifjoin(const char *val, int d) struct ieee80211_join join; int len; + if (strlen(nwidname) != 0) { + errx(1, "nwid and join may not be used at the same time"); + } + if (d != 0) { /* no network id is especially desired */ memset(&join, 0, sizeof(join)); -- 2.20.1