recovery-utils: only print open device warning when encrypting partitions

Technically, partition unencryption is safe to do in open devices, although it
implies that at least one partition has already been encrypted. If we aren't
going to encrypt any partitions, there's no need to print the warning.

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2021-06-01 17:53:54 +02:00
parent 8c19cda181
commit d5c696fd5b
1 changed files with 6 additions and 1 deletions

View File

@ -846,7 +846,12 @@ int encrypt_partitions(char *to_encrypt, char *to_unencrypt, unsigned char force
goto err; goto err;
} }
print_open_device_warning(); /*
* Print warning on open devices only if we're encrypting at least
* one partition.
*/
if (enc_diff[0])
print_open_device_warning();
/* /*
* At this point, we know that we have at least one partition to * At this point, we know that we have at least one partition to