cryptenroll: show better log message if slot to wipe does not exist
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Tue, 19 Nov 2024 10:26:49 +0000 (11:26 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 28 Nov 2024 14:04:47 +0000 (15:04 +0100)
```
$ systemd-cryptenroll /dev/vda3
SLOT TYPE
   0 password
$ systemd-cryptenroll --wipe-slot 1 /dev/vda3
Failed to wipe slot 1, continuing: No such file or directory
```

(cherry picked from commit 2b251491debf9cab695f5f34da9908ca46f085fe)

src/cryptenroll/cryptenroll-wipe.c

index 314ebd3113b703c8de0c523b9401fb0fcd908a86..26478d1e88d886d2e6536b9f86da9f9b56b304df 100644 (file)
@@ -425,7 +425,10 @@ int wipe_slots(struct crypt_device *cd,
         for (size_t i = n_ordered_slots; i > 0; i--) {
                 r = crypt_keyslot_destroy(cd, ordered_slots[i - 1]);
                 if (r < 0) {
-                        log_warning_errno(r, "Failed to wipe slot %i, continuing: %m", ordered_slots[i - 1]);
+                        if (r == -ENOENT)
+                                log_warning_errno(r, "Failed to wipe non-existent slot %i, continuing.", ordered_slots[i - 1]);
+                        else
+                                log_warning_errno(r, "Failed to wipe slot %i, continuing: %m", ordered_slots[i - 1]);
                         if (ret == 0)
                                 ret = r;
                 } else