DragonFly submit List (threaded) for 2004-10
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Allow write access to bpf in pcap_open()
Hello.
libpcap as shipped in DragonFly 1.1-current opens the descriptor with
O_RDONLY.
This is not consistent with most other operating systems. Linux doesn't
use bpf but it's possible to inject packets through the descriptor. Same
thing on Solaris. NetBSD and OpenBSD made local changes to pcap_open() a
long time ago to allow this.
It would be nice if the same change was introduced in DragonFly as well.
It would unbreak things like ucarp.
Trivial patch follows.
--- contrib/libpcap-0.8.3/pcap-bpf.c.orig 2004-10-17 21:40:36.000000000 +0200
+++ contrib/libpcap-0.8.3/pcap-bpf.c 2004-10-17 21:42:51.000000000 +0200
@@ -467,7 +467,9 @@
*/
do {
(void)snprintf(device, sizeof(device), "/dev/bpf%d", n++);
- fd = open(device, O_RDONLY);
+ fd = open(device, O_RDWR);
+ if (fd < 0 && errno == EACCES)
+ fd = open(device, O_RDONLY);
} while (fd < 0 && errno == EBUSY);
/*
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]