1511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallAs with other systems using BPF, Mac OS X allows users with read access 2511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallto the BPF devices to capture packets with libpcap and allows users with 3511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallwrite access to the BPF devices to send packets with libpcap. 4511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 5511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallOn some systems that use BPF, the BPF devices live on the root file 6511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallsystem, and the permissions and/or ownership on those devices can be 7511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallchanged to give users other than root permission to read or write those 8511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldevices. 9511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 10511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallOn newer versions of FreeBSD, the BPF devices live on devfs, and devfs 11511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallcan be configured to set the permissions and/or ownership of those 12511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldevices to give users other than root permission to read or write those 13511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldevices. 14511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 15511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallOn Mac OS X, the BPF devices live on devfs, but the OS X version of 16511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldevfs is based on an older (non-default) FreeBSD devfs, and that version 17511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallof devfs cannot be configured to set the permissions and/or ownership of 18511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallthose devices. 19511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 20511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallTherefore, we supply: 21511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 22511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall a "startup item" for older versions of Mac OS X; 23511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 24511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall a launchd daemon for Tiger and later versions of Mac OS X; 25511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 26511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallBoth of them will change the ownership of the BPF devices so that the 27511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall"admin" group owns them, and will change the permission of the BPF 28511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldevices to rw-rw----, so that all users in the "admin" group - i.e., all 29511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallusers with "Allow user to administer this computer" turned on - have 30511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallboth read and write access to them. 31511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 32511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallThe startup item is in the ChmodBPF directory in the source tree. A 33511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall/Library/StartupItems directory should be created if it doesn't already 34511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallexist, and the ChmodBPF directory should be copied to the 35511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall/Library/StartupItems directory (copy the entire directory, so that 36511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallthere's a /Library/StartupItems/ChmodBPF directory, containing all the 37511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallfiles in the source tree's ChmodBPF directory; don't copy the individual 38511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallitems in that directory to /Library/StartupItems). The ChmodBPF 39511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldirectory, and all files under it, must be owned by root. Installing 40511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallthe files won't immediately cause the startup item to be executed; it 41511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallwill be executed on the next reboot. To change the permissions before 42511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallthe reboot, run 43511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 44511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall sudo SystemStarter start ChmodBPF 45511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 46511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallThe launchd daemon is the chmod_bpf script, plus the 47511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallorg.tcpdump.chmod_bpf.plist launchd plist file. chmod_bpf should be 48511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallinstalled in /usr/local/bin/chmod_bpf, and org.tcpdump.chmod_bpf.plist 49511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallshould be installed in /Library/LaunchDaemons. chmod_bpf, and 50511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallorg.tcpdump.chmod_bpf.plist, must be owned by root. Installing the 51511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallscript and plist file won't immediately cause the script to be executed; 52511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallit will be executed on the next reboot. To change the permissions 53511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallbefore the reboot, run 54511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 55511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall sudo /usr/local/bin/chmod_bpf 56511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 57511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallor 58511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 59511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall sudo launchctl load /Library/LaunchDaemons/org.tcpdump.chmod_bpf.plist 60511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 61511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallIf you want to give a particular user permission to access the BPF 62511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldevices, rather than giving all administrative users permission to 63511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallaccess them, you can have the ChmodBPF/ChmodBPF script change the 64511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallownership of /dev/bpf* without changing the permissions. If you want to 65511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallgive a particular user permission to read and write the BPF devices and 66511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallgive the administrative users permission to read but not write the BPF 67511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralldevices, you can have the script change the owner to that user, the 68511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallgroup to "admin", and the permissions to rw-r-----. Other possibilities 69511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallare left as an exercise for the reader. 70511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 71511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall(NOTE: due to a bug in Snow Leopard, if you change the permissions not 72511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallto grant write permission to everybody who should be allowed to capture 73511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgralltraffic, non-root users who cannot open the BPF devices for writing will 74511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrallnot be able to capture outgoing packets.) 75