]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/home/homework-password-cache.h
varlink,json: introduce new varlink_dispatch() helper
[thirdparty/systemd.git] / src / home / homework-password-cache.h
CommitLineData
6b945d70
LP
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2#pragma once
3
4#include "strv.h"
5#include "user-record.h"
6
7typedef struct PasswordCache {
d26cdde3
LP
8 /* Passwords acquired from the kernel keyring */
9 char **keyring_passswords;
10
6b945d70
LP
11 /* Decoding passwords from security tokens is expensive and typically requires user interaction,
12 * hence cache any we already figured out. */
13 char **pkcs11_passwords;
14 char **fido2_passwords;
15} PasswordCache;
16
17void password_cache_free(PasswordCache *cache);
18
19static inline bool password_cache_contains(const PasswordCache *cache, const char *p) {
20 if (!cache)
21 return false;
22
d26cdde3
LP
23 return strv_contains(cache->pkcs11_passwords, p) ||
24 strv_contains(cache->fido2_passwords, p) ||
25 strv_contains(cache->keyring_passswords, p);
6b945d70 26}
d26cdde3
LP
27
28void password_cache_load_keyring(UserRecord *h, PasswordCache *cache);