From: Lennart Poettering Date: Mon, 31 May 2021 20:55:08 +0000 (+0200) Subject: homework: only default to LUKS storage if libcryptsetup is installed X-Git-Tag: v249-rc1~121^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0608e2d3a576bcdf30d61f7c370b83ca4c481d91;p=thirdparty%2Fsystemd.git homework: only default to LUKS storage if libcryptsetup is installed --- diff --git a/src/home/homework.c b/src/home/homework.c index cfabf348acd..073d12e50e1 100644 --- a/src/home/homework.c +++ b/src/home/homework.c @@ -1095,15 +1095,21 @@ static int determine_default_storage(UserStorage *ret) { return log_error_errno(r, "Failed to determine whether we are in a container: %m"); if (r == 0) { r = path_is_encrypted("/home"); - if (r < 0) - log_warning_errno(r, "Failed to determine if /home is encrypted, ignoring: %m"); - if (r <= 0) { - log_info("Using automatic default storage of '%s'.", user_storage_to_string(USER_LUKS)); - *ret = USER_LUKS; - return 0; - } + if (r > 0) + log_info("/home is encrypted, not using '%s' storage, in order to avoid double encryption.", user_storage_to_string(USER_LUKS)); + else { + if (r < 0) + log_warning_errno(r, "Failed to determine if /home is encrypted, ignoring: %m"); - log_info("/home is encrypted, not using '%s' storage, in order to avoid double encryption.", user_storage_to_string(USER_LUKS)); + r = dlopen_cryptsetup(); + if (r < 0) + log_info("Not using '%s' storage, since libcryptsetup could not be loaded.", user_storage_to_string(USER_LUKS)); + else { + log_info("Using automatic default storage of '%s'.", user_storage_to_string(USER_LUKS)); + *ret = USER_LUKS; + return 0; + } + } } else log_info("Running in container, not using '%s' storage.", user_storage_to_string(USER_LUKS));