Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2019-09-14 Thread Stefan Sperling
On Fri, Sep 06, 2019 at 11:01:35PM +0200, Klemens Nanni wrote:
> Rebased diff that I just tested again on a X230 with athn(4) where I
> installed over an ESSID of the form "Wifi foo" just fine;  empty ESSIDs
> showed up as "" in the list, all others still look normal and could be
> chosen just fine.
> 
> The resulting hostname.athn0 contained
> 
>   nwid 'Wifi foo'
>   dhcp
> 
> I'd like to finally commit this so occasional installations over said
> wifi will just work.
> 
> OK?
> 

Yes please, thanks.

> 
> Index: install.sub
> ===
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> retrieving revision 1.1140
> diff -u -p -r1.1140 install.sub
> --- install.sub   21 Aug 2019 17:39:30 -  1.1140
> +++ install.sub   6 Sep 2019 20:19:51 -
> @@ -1171,10 +1171,9 @@ v6_config() {
>  
>  # Perform an 802.11 network scan on interface $1 and cache the result a file.
>  ieee80211_scan() {
> - # N.B. Skipping quoted nwid's for now.
>   [[ -f $WLANLIST ]] ||
>   ifconfig $1 scan |
> - sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
> + sed -n 's/^[[:space:]]*nwid \(.*\) chan [0-9]* bssid 
> \([[:xdigit:]:]*\).*/\1 (\2)/p' >$WLANLIST
>   cat $WLANLIST
>  }
>  
> @@ -1194,12 +1193,12 @@ ieee80211_config() {
>   ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
>   case "$resp" in
>   +([0-9]))
> - _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
> + _nwid=$(ieee80211_scan $_if |
> + sed -n ${resp}'{s/ ([[:xdigit:]:]*)$//p;q;}')
>   [[ -z $_nwid ]] && echo "There is no line $resp."
> + [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
> _nwid=${_nwid%\"}
>   ;;
> - \?) ieee80211_scan $_if |
> - sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
> .*$/   \1 (\2)/p' |
> - cat -n | more -c
> + \?) ieee80211_scan $_if | cat -n | more -c
>   ;;
>   *)  _nwid=$resp
>   ;;
> 



Re: once again: iwm(4) multi-frame rx + monitor mode

2019-09-14 Thread Stefan Sperling
On Fri, Sep 13, 2019 at 09:35:56PM +, Mikolaj Kucharski wrote:
> I've tested monitor mode and it seems to work:
> 
> $ ifconfig iwm0
> iwm0: flags=8847 mtu 1500
> lladdr 38:37:8b:XX:XX:XX
> index 1 priority 4 llprio 3
> groups: wlan egress
> media: IEEE802.11 autoselect monitor
> status: active
> ieee80211: nwid linksys chan 11 bssid 00:1d:7e:XX:XX:XX 29%
> 
> I've used kismet-201607R1p0 package and I could see networks and packets
> being reported. Testing with tcpdump(8) also showed traffic visible from
> various access points around:

Thanks for testing! I've never tried kismet myself, glad to see it works.
 
> # tcpdump -c 3 -y IEEE802_11_RADIO -ni iwm0  
> tcpdump: listening on iwm0, link-type IEEE802_11_RADIO
> 21:25:12.586606 802.11: beacon, ssid (net_092382), rates, ds, tim, xrates, 
> rsn, htcaps, 
> 21:25:12.653411 802.11: beacon, ssid (linksys), rates, ds, tim, erp, 47:1, 
> xrates, vendor, 
> 21:25:12.755803 802.11: beacon, ssid (linksys), rates, ds, tim, erp, 47:1, 
> xrates, vendor, 
> 
> I see in tcpdump output that all beacons are reported with chan 11,
> where I know some of the access points are not on channel 11. Not
> sure is this expected. Other than that, I don't see anything
> concerning.

This is likely cross-talk (several channels do overlap), or dual-beacons
deliberately sent by APs in 40 MHz mode on all channels they occupy.



Re: [PATCH] Avoid leftover temporary mount points when using -P (mfs)

2019-09-14 Thread Otto Moerbeek
On Sun, Sep 08, 2019 at 10:10:06PM -0300, Rafael Neves wrote:

> Updated patch: It includes Otto's requests and remove unnecessary
> unmount(dst, 0) from copy(), because the caller unmount tmpnode.
> While there, I adjusted the return value of gettmpmnt() to return 0
> on success, and changed the checks according.

If gettmpmnt() always retruns -1 in the MNT_RDONLY case. We already
saw that that case was a problem before, but now it's even more
obvious. We have to decide if we want to allow for the R/O /tmp or not
and adapt the code.  I'd love it it would work. For that three three
cases (error, dir created, dir not created) still should be
distinguished in gettmpmnt() and the callers should be adapted.

Copying from a filestsem (as opposed to a dir) would be a problem,
though, since for that we need two mountpoints.

-Otto

