keyring support for linux

This commit is contained in:
veeso
2021-06-20 15:04:16 +02:00
parent 15d13af7d5
commit 19610479bd
6 changed files with 16 additions and 13 deletions

View File

@@ -67,7 +67,7 @@ impl KeyStorage for KeyringStorage {
#[cfg(target_os = "macos")]
KeyringError::MacOsKeychainError(_) => Err(KeyStorageError::NoSuchKey),
#[cfg(target_os = "linux")]
KeyringError::SecretServiceError(SsError) => Err(KeyStorageError::ProviderError),
KeyringError::SecretServiceError(_) => Err(KeyStorageError::ProviderError),
KeyringError::Parse(_) => Err(KeyStorageError::BadSytax),
_ => Err(KeyStorageError::ProviderError),
},
@@ -94,7 +94,13 @@ impl KeyStorage for KeyringStorage {
// Check what kind of error is returned
match storage.get_password() {
Ok(_) => true,
#[cfg(not(target_os = "linux"))]
Err(err) => !matches!(err, KeyringError::NoBackendFound),
#[cfg(target_os = "linux")]
Err(err) => !matches!(
err,
KeyringError::NoBackendFound | KeyringError::SecretServiceError(_)
),
}
}
}

View File

@@ -27,7 +27,7 @@
*/
// Storages
pub mod filestorage;
#[cfg(any(target_os = "windows", target_os = "macos"))]
#[cfg(feature = "with-keyring")]
pub mod keyringstorage;
// ext
use thiserror::Error;