summaryrefslogtreecommitdiff
path: root/usr.sbin/npppd
diff options
context:
space:
mode:
authorMartin Natano <natano@cvs.openbsd.org>2016-05-28 07:00:19 +0000
committerMartin Natano <natano@cvs.openbsd.org>2016-05-28 07:00:19 +0000
commit59596971235614442a43728c1ab62a752151fec8 (patch)
treee061bc0bc07b97ee4d9ef5ff0f9abe018e8aa765 /usr.sbin/npppd
parent614a17274c6957a98145216f22c2f8ad64e48735 (diff)
Replace the /dev/bpf* open loop with a plain open("/dev/bpf0", ...).
ok deraadt jca
Diffstat (limited to 'usr.sbin/npppd')
-rw-r--r--usr.sbin/npppd/npppd/privsep.c4
-rw-r--r--usr.sbin/npppd/pppoe/pppoed.c23
2 files changed, 8 insertions, 19 deletions
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 <yasuoka@openbsd.org>
@@ -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 <sys/param.h> /* ALIGN */
#include <sys/types.h>
@@ -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]);