From 2abe64666e544be6499f870618185f8819b4c152 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 5 Oct 2018 22:37:37 +0200 Subject: [PATCH 1/2] cryptsetup: don't use %m if there's no error to show We are not the ones receiving an error here, but the ones generating it, hence we shouldn't show it with %m, that's just confusing, as it suggests we received an error from some other call. --- src/cryptsetup/cryptsetup-generator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 24ccf04273..6c4aabe57d 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -152,8 +152,10 @@ static int create_disk( return log_oom(); } - if (keydev && !password) - return log_error_errno(-EINVAL, "Keydev is specified, but path to the password file is missing: %m"); + if (keydev && !password) { + log_error("Key device is specified, but path to the password file is missing."); + return -EINVAL; + } r = generator_open_unit_file(arg_dest, NULL, n, &f); if (r < 0) From e3ca6580ae2d9a72dd81a408ad7fcafb829a0882 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 5 Oct 2018 22:39:02 +0200 Subject: [PATCH 2/2] cryptsetup: use PATH_IN_SET() instead of STR_IN_SET() when comparing paths It's formally more correct. --- src/cryptsetup/cryptsetup-generator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 6c4aabe57d..cada032bb9 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -192,7 +192,7 @@ static int create_disk( netdev ? "remote-cryptsetup.target" : "cryptsetup.target"); if (password) { - if (STR_IN_SET(password, "/dev/urandom", "/dev/random", "/dev/hw_random")) + if (PATH_IN_SET(password, "/dev/urandom", "/dev/random", "/dev/hw_random")) fputs("After=systemd-random-seed.service\n", f); else if (!STR_IN_SET(password, "-", "none")) { _cleanup_free_ char *uu;