pub enum ConnCredentials {
LinuxLike {
pid: NonZero<u32>,
euid: u32,
egid: u32,
},
MacOsLike {
euid: u32,
number_of_groups: u8,
groups: [u32; 16],
},
}Expand description
Credentials of the peer process when it called connect(), accept() or pair().
User and group IDs can be misleading if the peer side of the socket
has been transfered to another process or the peer has changed privileges.
PID is almost impossible to use correctly, as the peer might have
terminated and the pid reused, or as for euid, the socket has been sent
to another process (via fd-passing or forking).
What information is received varies from OS to OS:
- Linux, OpenBSD and NetBSD provides process ID, effective user ID and effective group id.
- macOS, FreeBSD and DragonFly BSD provides effective user ID and group memberships. (The first group is also the effective group ID.) FreeBSD 13+ will also provide process ID.
- Illumos and Solaris provide more than one could possibly want
(the
LinuxLikevariant is most likely returned).
Current limitations of this crate:
- Illumos and Solaris provides enough information to fill out both variants, but obviously only one can be returned.
- FreeBSD 13 will also provide pid, but this crate doesn’t detect that.
Variants§
Implementations§
Source§impl ConnCredentials
impl ConnCredentials
Sourcepub fn pid(&self) -> Option<NonZero<u32>>
pub fn pid(&self) -> Option<NonZero<u32>>
Get the process ID of the initial peer of a connection.
This is currently only available on Linux & Android, but will in the future also be available on OpenBSD and NetBSD, and possibly also FreeBSD and Solaris.
Sourcepub fn euid(&self) -> u32
pub fn euid(&self) -> u32
Get the effective user ID of the initial peer of a connection.
This is provided by any supported OS.
Sourcepub fn egid(&self) -> Option<u32>
pub fn egid(&self) -> Option<u32>
Get the effective group ID of the initial peer of a connection.
- On Linux, Android, OpenBSD and NetBSD,
egidfrom theLinuxLikevariant is returned. - On FreeBSD, DragonFly BSD, macOS & other Apple platforms,
groups[0]from theMacOsLikevariant is returned (except in the unlikely case thatnumber_of_groupsis zero).
Trait Implementations§
Source§impl Clone for ConnCredentials
impl Clone for ConnCredentials
Source§fn clone(&self) -> ConnCredentials
fn clone(&self) -> ConnCredentials
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConnCredentials
impl Debug for ConnCredentials
Source§impl PartialEq for ConnCredentials
impl PartialEq for ConnCredentials
Source§fn eq(&self, other: &ConnCredentials) -> bool
fn eq(&self, other: &ConnCredentials) -> bool
self and other values to be equal, and is used by ==.impl Copy for ConnCredentials
impl StructuralPartialEq for ConnCredentials
Auto Trait Implementations§
impl Freeze for ConnCredentials
impl RefUnwindSafe for ConnCredentials
impl Send for ConnCredentials
impl Sync for ConnCredentials
impl Unpin for ConnCredentials
impl UnsafeUnpin for ConnCredentials
impl UnwindSafe for ConnCredentials
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<A> DynCastExt for A
impl<A> DynCastExt for A
Source§fn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
fn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
Source§fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
Source§fn dyn_cast_adv<F, T>(
self,
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
fn dyn_cast_adv<F, T>( self, ) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
Source§fn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
fn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more