pub struct KeyutilsCredential {
    pub session: KeyRing,
    pub persistent: Option<KeyRing>,
    pub description: String,
}
Expand description

Representation of a keyutils credential.

Since the CredentialBuilderApi::build method does not provide an initial secret, and it is impossible to have 0-length keys, this representation holds a linux_keyutils::KeyRing instead of a linux_keyutils::Key.

The added benefit of this approach is that any call to get_password before set_password is done will result in a proper error as the key does not exist until set_password is called.

Fields§

§session: KeyRing

Host session keyring

§persistent: Option<KeyRing>

Host persistent keyring

§description: String

Description of the key entry

Implementations§

source§

impl KeyutilsCredential

source

pub fn get_credential(&self) -> Result<KeyutilsCredential, Error>

Create a credential from the matching keyutils key.

This is basically a no-op, because keys don’t have extra attributes, but at least we make sure the underlying platform credential exists.

source

pub fn new_with_target( target: Option<&str>, service: &str, user: &str ) -> Result<KeyutilsCredential, Error>

Create the platform credential for a Keyutils entry.

An explicit target string is interpreted as the KeyRing to use for the entry. If none is provided, then we concatenate the user and service in the string keyring-rs:user@service.

Trait Implementations§

source§

impl Clone for KeyutilsCredential

source§

fn clone(&self) -> KeyutilsCredential

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl CredentialApi for KeyutilsCredential

source§

fn set_password(&self, password: &str) -> Result<(), Error>

Set a password in the underlying store

This will overwrite the entry if it already exists since it’s using add_key under the hood.

Returns an Invalid error if the password is empty, because keyutils keys cannot have empty values.

source§

fn get_password(&self) -> Result<String, Error>

Retrieve a password from the underlying store

This requires a call to Key::read with checked conversions to a utf8 Rust string.

source§

fn delete_password(&self) -> Result<(), Error>

Delete a password from the underlying store.

Under the hood this uses Key::invalidate to immediately invalidate the key and prevent any further successful searches.

Note that the keyutils implementation uses caching, and the caches take some time to clear, so a key that has been invalidated may still be found by get_password if it’s called within milliseconds in the same process that deleted the key.

source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast the credential object to std::any::Any. This allows clients to downcast the credential to its concrete type so they can do platform-specific things with it.

source§

impl Debug for KeyutilsCredential

source§

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

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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