cryptenroll: show better log message if slot to wipe does not exist

```
$ 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
```
This commit is contained in:
Antonio Alvarez Feijoo 2024-11-19 11:26:49 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 12b06fef7a
commit 2b251491de

View File

@ -427,7 +427,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