forked from systemd/systemd-stable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
homework: split out password cache logic into its own .c/.h file
Preparation for extending it further down the line.
- Loading branch information
1 parent
0881991
commit 6b945d7
Showing
5 changed files
with
35 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
|
||
#include "homework-password-cache.h" | ||
|
||
void password_cache_free(PasswordCache *cache) { | ||
if (!cache) | ||
return; | ||
|
||
cache->pkcs11_passwords = strv_free_erase(cache->pkcs11_passwords); | ||
cache->fido2_passwords = strv_free_erase(cache->fido2_passwords); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
#pragma once | ||
|
||
#include "strv.h" | ||
#include "user-record.h" | ||
|
||
typedef struct PasswordCache { | ||
/* Decoding passwords from security tokens is expensive and typically requires user interaction, | ||
* hence cache any we already figured out. */ | ||
char **pkcs11_passwords; | ||
char **fido2_passwords; | ||
} PasswordCache; | ||
|
||
void password_cache_free(PasswordCache *cache); | ||
|
||
static inline bool password_cache_contains(const PasswordCache *cache, const char *p) { | ||
if (!cache) | ||
return false; | ||
|
||
return strv_contains(cache->pkcs11_passwords, p) || strv_contains(cache->fido2_passwords, p); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters