From 3d8e8d32cdbd6251686065096b11768023bd9994 Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Thu, 17 Aug 2023 13:05:51 -0500 Subject: [PATCH 1/2] credential: make gnome-secret built-in as cargo:libsecret --- Cargo.lock | 1 + Cargo.toml | 2 ++ .../cargo-credential-gnome-secret/src/lib.rs | 6 ++++++ .../cargo-credential-gnome-secret/src/main.rs | 7 ------- deny.toml | 1 + src/cargo/util/auth/mod.rs | 1 + src/doc/src/reference/unstable.md | 15 +-------------- 7 files changed, 12 insertions(+), 21 deletions(-) create mode 100644 credential/cargo-credential-gnome-secret/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 9976db22c80..63f11dfc9bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,6 +263,7 @@ dependencies = [ "base64", "bytesize", "cargo-credential", + "cargo-credential-gnome-secret", "cargo-credential-macos-keychain", "cargo-credential-wincred", "cargo-platform 0.1.4", diff --git a/Cargo.toml b/Cargo.toml index 9e0a68bc302..4d2d6f6c790 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ base64 = "0.21.2" bytesize = "1.2" cargo = { path = "" } cargo-credential = { version = "0.3.0", path = "credential/cargo-credential" } +cargo-credential-gnome-secret = { version = "0.3.1", path = "credential/cargo-credential-gnome-secret" } cargo-credential-wincred = { version = "0.3.0", path = "credential/cargo-credential-wincred" } cargo-credential-macos-keychain = { version = "0.3.0", path = "credential/cargo-credential-macos-keychain" } cargo-platform = { path = "crates/cargo-platform", version = "0.1.4" } @@ -123,6 +124,7 @@ base64.workspace = true bytesize.workspace = true cargo-platform.workspace = true cargo-credential.workspace = true +cargo-credential-gnome-secret.workspace = true cargo-credential-macos-keychain.workspace = true cargo-credential-wincred.workspace = true cargo-util.workspace = true diff --git a/credential/cargo-credential-gnome-secret/src/lib.rs b/credential/cargo-credential-gnome-secret/src/lib.rs new file mode 100644 index 00000000000..473e3191daf --- /dev/null +++ b/credential/cargo-credential-gnome-secret/src/lib.rs @@ -0,0 +1,6 @@ +#[cfg(target_os = "linux")] +mod libsecret; +#[cfg(not(target_os = "linux"))] +pub use cargo_credential::UnsupportedCredential as GnomeSecret; +#[cfg(target_os = "linux")] +pub use libsecret::GnomeSecret; diff --git a/credential/cargo-credential-gnome-secret/src/main.rs b/credential/cargo-credential-gnome-secret/src/main.rs index 1d2ecc61fbc..9ba535dcd07 100644 --- a/credential/cargo-credential-gnome-secret/src/main.rs +++ b/credential/cargo-credential-gnome-secret/src/main.rs @@ -1,12 +1,5 @@ //! Cargo registry gnome libsecret credential process. -#[cfg(target_os = "linux")] -mod libsecret; -#[cfg(not(target_os = "linux"))] -use cargo_credential::UnsupportedCredential as GnomeSecret; -#[cfg(target_os = "linux")] -use libsecret::GnomeSecret; - fn main() { cargo_credential::main(GnomeSecret); } diff --git a/deny.toml b/deny.toml index 89d08eacc8f..38364817143 100644 --- a/deny.toml +++ b/deny.toml @@ -109,6 +109,7 @@ allow = [ "MPL-2.0", "Unicode-DFS-2016", "CC0-1.0", + "ISC", ] # List of explicitly disallowed licenses # See https://spdx.org/licenses/ for list of possible licenses diff --git a/src/cargo/util/auth/mod.rs b/src/cargo/util/auth/mod.rs index 10ab4491a92..8ff32f52dea 100644 --- a/src/cargo/util/auth/mod.rs +++ b/src/cargo/util/auth/mod.rs @@ -451,6 +451,7 @@ fn credential_action( "cargo:token-from-stdout" => Box::new(BasicProcessCredential {}), "cargo:wincred" => Box::new(cargo_credential_wincred::WindowsCredential {}), "cargo:macos-keychain" => Box::new(cargo_credential_macos_keychain::MacKeychain {}), + "cargo:libsecret" => Box::new(cargo_credential_gnome_secret::GnomeSecret {}), process => Box::new(CredentialProcessCredential::new(process)), }; config.shell().verbose(|c| { diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 85aad30c1a0..11b9406baa0 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -1094,6 +1094,7 @@ executed within the Cargo process. They are identified with the `cargo:` prefix. * `cargo:token` - Uses Cargo's config and `credentials.toml` to store the token (default). * `cargo:wincred` - Uses the Windows Credential Manager to store the token. * `cargo:macos-keychain` - Uses the macOS Keychain to store the token. +* `cargo:libsecret` - Uses [libsecret](https://wiki.gnome.org/Projects/Libsecret) to store tokens on Linux systems. * `cargo:token-from-stdout ` - Launch a subprocess that returns a token on stdout. Newlines will be trimmed. The process inherits the user's stdin and stderr. It should exit 0 on success, and nonzero on error. @@ -1130,20 +1131,6 @@ In the config, add it to `global-credential-providers`: global-credential-providers = ["cargo-credential-1password"] ``` -A wrapper is available for GNOME -[libsecret](https://wiki.gnome.org/Projects/Libsecret) to store tokens on -Linux systems. Due to build limitations, this wrapper is not available as a -pre-compiled binary. This can be built and installed manually. First, install -libsecret using your system package manager (for example, `sudo apt install -libsecret-1-dev`). Then build and install the wrapper with `cargo install -cargo-credential-gnome-secret`. -In the config, use a path to the binary like this: - -```toml -[registry] -global-credential-providers = ["cargo-credential-gnome-secret"] -``` - #### JSON Interface When using an external credential provider, Cargo communicates with the credential provider using stdin/stdout messages passed as a single line of JSON. From 763edbab09f11b5159eab4ec3c2e90b8f8854ea8 Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Thu, 17 Aug 2023 15:59:33 -0500 Subject: [PATCH 2/2] rename crate to cargo-credential-libsecret --- Cargo.lock | 4 +- Cargo.toml | 4 +- crates/xtask-bump-check/src/xtask.rs | 2 +- .../cargo-credential-gnome-secret/src/lib.rs | 6 - .../src/libsecret.rs | 226 ----------------- .../cargo-credential-gnome-secret/src/main.rs | 5 - .../Cargo.toml | 3 +- .../README.md | 2 +- .../cargo-credential-libsecret/src/lib.rs | 235 ++++++++++++++++++ src/cargo/util/auth/mod.rs | 2 +- 10 files changed, 243 insertions(+), 246 deletions(-) delete mode 100644 credential/cargo-credential-gnome-secret/src/lib.rs delete mode 100644 credential/cargo-credential-gnome-secret/src/libsecret.rs delete mode 100644 credential/cargo-credential-gnome-secret/src/main.rs rename credential/{cargo-credential-gnome-secret => cargo-credential-libsecret}/Cargo.toml (88%) rename credential/{cargo-credential-gnome-secret => cargo-credential-libsecret}/README.md (90%) create mode 100644 credential/cargo-credential-libsecret/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 63f11dfc9bb..e5c19b95251 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,7 +263,7 @@ dependencies = [ "base64", "bytesize", "cargo-credential", - "cargo-credential-gnome-secret", + "cargo-credential-libsecret", "cargo-credential-macos-keychain", "cargo-credential-wincred", "cargo-platform 0.1.4", @@ -355,7 +355,7 @@ dependencies = [ ] [[package]] -name = "cargo-credential-gnome-secret" +name = "cargo-credential-libsecret" version = "0.3.1" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 4d2d6f6c790..a9587ea2d71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ base64 = "0.21.2" bytesize = "1.2" cargo = { path = "" } cargo-credential = { version = "0.3.0", path = "credential/cargo-credential" } -cargo-credential-gnome-secret = { version = "0.3.1", path = "credential/cargo-credential-gnome-secret" } +cargo-credential-libsecret = { version = "0.3.1", path = "credential/cargo-credential-libsecret" } cargo-credential-wincred = { version = "0.3.0", path = "credential/cargo-credential-wincred" } cargo-credential-macos-keychain = { version = "0.3.0", path = "credential/cargo-credential-macos-keychain" } cargo-platform = { path = "crates/cargo-platform", version = "0.1.4" } @@ -124,7 +124,7 @@ base64.workspace = true bytesize.workspace = true cargo-platform.workspace = true cargo-credential.workspace = true -cargo-credential-gnome-secret.workspace = true +cargo-credential-libsecret.workspace = true cargo-credential-macos-keychain.workspace = true cargo-credential-wincred.workspace = true cargo-util.workspace = true diff --git a/crates/xtask-bump-check/src/xtask.rs b/crates/xtask-bump-check/src/xtask.rs index 1a3a1a77c95..f891523315d 100644 --- a/crates/xtask-bump-check/src/xtask.rs +++ b/crates/xtask-bump-check/src/xtask.rs @@ -153,7 +153,7 @@ fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> Carg "--exclude", "cargo-credential-1password", "--exclude", - "cargo-credential-gnome-secret", + "cargo-credential-libsecret", "--exclude", "cargo-credential-macos-keychain", "--exclude", diff --git a/credential/cargo-credential-gnome-secret/src/lib.rs b/credential/cargo-credential-gnome-secret/src/lib.rs deleted file mode 100644 index 473e3191daf..00000000000 --- a/credential/cargo-credential-gnome-secret/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[cfg(target_os = "linux")] -mod libsecret; -#[cfg(not(target_os = "linux"))] -pub use cargo_credential::UnsupportedCredential as GnomeSecret; -#[cfg(target_os = "linux")] -pub use libsecret::GnomeSecret; diff --git a/credential/cargo-credential-gnome-secret/src/libsecret.rs b/credential/cargo-credential-gnome-secret/src/libsecret.rs deleted file mode 100644 index 44fc4dea4f5..00000000000 --- a/credential/cargo-credential-gnome-secret/src/libsecret.rs +++ /dev/null @@ -1,226 +0,0 @@ -//! Implementation of the libsecret credential helper. - -use anyhow::Context; -use cargo_credential::{ - read_token, Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo, Secret, -}; -use libloading::{Library, Symbol}; -use std::ffi::{CStr, CString}; -use std::os::raw::{c_char, c_int}; -use std::ptr::{null, null_mut}; - -#[allow(non_camel_case_types)] -type gchar = c_char; - -#[allow(non_camel_case_types)] -type gboolean = c_int; - -type GQuark = u32; - -#[repr(C)] -struct GError { - domain: GQuark, - code: c_int, - message: *mut gchar, -} - -#[repr(C)] -struct GCancellable { - _private: [u8; 0], -} - -#[repr(C)] -struct SecretSchema { - name: *const gchar, - flags: SecretSchemaFlags, - attributes: [SecretSchemaAttribute; 32], -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct SecretSchemaAttribute { - name: *const gchar, - attr_type: SecretSchemaAttributeType, -} - -#[repr(C)] -enum SecretSchemaFlags { - None = 0, -} - -#[repr(C)] -#[derive(Copy, Clone)] -enum SecretSchemaAttributeType { - String = 0, -} - -type SecretPasswordStoreSync = extern "C" fn( - schema: *const SecretSchema, - collection: *const gchar, - label: *const gchar, - password: *const gchar, - cancellable: *mut GCancellable, - error: *mut *mut GError, - ... -) -> gboolean; -type SecretPasswordClearSync = extern "C" fn( - schema: *const SecretSchema, - cancellable: *mut GCancellable, - error: *mut *mut GError, - ... -) -> gboolean; -type SecretPasswordLookupSync = extern "C" fn( - schema: *const SecretSchema, - cancellable: *mut GCancellable, - error: *mut *mut GError, - ... -) -> *mut gchar; - -pub struct GnomeSecret; - -fn label(index_url: &str) -> CString { - CString::new(format!("cargo-registry:{}", index_url)).unwrap() -} - -fn schema() -> SecretSchema { - let mut attributes = [SecretSchemaAttribute { - name: null(), - attr_type: SecretSchemaAttributeType::String, - }; 32]; - attributes[0] = SecretSchemaAttribute { - name: b"url\0".as_ptr() as *const gchar, - attr_type: SecretSchemaAttributeType::String, - }; - SecretSchema { - name: b"org.rust-lang.cargo.registry\0".as_ptr() as *const gchar, - flags: SecretSchemaFlags::None, - attributes, - } -} - -impl Credential for GnomeSecret { - fn perform( - &self, - registry: &RegistryInfo, - action: &Action, - _args: &[&str], - ) -> Result { - // Dynamically load libsecret to avoid users needing to install - // additional -dev packages when building this provider. - let lib; - let secret_password_lookup_sync: Symbol; - let secret_password_store_sync: Symbol; - let secret_password_clear_sync: Symbol; - unsafe { - lib = Library::new("libsecret-1.so").context( - "failed to load libsecret: try installing the `libsecret` \ - or `libsecret-1-0` package with the system package manager", - )?; - secret_password_lookup_sync = lib - .get(b"secret_password_lookup_sync\0") - .map_err(Box::new)?; - secret_password_store_sync = - lib.get(b"secret_password_store_sync\0").map_err(Box::new)?; - secret_password_clear_sync = - lib.get(b"secret_password_clear_sync\0").map_err(Box::new)?; - } - - let index_url_c = CString::new(registry.index_url).unwrap(); - match action { - cargo_credential::Action::Get(_) => { - let mut error: *mut GError = null_mut(); - let attr_url = CString::new("url").unwrap(); - let schema = schema(); - unsafe { - let token_c = secret_password_lookup_sync( - &schema, - null_mut(), - &mut error, - attr_url.as_ptr(), - index_url_c.as_ptr(), - null() as *const gchar, - ); - if !error.is_null() { - return Err(format!( - "failed to get token: {}", - CStr::from_ptr((*error).message) - .to_str() - .unwrap_or_default() - ) - .into()); - } - if token_c.is_null() { - return Err(Error::NotFound); - } - let token = Secret::from( - CStr::from_ptr(token_c) - .to_str() - .map_err(|e| format!("expected utf8 token: {}", e))? - .to_string(), - ); - Ok(CredentialResponse::Get { - token, - cache: CacheControl::Session, - operation_independent: true, - }) - } - } - cargo_credential::Action::Login(options) => { - let label = label(registry.name.unwrap_or(registry.index_url)); - let token = CString::new(read_token(options, registry)?.expose()).unwrap(); - let mut error: *mut GError = null_mut(); - let attr_url = CString::new("url").unwrap(); - let schema = schema(); - unsafe { - secret_password_store_sync( - &schema, - b"default\0".as_ptr() as *const gchar, - label.as_ptr(), - token.as_ptr(), - null_mut(), - &mut error, - attr_url.as_ptr(), - index_url_c.as_ptr(), - null() as *const gchar, - ); - if !error.is_null() { - return Err(format!( - "failed to store token: {}", - CStr::from_ptr((*error).message) - .to_str() - .unwrap_or_default() - ) - .into()); - } - } - Ok(CredentialResponse::Login) - } - cargo_credential::Action::Logout => { - let schema = schema(); - let mut error: *mut GError = null_mut(); - let attr_url = CString::new("url").unwrap(); - unsafe { - secret_password_clear_sync( - &schema, - null_mut(), - &mut error, - attr_url.as_ptr(), - index_url_c.as_ptr(), - null() as *const gchar, - ); - if !error.is_null() { - return Err(format!( - "failed to erase token: {}", - CStr::from_ptr((*error).message) - .to_str() - .unwrap_or_default() - ) - .into()); - } - } - Ok(CredentialResponse::Logout) - } - _ => Err(Error::OperationNotSupported), - } - } -} diff --git a/credential/cargo-credential-gnome-secret/src/main.rs b/credential/cargo-credential-gnome-secret/src/main.rs deleted file mode 100644 index 9ba535dcd07..00000000000 --- a/credential/cargo-credential-gnome-secret/src/main.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Cargo registry gnome libsecret credential process. - -fn main() { - cargo_credential::main(GnomeSecret); -} diff --git a/credential/cargo-credential-gnome-secret/Cargo.toml b/credential/cargo-credential-libsecret/Cargo.toml similarity index 88% rename from credential/cargo-credential-gnome-secret/Cargo.toml rename to credential/cargo-credential-libsecret/Cargo.toml index e88790c542b..1bd4bb7d063 100644 --- a/credential/cargo-credential-gnome-secret/Cargo.toml +++ b/credential/cargo-credential-libsecret/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cargo-credential-gnome-secret" +name = "cargo-credential-libsecret" version = "0.3.1" edition.workspace = true license.workspace = true @@ -10,4 +10,3 @@ description = "A Cargo credential process that stores tokens with GNOME libsecre anyhow.workspace = true cargo-credential.workspace = true libloading.workspace = true - diff --git a/credential/cargo-credential-gnome-secret/README.md b/credential/cargo-credential-libsecret/README.md similarity index 90% rename from credential/cargo-credential-gnome-secret/README.md rename to credential/cargo-credential-libsecret/README.md index 7a4b0283856..f169323e061 100644 --- a/credential/cargo-credential-gnome-secret/README.md +++ b/credential/cargo-credential-libsecret/README.md @@ -1,4 +1,4 @@ -# cargo-credential-gnome-secret +# cargo-credential-libsecret This is the implementation for the Cargo credential helper for [GNOME libsecret]. See the [credential-process] documentation for how to use this. diff --git a/credential/cargo-credential-libsecret/src/lib.rs b/credential/cargo-credential-libsecret/src/lib.rs new file mode 100644 index 00000000000..f83b424ee51 --- /dev/null +++ b/credential/cargo-credential-libsecret/src/lib.rs @@ -0,0 +1,235 @@ +#[cfg(target_os = "linux")] +mod linux { + //! Implementation of the libsecret credential helper. + + use anyhow::Context; + use cargo_credential::{ + read_token, Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo, + Secret, + }; + use libloading::{Library, Symbol}; + use std::ffi::{CStr, CString}; + use std::os::raw::{c_char, c_int}; + use std::ptr::{null, null_mut}; + + #[allow(non_camel_case_types)] + type gchar = c_char; + + #[allow(non_camel_case_types)] + type gboolean = c_int; + + type GQuark = u32; + + #[repr(C)] + struct GError { + domain: GQuark, + code: c_int, + message: *mut gchar, + } + + #[repr(C)] + struct GCancellable { + _private: [u8; 0], + } + + #[repr(C)] + struct SecretSchema { + name: *const gchar, + flags: SecretSchemaFlags, + attributes: [SecretSchemaAttribute; 32], + } + + #[repr(C)] + #[derive(Copy, Clone)] + struct SecretSchemaAttribute { + name: *const gchar, + attr_type: SecretSchemaAttributeType, + } + + #[repr(C)] + enum SecretSchemaFlags { + None = 0, + } + + #[repr(C)] + #[derive(Copy, Clone)] + enum SecretSchemaAttributeType { + String = 0, + } + + type SecretPasswordStoreSync = extern "C" fn( + schema: *const SecretSchema, + collection: *const gchar, + label: *const gchar, + password: *const gchar, + cancellable: *mut GCancellable, + error: *mut *mut GError, + ... + ) -> gboolean; + type SecretPasswordClearSync = extern "C" fn( + schema: *const SecretSchema, + cancellable: *mut GCancellable, + error: *mut *mut GError, + ... + ) -> gboolean; + type SecretPasswordLookupSync = extern "C" fn( + schema: *const SecretSchema, + cancellable: *mut GCancellable, + error: *mut *mut GError, + ... + ) -> *mut gchar; + + pub struct LibSecretCredential; + + fn label(index_url: &str) -> CString { + CString::new(format!("cargo-registry:{}", index_url)).unwrap() + } + + fn schema() -> SecretSchema { + let mut attributes = [SecretSchemaAttribute { + name: null(), + attr_type: SecretSchemaAttributeType::String, + }; 32]; + attributes[0] = SecretSchemaAttribute { + name: b"url\0".as_ptr() as *const gchar, + attr_type: SecretSchemaAttributeType::String, + }; + SecretSchema { + name: b"org.rust-lang.cargo.registry\0".as_ptr() as *const gchar, + flags: SecretSchemaFlags::None, + attributes, + } + } + + impl Credential for LibSecretCredential { + fn perform( + &self, + registry: &RegistryInfo, + action: &Action, + _args: &[&str], + ) -> Result { + // Dynamically load libsecret to avoid users needing to install + // additional -dev packages when building this provider. + let lib; + let secret_password_lookup_sync: Symbol; + let secret_password_store_sync: Symbol; + let secret_password_clear_sync: Symbol; + unsafe { + lib = Library::new("libsecret-1.so").context( + "failed to load libsecret: try installing the `libsecret` \ + or `libsecret-1-0` package with the system package manager", + )?; + secret_password_lookup_sync = lib + .get(b"secret_password_lookup_sync\0") + .map_err(Box::new)?; + secret_password_store_sync = + lib.get(b"secret_password_store_sync\0").map_err(Box::new)?; + secret_password_clear_sync = + lib.get(b"secret_password_clear_sync\0").map_err(Box::new)?; + } + + let index_url_c = CString::new(registry.index_url).unwrap(); + match action { + cargo_credential::Action::Get(_) => { + let mut error: *mut GError = null_mut(); + let attr_url = CString::new("url").unwrap(); + let schema = schema(); + unsafe { + let token_c = secret_password_lookup_sync( + &schema, + null_mut(), + &mut error, + attr_url.as_ptr(), + index_url_c.as_ptr(), + null() as *const gchar, + ); + if !error.is_null() { + return Err(format!( + "failed to get token: {}", + CStr::from_ptr((*error).message) + .to_str() + .unwrap_or_default() + ) + .into()); + } + if token_c.is_null() { + return Err(Error::NotFound); + } + let token = Secret::from( + CStr::from_ptr(token_c) + .to_str() + .map_err(|e| format!("expected utf8 token: {}", e))? + .to_string(), + ); + Ok(CredentialResponse::Get { + token, + cache: CacheControl::Session, + operation_independent: true, + }) + } + } + cargo_credential::Action::Login(options) => { + let label = label(registry.name.unwrap_or(registry.index_url)); + let token = CString::new(read_token(options, registry)?.expose()).unwrap(); + let mut error: *mut GError = null_mut(); + let attr_url = CString::new("url").unwrap(); + let schema = schema(); + unsafe { + secret_password_store_sync( + &schema, + b"default\0".as_ptr() as *const gchar, + label.as_ptr(), + token.as_ptr(), + null_mut(), + &mut error, + attr_url.as_ptr(), + index_url_c.as_ptr(), + null() as *const gchar, + ); + if !error.is_null() { + return Err(format!( + "failed to store token: {}", + CStr::from_ptr((*error).message) + .to_str() + .unwrap_or_default() + ) + .into()); + } + } + Ok(CredentialResponse::Login) + } + cargo_credential::Action::Logout => { + let schema = schema(); + let mut error: *mut GError = null_mut(); + let attr_url = CString::new("url").unwrap(); + unsafe { + secret_password_clear_sync( + &schema, + null_mut(), + &mut error, + attr_url.as_ptr(), + index_url_c.as_ptr(), + null() as *const gchar, + ); + if !error.is_null() { + return Err(format!( + "failed to erase token: {}", + CStr::from_ptr((*error).message) + .to_str() + .unwrap_or_default() + ) + .into()); + } + } + Ok(CredentialResponse::Logout) + } + _ => Err(Error::OperationNotSupported), + } + } + } +} + +#[cfg(not(target_os = "linux"))] +pub use cargo_credential::UnsupportedCredential as LibSecretCredential; +#[cfg(target_os = "linux")] +pub use linux::LibSecretCredential; diff --git a/src/cargo/util/auth/mod.rs b/src/cargo/util/auth/mod.rs index 8ff32f52dea..7354b8cab6c 100644 --- a/src/cargo/util/auth/mod.rs +++ b/src/cargo/util/auth/mod.rs @@ -451,7 +451,7 @@ fn credential_action( "cargo:token-from-stdout" => Box::new(BasicProcessCredential {}), "cargo:wincred" => Box::new(cargo_credential_wincred::WindowsCredential {}), "cargo:macos-keychain" => Box::new(cargo_credential_macos_keychain::MacKeychain {}), - "cargo:libsecret" => Box::new(cargo_credential_gnome_secret::GnomeSecret {}), + "cargo:libsecret" => Box::new(cargo_credential_libsecret::LibSecretCredential {}), process => Box::new(CredentialProcessCredential::new(process)), }; config.shell().verbose(|c| {