Struct keyring::native::keyutils::KeyutilsCredential
source · 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: KeyRingHost session keyring
persistent: Option<KeyRing>Host persistent keyring
description: StringDescription of the key entry
Implementations§
source§impl KeyutilsCredential
impl KeyutilsCredential
sourcepub fn get_credential(&self) -> Result<KeyutilsCredential, Error>
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.
sourcepub fn new_with_target(
target: Option<&str>,
service: &str,
user: &str
) -> Result<KeyutilsCredential, Error>
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
impl Clone for KeyutilsCredential
source§fn clone(&self) -> KeyutilsCredential
fn clone(&self) -> KeyutilsCredential
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl CredentialApi for KeyutilsCredential
impl CredentialApi for KeyutilsCredential
source§fn set_password(&self, password: &str) -> Result<(), Error>
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>
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>
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.