From 59596971235614442a43728c1ab62a752151fec8 Mon Sep 17 00:00:00 2001 From: Martin Natano Date: Sat, 28 May 2016 07:00:19 +0000 Subject: Replace the /dev/bpf* open loop with a plain open("/dev/bpf0", ...). ok deraadt jca --- usr.sbin/npppd/npppd/privsep.c | 4 ++-- usr.sbin/npppd/pppoe/pppoed.c | 23 ++++++----------------- 2 files changed, 8 insertions(+), 19 deletions(-) (limited to 'usr.sbin/npppd') diff --git a/usr.sbin/npppd/npppd/privsep.c b/usr.sbin/npppd/npppd/privsep.c index 765dead5017..d248b724bed 100644 --- a/usr.sbin/npppd/npppd/privsep.c +++ b/usr.sbin/npppd/npppd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.21 2016/02/02 17:51:11 sthen Exp $ */ +/* $OpenBSD: privsep.c,v 1.22 2016/05/28 07:00:18 natano Exp $ */ /* * Copyright (c) 2010 Yasuoka Masahiko @@ -983,7 +983,7 @@ privsep_npppd_check_open(struct PRIVSEP_OPEN_ARG *arg) int readonly; } const allow_paths[] = { { NPPPD_DIR "/", 1, 1 }, - { "/dev/bpf", 1, 0 }, + { "/dev/bpf0", 0, 0 }, { "/etc/resolv.conf", 0, 1 }, { "/dev/tun", 1, 0 }, { "/dev/pppx", 1, 0 } diff --git a/usr.sbin/npppd/pppoe/pppoed.c b/usr.sbin/npppd/pppoe/pppoed.c index 10d73d517c6..ec4e90e496b 100644 --- a/usr.sbin/npppd/pppoe/pppoed.c +++ b/usr.sbin/npppd/pppoe/pppoed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pppoed.c,v 1.19 2015/12/17 08:09:20 tb Exp $ */ +/* $OpenBSD: pppoed.c,v 1.20 2016/05/28 07:00:18 natano Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ /**@file * This file provides the PPPoE(RFC2516) server(access concentrator) * implementaion. - * $Id: pppoed.c,v 1.19 2015/12/17 08:09:20 tb Exp $ + * $Id: pppoed.c,v 1.20 2016/05/28 07:00:18 natano Exp $ */ #include /* ALIGN */ #include @@ -202,9 +202,7 @@ pppoed_reload_listeners(pppoed *_this) static int pppoed_listener_start(pppoed_listener *_this, int restart) { - int i; int log_level; - char buf[BUFSIZ]; struct ifreq ifreq; int ival; int found; @@ -275,17 +273,8 @@ pppoed_listener_start(pppoed_listener *_this, int restart) goto fail; } - /* Open /dev/bpfXX */ - /* FIXME: /dev/bpf of NetBSD3.0 can simultaneity open */ - for (i = 0; i < 256; i++) { - snprintf(buf, sizeof(buf), "/dev/bpf%d", i); - if ((_this->bpf = priv_open(buf, O_RDWR)) >= 0) { - break; - } else if (errno == ENXIO || errno == ENOENT) - break; /* no more entries */ - } - if (_this->bpf < 0) { - pppoed_log(_pppoed, log_level, "Cannot open bpf"); + if ((_this->bpf = priv_open("/dev/bpf0", O_RDWR)) == -1) { + pppoed_log(_pppoed, log_level, "Cannot open bpf: %m"); goto fail; } @@ -327,9 +316,9 @@ pppoed_listener_start(pppoed_listener *_this, int restart) pppoed_io_event, _this); event_add(&_this->ev_bpf, NULL); - pppoed_log(_pppoed, LOG_INFO, "Listening on %s (PPPoE) [%s] using=%s " + pppoed_log(_pppoed, LOG_INFO, "Listening on %s (PPPoE) [%s] " "address=%02x:%02x:%02x:%02x:%02x:%02x", _this->listen_ifname, - _this->tun_name, buf, _this->ether_addr[0], _this->ether_addr[1], + _this->tun_name, _this->ether_addr[0], _this->ether_addr[1], _this->ether_addr[2], _this->ether_addr[3], _this->ether_addr[4], _this->ether_addr[5]); -- cgit v1.2.3