]> git.ipfire.org Git - thirdparty/mtr.git/commit
Fix interface binding by retaining CAP_NET_RAW
authorflu0r1ne <flu0r1ne@flu0r1ne.net>
Fri, 29 Sep 2023 21:28:19 +0000 (16:28 -0500)
committerflu0r1ne <flu0r1ne@flu0r1ne.net>
Fri, 29 Sep 2023 23:42:16 +0000 (18:42 -0500)
commit04d5abe3b5d9975a4e74f15ef86eae3b355ae729
tree97328bd3bf0a37139499308d7f98ea233bc1625a
parent1b519cde3e1e23b11a2ab94c43b0d10ae5a9e588
Fix interface binding by retaining CAP_NET_RAW

This commit addresses an issue where mtr would fail with EPERM because setting the
SO_BINDTODEVICE socket option requires the CAP_NET_RAW capability.

Changes:

- Refactor the code to abstract setting privileged socket options. This
  includes a common interface for setting capabilities depending on the
  platform (with or without LIBCAP).

- Replace direct setsockopt calls with the new abstracted function for
  setting both SO_MARK and SO_BINDTODEVICE.

- Update capability management in `drop_excess_capabilities` to retain
  CAP_NET_RAW when needed.
packet/construct_unix.c
packet/packet.c
packet/utils.h [new file with mode: 0644]