Skip to main content

CallerPrincipal

Enum CallerPrincipal 

Source
pub enum CallerPrincipal {
    Uid(u32),
    VsockToken,
    Unattributed,
}
Expand description

Who asked, as opposed to what they were allowed to do.

CallerRole answers “was this permitted”; two members of sysknife-admin share a role and are indistinguishable by it. The principal answers “which account”, and is signed into the audit chain (crate::audit_chain::ChainIdentity::V3) so the trail can name the account rather than the class.

An account is not a person: a uid survives su, shared logins, and reuse after a user is deleted. See the attribution-strength limit in SECURITY.md.

Every rendering is scheme:value, and the scheme is signed along with the value on purpose, because the strength of the evidence differs. uid:1000 was attested by the kernel through SO_PEERCRED. token:vsock means a pre-shared secret was presented, and any holder of that file could have presented it. none:unattributed means the daemon could establish neither. A bare string would erase those distinctions.

Variants§

§

Uid(u32)

A Unix-socket peer whose uid the kernel supplied at connect().

§

VsockToken

A vsock connection authenticated by the pre-shared token. No uid exists on that path: the peer is in another kernel.

§

Unattributed

The daemon could not establish an account for this connection, either because SO_PEERCRED failed, or because it returned no usable pid, or because the peer is not representable in this daemon’s namespaces (the kernel then reports the overflow uid, which names nobody rather than the caller).

The connection is still handled, at Observer (the pre-existing fallback), and the row records that attribution failed instead of inventing a uid. A signed lie about who acted would be worse than a signed admission of ignorance.

Implementations§

Source§

impl CallerPrincipal

Source

pub fn scheme(&self) -> &'static str

Evidence class of this principal. Signed as the part before the colon.

Split out from Self::as_signed_str so a new variant cannot be added without declaring which class it belongs to, and so every_principal_renders_as_a_known_scheme can walk the whole set.

Source

pub fn as_signed_str(&self) -> String

The exact string signed into the chain and stored in caller_principal.

Never empty for any variant, which matters: ChainRow::identity treats an empty principal on a chain_version = 3 row as a missing one and reports the row broken. A variant that rendered empty would turn every honest row on an affected host into a false tamper report.

Source

pub fn claim(&self) -> PrincipalClaim

What this principal claims about who acted.

Exhaustive on self, so a new variant cannot be added without deciding here whether it names an account. Self::classify answers for a stored string by rebuilding the variant and then asking this.

Source

pub fn classify(stored: &str) -> PrincipalClaim

Read a stored caller_principal back into what it claims about who acted.

Deliberately the inverse of Self::as_signed_str and kept beside it, so the writer and the reader of this column cannot drift apart.

This is not a parse into Self for the caller’s use, and that is the point: it classifies strings this daemon may never have written. The census reads a database column rather than a live connection, so it meets rows that were tampered with, and rows signed by a newer daemon using a scheme this binary does not know. Both must come back as PrincipalClaim::Unrecognized instead of being credited as an account: a report that turns an unreadable principal into “someone was named” is the failure mode worth designing against.

Trait Implementations§

Source§

impl Clone for CallerPrincipal

Source§

fn clone(&self) -> CallerPrincipal

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CallerPrincipal

Source§

impl Debug for CallerPrincipal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CallerPrincipal

Source§

impl PartialEq for CallerPrincipal

Source§

fn eq(&self, other: &CallerPrincipal) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CallerPrincipal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more