]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tape: avoid error when clearing encryption key
authorDietmar Maurer <dietmar@proxmox.com>
Sat, 23 Jan 2021 09:20:43 +0000 (10:20 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 23 Jan 2021 09:20:43 +0000 (10:20 +0100)
Simply ignore clear request when sg_spin_data_encryption_caps fails.
Assume those are tapes without hardware encryption support.

src/tape/drive/encryption.rs

index a71ae2ff6197083033323b434a240c55ba38609e..0f1d3bd3a8a1ae734d697e0fd7356ba42028d6e1 100644 (file)
@@ -33,7 +33,16 @@ pub fn set_encryption<F: AsRawFd>(
     key: Option<[u8; 32]>,
 ) -> Result<(), Error> {
 
-    let data = sg_spin_data_encryption_caps(file)?;
+    let data = match sg_spin_data_encryption_caps(file) {
+        Ok(data) => data,
+        Err(err) if key.is_none() => {
+            /// Assume device does not support HW encryption
+            /// We can simply ignore the clear key request
+            return Ok(());
+        }
+        Err(err) => return Err(err),
+    };
+
     let algorithm_index = decode_spin_data_encryption_caps(&data)?;
 
     sg_spout_set_encryption(file, algorithm_index, key)?;