pub enum AncillaryData<'a> {
FileDescriptors(Cow<'a, [c_int]>),
Credentials {
pid: pid_t,
uid: uid_t,
gid: gid_t,
},
}
Expand description
Ancillary data to be sent through a Unix domain socket or read from an input buffer.
Ancillary data gives unique possibilities to Unix domain sockets which no other POSIX API has: passing file descriptors between two processes which do not have a parent-child relationship. It also can be used to transfer credentials of a process reliably.
Variants§
FileDescriptors(Cow<'a, [c_int]>)
One or more file descriptors to be sent.
Credentials
target_env="musleabi"
or target_env="musleabihf"
), or Emscripten, or Redox only.Credentials to be sent. The specified values are checked by the system when sent for all users except for the superuser – for senders, this means that the correct values need to be filled out, otherwise, an error is returned; for receivers, this means that the credentials are to be trusted for authentification purposes. For convenience, the credentials
function provides a value which is known to be valid when sent.
Implementations§
Source§impl<'a> AncillaryData<'a>
impl<'a> AncillaryData<'a>
Sourcepub const ENCODED_SIZE_OF_CREDENTIALS: usize = 28usize
pub const ENCODED_SIZE_OF_CREDENTIALS: usize = 28usize
The size of a single AncillaryData::Credentials
element when packed into the Unix ancillary data format. Useful for allocating a buffer when you expect to receive credentials.
Sourcepub const fn encoded_size_of_file_descriptors(num_descriptors: usize) -> usize
pub const fn encoded_size_of_file_descriptors(num_descriptors: usize) -> usize
Calculates the size of an AncillaryData::FileDescriptors
element with the specified amount of file descriptors when packed into the Unix ancillary data format. Useful for allocating a buffer when you expect to receive a specific amount of file descriptors.
Sourcepub fn clone_ref(&'a self) -> Self
pub fn clone_ref(&'a self) -> Self
Inexpensievly clones self
by borrowing the FileDescriptors
variant or copying the Credentials
variant.
Sourcepub fn encoded_size(&self) -> usize
pub fn encoded_size(&self) -> usize
Returns the size of an ancillary data element when packed into the Unix ancillary data format.
Sourcepub fn encode(
op: impl IntoIterator<Item = Self>,
) -> EncodedAncillaryData<'static>
pub fn encode( op: impl IntoIterator<Item = Self>, ) -> EncodedAncillaryData<'static>
Encodes the ancillary data into EncodedAncillaryData
which is ready to be sent via a Unix domain socket.
Source§impl AncillaryData<'static>
impl AncillaryData<'static>
Sourcepub fn credentials() -> Self
Available on Linux and (GNU or musl or target_env="musleabi"
or target_env="musleabihf"
), or Emscripten, or Redox only.
pub fn credentials() -> Self
target_env="musleabi"
or target_env="musleabihf"
), or Emscripten, or Redox only.Fetches the credentials of the process from the system and returns a value which can be safely sent to another process without the system complaining about an unauthorized attempt to impersonate another process/user/group.
If you want to send credentials to another process, this is usually the function you need to obtain the desired ancillary payload.
Trait Implementations§
Source§impl<'a> Clone for AncillaryData<'a>
impl<'a> Clone for AncillaryData<'a>
Source§fn clone(&self) -> AncillaryData<'a>
fn clone(&self) -> AncillaryData<'a>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more