> 
> Regards,
> Rafael Neves
> 
> 
> Index: sbin/newfs/newfs.c
> ===
> RCS file: /cvs/src/sbin/newfs/newfs.c,v
> retrieving revision 1.112
> diff -u -p -r1.112 newfs.c
> --- sbin/newfs/newfs.c28 Jun 2019 13:32:45 -  1.112
> +++ sbin/newfs/newfs.c8 Sep 2019 22:49:11 -
> @@ -147,7 +147,7 @@ struct disklabel *getdisklabel(char *, i
>  static void waitformount(char *, pid_t);
>  static int do_exec(const char *, const char *, char *const[]);
>  static int isdir(const char *);
> -static void copy(char *, char *);
> +static int copy(char *, char *);
>  static int gettmpmnt(char *, size_t);
>  #endif
>  
> @@ -515,8 +515,9 @@ havelabel:
>   if (mfs) {
>   struct mfs_args args;
>   char tmpnode[PATH_MAX];
> + int ret = 0;
>  
> - if (pop != NULL && gettmpmnt(tmpnode, sizeof(tmpnode)) == 0)
> + if (pop != NULL && gettmpmnt(tmpnode, sizeof(tmpnode)) != 0)
>   errx(1, "Cannot create tmp mountpoint for -P");
>   memset(, 0, sizeof(args));
>   args.base = membase;
> @@ -537,11 +538,15 @@ havelabel:
>   default:
>   if (pop != NULL) {
>   waitformount(tmpnode, pid);
> - copy(pop, tmpnode);
> + ret = copy(pop, tmpnode);
>   unmount(tmpnode, 0);
>   rmdir(tmpnode);
>   }
>   waitformount(node, pid);
> + if (ret != 0) {
> + unmount(node, 0);
> + exit(1);
> + }
>   exit(0);
>   /* NOTREACHED */
>   }
> @@ -740,48 +745,55 @@ isdir(const char *path)
>  {
>   struct stat st;
>  
> - if (stat(path, ) != 0)
> - err(1, "cannot stat %s", path);
> - if (!S_ISDIR(st.st_mode) && !S_ISBLK(st.st_mode))
> - errx(1, "%s: not a dir or a block device", path);
> + if (stat(path, ) != 0) {
> + warn("cannot stat %s", path);
> + return (-1);
> + }
> + if (!S_ISDIR(st.st_mode) && !S_ISBLK(st.st_mode)) {
> + warn("%s: not a dir or a block device", path);
> + return  (-1);
> + }
>   return (S_ISDIR(st.st_mode));
>  }
>  
> -static void
> +static int 
>  copy(char *src, char *dst)
>  {
> - int ret, dir, created = 0;
> + int ret, dir;
>   struct ufs_args mount_args;
>   char mountpoint[MNAMELEN];
>   char *const argv[] = { "pax", "-rw", "-pe", ".", dst, NULL } ;
>  
> - dir = isdir(src);
> + if ((dir = isdir(src)) == -1)
> + return (-1);
> +
>   if (dir)
>   strlcpy(mountpoint, src, sizeof(mountpoint));
>   else {
> - created = gettmpmnt(mountpoint, sizeof(mountpoint));
> + if (gettmpmnt(mountpoint, sizeof(mountpoint)) != 0)
> + return (-1);
> +
>   memset(_args, 0, sizeof(mount_args));
>   mount_args.fspec = src;
>   ret = mount(MOUNT_FFS, mountpoint, MNT_RDONLY, _args);
>   if (ret != 0) {
>   int saved_errno = errno;
> - if (created && rmdir(mountpoint) != 0)
> + if (rmdir(mountpoint) != 0)
>   warn("rmdir %s", mountpoint);
> - if (unmount(dst, 0) != 0)
> - warn("unmount %s", dst);
> - errc(1, saved_errno, "mount %s %s", src, mountpoint);
> + warnc(saved_errno, "mount %s %s", src, mountpoint);
> + return (-1);
>   }
>   }
>   ret = do_exec(mountpoint, "/bin/pax", argv);
>   if (!dir && unmount(mountpoint, 0) != 0)
>   warn("unmount %s", mountpoint);
> - if (created && rmdir(mountpoint) != 0)
> + if (!dir && rmdir(mountpoint) != 0)
>   warn("rmdir %s", mountpoint);
> 

Re: PATCH: smtpd: don't strcmp() NULL in mta_relay_cmp()

2019-09-14 Thread Gilles Chehade
On Fri, Sep 13, 2019 at 09:34:33PM +0200, Caspar Schutijser wrote:
> Hi,
> 

Hi,


> smtpd crashed on one of my machines. I attempted to start it again but
> it crashed again after a few seconds.
> 
> [...]
> 
> So I think the problem is that b->backupname is passed to strcmp()
> without checking whether b->backupname != NULL. The diff below adds
> such a check, in line with other string comparisons that are performed
> in mta_relay_cmp(). In the same function, I think the same problem
> exists while comparing a->authlabel and b->authlabel so I added a
> similar check there.
> 
> I'd like you to double-check whether the fix is indeed correct.
> 

Yes, your understanding of the problem is correct and your diff also, so
I committed it a minute ago, thanks !

I'm curious about what configuration allowed you to hit this though, can
you share your smtpd.conf with me ?

-- 
Gilles Chehade @poolpOrg

https://www.poolp.orgpatreon: https://www.patreon.com/gilles