README.macos 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. As with other systems using BPF, macOS allows users with read access to
  2. the BPF devices to capture packets with libpcap and allows users with
  3. write access to the BPF devices to send packets with libpcap.
  4. On some systems that use BPF, the BPF devices live on the root file
  5. system, and the permissions and/or ownership on those devices can be
  6. changed to give users other than root permission to read or write those
  7. devices.
  8. On newer versions of FreeBSD, the BPF devices live on devfs, and devfs
  9. can be configured to set the permissions and/or ownership of those
  10. devices to give users other than root permission to read or write those
  11. devices.
  12. On macOS, the BPF devices live on devfs, but the macOS version of devfs
  13. is based on an older (non-default) FreeBSD devfs, and that version of
  14. devfs cannot be configured to set the permissions and/or ownership of
  15. those devices.
  16. Therefore, we supply:
  17. a "startup item" for older versions of macOS;
  18. a launchd daemon for Tiger and later versions of macOS;
  19. Both of them will change the ownership of the BPF devices so that the
  20. "admin" group owns them, and will change the permission of the BPF
  21. devices to rw-rw----, so that all users in the "admin" group - i.e., all
  22. users with "Allow user to administer this computer" turned on - have
  23. both read and write access to them.
  24. The startup item is in the ChmodBPF directory in the source tree. A
  25. /Library/StartupItems directory should be created if it doesn't already
  26. exist, and the ChmodBPF directory should be copied to the
  27. /Library/StartupItems directory (copy the entire directory, so that
  28. there's a /Library/StartupItems/ChmodBPF directory, containing all the
  29. files in the source tree's ChmodBPF directory; don't copy the individual
  30. items in that directory to /Library/StartupItems). The ChmodBPF
  31. directory, and all files under it, must be owned by root. Installing
  32. the files won't immediately cause the startup item to be executed; it
  33. will be executed on the next reboot. To change the permissions before
  34. the reboot, run
  35. sudo SystemStarter start ChmodBPF
  36. The launchd daemon is the chmod_bpf script, plus the
  37. org.tcpdump.chmod_bpf.plist launchd plist file. chmod_bpf should be
  38. installed in /usr/local/bin/chmod_bpf, and org.tcpdump.chmod_bpf.plist
  39. should be installed in /Library/LaunchDaemons. chmod_bpf, and
  40. org.tcpdump.chmod_bpf.plist, must be owned by root. Installing the
  41. script and plist file won't immediately cause the script to be executed;
  42. it will be executed on the next reboot. To change the permissions
  43. before the reboot, run
  44. sudo /usr/local/bin/chmod_bpf
  45. or
  46. sudo launchctl load /Library/LaunchDaemons/org.tcpdump.chmod_bpf.plist
  47. If you want to give a particular user permission to access the BPF
  48. devices, rather than giving all administrative users permission to
  49. access them, you can have the ChmodBPF/ChmodBPF script change the
  50. ownership of /dev/bpf* without changing the permissions. If you want to
  51. give a particular user permission to read and write the BPF devices and
  52. give the administrative users permission to read but not write the BPF
  53. devices, you can have the script change the owner to that user, the
  54. group to "admin", and the permissions to rw-r-----. Other possibilities
  55. are left as an exercise for the reader.
  56. (NOTE: due to a bug in Snow Leopard, if you change the permissions not
  57. to grant write permission to everybody who should be allowed to capture
  58. traffic, non-root users who cannot open the BPF devices for writing will
  59. not be able to capture outgoing packets.)