xref: /netbsd-src/external/bsd/libpcap/dist/doc/README.macos (revision 9185e895f1b94e89d9c29ea1e64a7aa34809f403)
1*9185e895SchristosAs with other systems using BPF, macOS allows users with read access to
2*9185e895Schristosthe BPF devices to capture packets with libpcap and allows users with
3*9185e895Schristoswrite access to the BPF devices to send packets with libpcap.
4*9185e895Schristos
5*9185e895SchristosOn some systems that use BPF, the BPF devices live on the root file
6*9185e895Schristossystem, and the permissions and/or ownership on those devices can be
7*9185e895Schristoschanged to give users other than root permission to read or write those
8*9185e895Schristosdevices.
9*9185e895Schristos
10*9185e895SchristosOn newer versions of FreeBSD, the BPF devices live on devfs, and devfs
11*9185e895Schristoscan be configured to set the permissions and/or ownership of those
12*9185e895Schristosdevices to give users other than root permission to read or write those
13*9185e895Schristosdevices.
14*9185e895Schristos
15*9185e895SchristosOn macOS, the BPF devices live on devfs, but the macOS version of devfs
16*9185e895Schristosis based on an older (non-default) FreeBSD devfs, and that version of
17*9185e895Schristosdevfs cannot be configured to set the permissions and/or ownership of
18*9185e895Schristosthose devices.
19*9185e895Schristos
20*9185e895SchristosTherefore, we supply:
21*9185e895Schristos
22*9185e895Schristos	a "startup item" for older versions of macOS;
23*9185e895Schristos
24*9185e895Schristos	a launchd daemon for Tiger and later versions of macOS;
25*9185e895Schristos
26*9185e895SchristosBoth of them will change the ownership of the BPF devices so that the
27*9185e895Schristos"admin" group owns them, and will change the permission of the BPF
28*9185e895Schristosdevices to rw-rw----, so that all users in the "admin" group - i.e., all
29*9185e895Schristosusers with "Allow user to administer this computer" turned on - have
30*9185e895Schristosboth read and write access to them.
31*9185e895Schristos
32*9185e895SchristosThe startup item is in the ChmodBPF directory in the source tree.  A
33*9185e895Schristos/Library/StartupItems directory should be created if it doesn't already
34*9185e895Schristosexist, and the ChmodBPF directory should be copied to the
35*9185e895Schristos/Library/StartupItems directory (copy the entire directory, so that
36*9185e895Schristosthere's a /Library/StartupItems/ChmodBPF directory, containing all the
37*9185e895Schristosfiles in the source tree's ChmodBPF directory; don't copy the individual
38*9185e895Schristositems in that directory to /Library/StartupItems).  The ChmodBPF
39*9185e895Schristosdirectory, and all files under it, must be owned by root.  Installing
40*9185e895Schristosthe files won't immediately cause the startup item to be executed; it
41*9185e895Schristoswill be executed on the next reboot.  To change the permissions before
42*9185e895Schristosthe reboot, run
43*9185e895Schristos
44*9185e895Schristos	sudo SystemStarter start ChmodBPF
45*9185e895Schristos
46*9185e895SchristosThe launchd daemon is the chmod_bpf script, plus the
47*9185e895Schristosorg.tcpdump.chmod_bpf.plist launchd plist file.  chmod_bpf should be
48*9185e895Schristosinstalled in /usr/local/bin/chmod_bpf, and org.tcpdump.chmod_bpf.plist
49*9185e895Schristosshould be installed in /Library/LaunchDaemons.  chmod_bpf, and
50*9185e895Schristosorg.tcpdump.chmod_bpf.plist, must be owned by root.  Installing the
51*9185e895Schristosscript and plist file won't immediately cause the script to be executed;
52*9185e895Schristosit will be executed on the next reboot.  To change the permissions
53*9185e895Schristosbefore the reboot, run
54*9185e895Schristos
55*9185e895Schristos	sudo /usr/local/bin/chmod_bpf
56*9185e895Schristos
57*9185e895Schristosor
58*9185e895Schristos
59*9185e895Schristos	sudo launchctl load /Library/LaunchDaemons/org.tcpdump.chmod_bpf.plist
60*9185e895Schristos
61*9185e895SchristosIf you want to give a particular user permission to access the BPF
62*9185e895Schristosdevices, rather than giving all administrative users permission to
63*9185e895Schristosaccess them, you can have the ChmodBPF/ChmodBPF script change the
64*9185e895Schristosownership of /dev/bpf* without changing the permissions.  If you want to
65*9185e895Schristosgive a particular user permission to read and write the BPF devices and
66*9185e895Schristosgive the administrative users permission to read but not write the BPF
67*9185e895Schristosdevices, you can have the script change the owner to that user, the
68*9185e895Schristosgroup to "admin", and the permissions to rw-r-----.  Other possibilities
69*9185e895Schristosare left as an exercise for the reader.
70*9185e895Schristos
71*9185e895Schristos(NOTE: due to a bug in Snow Leopard, if you change the permissions not
72*9185e895Schristosto grant write permission to everybody who should be allowed to capture
73*9185e895Schristostraffic, non-root users who cannot open the BPF devices for writing will
74*9185e895Schristosnot be able to capture outgoing packets.)
75