]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: ignore invalid password-cache= fully 43135/head
authordongshengyuan <545258830@qq.com>
Fri, 24 Jul 2026 08:38:19 +0000 (16:38 +0800)
committerdongshengyuan <545258830@qq.com>
Fri, 24 Jul 2026 08:38:19 +0000 (16:38 +0800)
password-cache= tracks both the cache mode and whether the option was
configured explicitly. The parser set arg_password_cache_set before
validating the value, so an invalid value was logged as ignored but
still blocked the PKCS#11 default no-cache policy.

Only mark password-cache= as configured after accepting read-only or a
valid boolean.

Repro:
build/systemd-cryptsetup attach sdscan /dev/null - \
    pkcs11-uri=auto,password-cache=bogus

Before: warned ignored, then failed with the PKCS#11 cache error.
After: warned ignored, then continued to the device check.

Follow-up for: fd8ed7f26b5e365c27599bb6b223caaaa20dd2ca

src/cryptsetup/cryptsetup.c

index 379556f5d9e5641d3a91e553f89bf7e81a621d68..6aedf12df5636b94ad4cd2630dbcc922f74c65a0 100644 (file)
@@ -311,8 +311,6 @@ static int parse_one_option(const char *option) {
                         SET_FLAG(arg_ask_password_flags, ASK_PASSWORD_SILENT, !r);
                 }
         } else if ((val = startswith(option, "password-cache="))) {
-                arg_password_cache_set = true;
-
                 if (streq(val, "read-only")) {
                         arg_ask_password_flags |= ASK_PASSWORD_ACCEPT_CACHED;
                         arg_ask_password_flags &= ~ASK_PASSWORD_PUSH_CACHE;
@@ -325,6 +323,8 @@ static int parse_one_option(const char *option) {
 
                         SET_FLAG(arg_ask_password_flags, ASK_PASSWORD_ACCEPT_CACHED|ASK_PASSWORD_PUSH_CACHE, r);
                 }
+
+                arg_password_cache_set = true;
         } else if (STR_IN_SET(option, "allow-discards", "discard"))
                 arg_discards = true;
         else if (streq(option, "same-cpu-crypt"))