Expand description
Raw sockets from a helper, so the program using them holds no
capability. On Linux a raw Ethernet socket takes CAP_NET_RAW only to be
created; once open it works for whoever holds it. A program holding the
capability itself runs as one other programs may not look into: the
desktop portals refuse it file dialogs and screen sharing, and
debuggers and crash reports pass it by. So an app ships a tiny helper
of its own, the one file granted the capability, whose main calls
serve; the app starts it with Broker::start and installs
it, and every raw socket this crate opens comes from it from then on.
The helper takes requests on its standard input, a Unix socket the app
keeps the other end of: one octet, the kind of socket. It answers each
with four octets, zero or the error number, and on success the new
socket’s descriptor beside them. It makes nothing but packet sockets,
and stops when the app closes its end. A helper granted CAP_NET_ADMIN
as well makes Kind::Launch sockets, whose frames a card sends at
their times; one without answers EPERM for them.
Structs§
- Broker
- A running helper, and the socket to it. Dropping it stops the helper.
Enums§
- Kind
- A kind of packet socket.
Functions§
- install
- Has every raw socket this crate opens from now on come from
broker. Only the first broker installed is kept; a later one is dropped, its helper stopping. - installed
- Whether a helper is installed.
- needs_
capability - The program that must hold CAP_NET_RAW for raw sockets to open: the installed helper, or the one found that could not start, else this one. An app names it in the command it offers to grant the capability.
- open
- A packet socket of
kind: from the helper when one is installed, else made here. The error for one CAP_NET_RAW is missing for carriescrate::Blocked::RawCapability; aKind::Launchone refused for want of CAP_NET_ADMIN is PermissionDenied, naming that capability. For crates on this one opening sockets of their own, as avb-net does for AVTP streams. - serve
- The helper’s whole program: answers the requests on its standard input until the app closes it. Returns the exit code.
- use_
helper - Starts and installs the app’s helper,
name, once: found beside the running program, or beside the folder it is in, as for an example, or in one offolders, where packages put it. Later calls do nothing once one is installed, and try again after one failed, as after the helper is granted the capability.