From 6d7cdb9e10016ba586f5b80f7bf3ab4203f18daf Mon Sep 17 00:00:00 2001 From: Steffen Eiden Date: Wed, 23 Apr 2025 11:24:29 +0200 Subject: [PATCH] pvsecret: Improve documentation for duplicated secret IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Finn Callies Tested-by: Finn Callies Signed-off-by: Steffen Eiden Signed-off-by: Jan Höppner --- rust/pvsecret/README.md | 8 ++++++-- rust/pvsecret/man/pvsecret-retrieve.1 | 11 ++++++++--- rust/pvsecret/src/cli.rs | 6 ++++-- rust/pvsecret/src/cmd/add.rs | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/rust/pvsecret/README.md b/rust/pvsecret/README.md index edecb1e7..b2be7d8e 100644 --- a/rust/pvsecret/README.md +++ b/rust/pvsecret/README.md @@ -526,8 +526,11 @@ Retrieve a secret from the UV secret store (s390x only)
    Specify the secret ID to be retrieved. Input type depends on '--inform'. If `yaml` (default) is specified, it must be a yaml created by the create -subcommand of this tool. If `hex` is specified, it must be a hex 32-byte -unsigned big endian number string. Leading zeros are required. +subcommand of this tool. If `hex` is specified, it must be a 32 byte handle +encodes in hexadecimal. Leading zeros are required. If there are multiple +secrets in the store with the same Id there are no guarantees on which specific +secret is retrieved. Use --inform=idx to make sure a specific secret is +retrieved.
@@ -548,6 +551,7 @@ Define input type for the Secret ID. - **yaml**: Use a yaml file. - **hex**: Use a hex string. - **name**: Use a name-string. Will hash it if no secret with the name found. + - **idx**: Use the secret-index (base 10) instead of the secret-ID. diff --git a/rust/pvsecret/man/pvsecret-retrieve.1 b/rust/pvsecret/man/pvsecret-retrieve.1 index f8ee957d..832279a9 100644 --- a/rust/pvsecret/man/pvsecret-retrieve.1 +++ b/rust/pvsecret/man/pvsecret-retrieve.1 @@ -3,7 +3,7 @@ .\" it under the terms of the MIT license. See LICENSE for details. .\" -.TH "PVSECRET-RETRIEVE" "1" "2025-03-07" "s390-tools" "UV-Secret Manual" +.TH "PVSECRET-RETRIEVE" "1" "2025-04-17" "s390-tools" "UV-Secret Manual" .nh .ad l .SH NAME @@ -28,8 +28,11 @@ keys the PEM name \fBIBM PROTECTED KEY\fP is used. .RS 4 Specify the secret ID to be retrieved. Input type depends on \fB\-\-inform\fR. If `yaml` (default) is specified, it must be a yaml created by the create -subcommand of this tool. If `hex` is specified, it must be a hex 32\-byte -unsigned big endian number string. Leading zeros are required. +subcommand of this tool. If `hex` is specified, it must be a 32 byte handle +encodes in hexadecimal. Leading zeros are required. If there are multiple +secrets in the store with the same Id there are no guarantees on which specific +secret is retrieved. Use \-\-inform=idx to make sure a specific secret is +retrieved. .RE .RE @@ -54,6 +57,8 @@ Possible values: \- \fBname\fP: Use a name-string. Will hash it if no secret with the name found. +\- \fBidx\fP: Use the secret-index (base 10) instead of the secret-ID. + .RE .RE .PP diff --git a/rust/pvsecret/src/cli.rs b/rust/pvsecret/src/cli.rs index 6b983eb4..6271b8fa 100644 --- a/rust/pvsecret/src/cli.rs +++ b/rust/pvsecret/src/cli.rs @@ -320,8 +320,10 @@ pub struct RetrSecretOptions { /// Specify the secret ID to be retrieved. /// /// Input type depends on '--inform'. If `yaml` (default) is specified, it must be a yaml - /// created by the create subcommand of this tool. If `hex` is specified, it must be a hex - /// 32-byte unsigned big endian number string. Leading zeros are required. + /// created by the create subcommand of this tool. If `hex` is specified, it must be a 32 byte + /// handle encodes in hexadecimal. Leading zeros are required. If there are multiple secrets in + /// the store with the same Id there are no guarantees on which specific secret is retrieved. + /// Use --inform=idx to make sure a specific secret is retrieved. #[cfg(target_arch = "s390x")] #[arg(value_name = "ID", value_hint = ValueHint::FilePath)] pub input: String, diff --git a/rust/pvsecret/src/cmd/add.rs b/rust/pvsecret/src/cmd/add.rs index 9404ded8..81fd2730 100644 --- a/rust/pvsecret/src/cmd/add.rs +++ b/rust/pvsecret/src/cmd/add.rs @@ -19,7 +19,7 @@ pub fn add(opt: &AddSecretOpt) -> Result<()> { AddCmd::new(&mut rd_in).context(format!("Processing input file {}", opt.input))?; if let Some(id) = AddSecretRequest::bin_id(cmd.data().unwrap())? { - if !list_uvc(&uv)?.iter().any(|e| e.id() == id.as_ref()) { + if list_uvc(&uv)?.iter().any(|e| e.id() == id.as_ref()) { warn!("There is already a secret in the secret store with that id. Adding the secret anyways."); } }