Skip to main content

ArmorCache

Struct ArmorCache 

Source
pub struct ArmorCache { /* private fields */ }
Expand description

A FILE: credential cache holding the machine (armor) ticket.

Implementations§

Source§

impl ArmorCache

Source

pub fn new(path: impl Into<PathBuf>) -> Self

Source

pub fn path(&self) -> &Path

Source

pub fn cache_name(&self) -> String

The FILE:<path> form kinit/klist/kdestroy expect.

Source

pub fn is_valid(&self, tools: &Tools) -> bool

Does the cache exist and hold a non-expired ticket? (klist -s)

Source

pub fn renew(&self, tools: &Tools, identity: &MachineIdentity) -> Result<()>

Renew the existing ticket in place (kinit -R).

No keytab and no fresh authentication needed. Renewal only works while the current ticket is still unexpired (AD machine tickets live ~10 h); the ~7-day renewable lifetime is the outer bound reachable via repeated pre-expiry renewals, not a grace period after expiry — an expired ticket always needs Self::mint. Use Self::ensure to get the fallback automatically.

The expected principal is passed explicitly, so a cache that somehow holds a different principal fails here (“Matching credential not found”) instead of being silently renewed as the wrong identity.

Source

pub fn mint(&self, tools: &Tools, identity: &MachineIdentity) -> Result<()>

Mint a brand-new ticket from the machine keytab (kinit -k). Needs read access to the keytab — root, in practice.

Source

pub fn ensure( &self, tools: &Tools, identity: &MachineIdentity, ) -> Result<Freshness>

Make sure the cache holds a valid ticket for this identity: renew if possible (cheapest, keeps the same established ticket), mint from the keytab otherwise. The result is verified with klist -s before returning. A cache holding a foreign principal fails the renew and is overwritten by the mint — the cache self-heals.

Source

pub fn set_access(&self, gid: u32) -> Result<()>

Restrict the cache to root:<gid> 0640 so group members (and only they) can use the armor ticket. kinit re-creates the file 0600 on every renew/mint, so call this after ensure.

Only the group is changed (owner stays whoever kinit ran as), so this works under a minimal capability set (CAP_CHOWN). Race-free against symlink swaps: the file is opened with O_NOFOLLOW and the ownership/ mode changes are applied through the file descriptor (fchown/ fchmod), so there is no check-to-use window on the path.

Source

pub fn klist_text(&self, tools: &Tools) -> Result<String>

Raw klist text for status display (LC_ALL=C, so stable format).

Source

pub fn destroy(&self, tools: &Tools)

Destroy the cache (best effort; missing cache is fine).

Trait Implementations§

Source§

impl Clone for ArmorCache

Source§

fn clone(&self) -> ArmorCache

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 Debug for ArmorCache

Source§

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

Formats the value using the given formatter. Read more

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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.