<varname>LoadCredential=</varname> and <varname>LoadCredentialEncrypted=</varname> take priority over
credentials found by <varname>ImportCredential=</varname>.</para>
+ <para>Note that if decryption or authentication of a credential picked up as result of
+ <varname>ImportCredential=</varname> fails it will be skipped gracefully (a warning is generated, but
+ the credential will not be made available to the invoked service). This is different for those
+ configured via
+ <varname>SetCredentialEncrypted=</varname>/<varname>LoadCredentialEncrypted=</varname>, where failed
+ decryption/authentication will result in service failure.</para>
+
<xi:include href="version-info.xml" xpointer="v254"/></listitem>
</varlistentry>
struct load_cred_args *args,
const char *id,
const char *data,
- size_t size) {
+ size_t size,
+ bool graceful) {
_cleanup_(iovec_done_erase) struct iovec plaintext = {};
size_t add;
default:
assert_not_reached();
}
- if (r < 0)
+ if (r < 0) {
+ if (graceful) {
+ log_warning_errno(r, "Unable to decrypt credential '%s', skipping.", id);
+ return 0;
+ }
+
return r;
+ }
data = plaintext.iov_base;
size = plaintext.iov_len;
if (r < 0)
return log_debug_errno(r, "Failed to read credential '%s': %m", *p);
- r = maybe_decrypt_and_write_credential(args, fn, data, size);
+ r = maybe_decrypt_and_write_credential(args, fn, data, size, /* graceful= */ true);
if (r < 0)
return r;
}
if (r < 0)
return log_debug_errno(r, "Failed to read credential '%s': %m", path);
- return maybe_decrypt_and_write_credential(args, id, data, size);
+ return maybe_decrypt_and_write_credential(args, id, data, size, /* graceful= */ true);
}
static int load_cred_recurse_dir_cb(
args.encrypted = false;
- r = load_credential_glob(&args,
- ic,
- search_path,
- READ_FULL_FILE_SECURE|READ_FULL_FILE_FAIL_WHEN_LARGER);
+ r = load_credential_glob(
+ &args,
+ ic,
+ search_path,
+ READ_FULL_FILE_SECURE|READ_FULL_FILE_FAIL_WHEN_LARGER);
if (r < 0)
return r;
args.encrypted = true;
- r = load_credential_glob(&args,
- ic,
- search_path,
- READ_FULL_FILE_SECURE|READ_FULL_FILE_FAIL_WHEN_LARGER|READ_FULL_FILE_UNBASE64);
+ r = load_credential_glob(
+ &args,
+ ic,
+ search_path,
+ READ_FULL_FILE_SECURE|READ_FULL_FILE_FAIL_WHEN_LARGER|READ_FULL_FILE_UNBASE64);
if (r < 0)
return r;
}
if (errno != ENOENT)
return log_debug_errno(errno, "Failed to test if credential %s exists: %m", sc->id);
- r = maybe_decrypt_and_write_credential(&args, sc->id, sc->data, sc->size);
+ r = maybe_decrypt_and_write_credential(&args, sc->id, sc->data, sc->size, /* graceful= */ false);
if (r < 0)
return r;
}