]> git.proxmox.com Git - proxmox-backup.git/commitdiff
cli: tape key-restore: print more info for better ux
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 13 Apr 2022 14:57:11 +0000 (16:57 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 13 Apr 2022 14:59:47 +0000 (16:59 +0200)
as getting the marker error if we passed valid json (but not valid
key) is confusing

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/bin/proxmox_tape/encryption_key.rs

index cbe249de7bfee0f76b41455d44394e4ba4f90191..2e2c043003101530739044503d2e481c861bec8e 100644 (file)
@@ -228,12 +228,13 @@ async fn restore_key(
         let key = if serde_json::from_str::<KeyConfig>(&data).is_ok() {
             &data
         } else {
+            println!("key data seems not like a valid JSON key, trying to parse paper-key format");
             const BEGIN_MARKER: &str = "-----BEGIN PROXMOX BACKUP KEY-----";
             const END_MARKER: &str = "-----END PROXMOX BACKUP KEY-----";
             // exported paperkey-file
             let start = data
                 .find(BEGIN_MARKER)
-                .ok_or_else(|| format_err!("cannot find key start marker"))?
+                .ok_or_else(|| format_err!("cannot find a paper-key format start marker"))?
                 + BEGIN_MARKER.len();
             let data_remain = &data[start..];
             let end = data_remain