summaryrefslogtreecommitdiffstats
path: root/src/home/homectl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-16 09:44:55 +0200
committerLennart Poettering <lennart@poettering.net>2020-07-01 11:20:26 +0200
commit0eb3be464446ff98dba63cac6769467514403e10 (patch)
tree72491aebfdf3ea44148a85dbd12a0587a7ad2a8b /src/home/homectl.c
parenthomectl: add acquired fido2 PIN to user record (diff)
downloadsystemd-0eb3be464446ff98dba63cac6769467514403e10.tar.xz
systemd-0eb3be464446ff98dba63cac6769467514403e10.zip
homectl: add --pkcs11-uri=auto and --pkcs-11-uri=list support
We have the same for FIDO2 devices, for listing suitable devices, or picking the right one automatically, let's add that for PKCS11 too.
Diffstat (limited to 'src/home/homectl.c')
-rw-r--r--src/home/homectl.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/home/homectl.c b/src/home/homectl.c
index 95fcead038..74c967eb26 100644
--- a/src/home/homectl.c
+++ b/src/home/homectl.c
@@ -3098,6 +3098,9 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_PKCS11_TOKEN_URI: {
const char *p;
+ if (streq(optarg, "list"))
+ return list_pkcs11_tokens();
+
/* If --pkcs11-token-uri= is specified we always drop everything old */
FOREACH_STRING(p, "pkcs11TokenUri", "pkcs11EncryptedKey") {
r = drop_from_identity(p);
@@ -3110,10 +3113,19 @@ static int parse_argv(int argc, char *argv[]) {
break;
}
- if (!pkcs11_uri_valid(optarg))
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not a valid PKCS#11 URI: %s", optarg);
+ if (streq(optarg, "auto")) {
+ _cleanup_free_ char *found = NULL;
- r = strv_extend(&arg_pkcs11_token_uri, optarg);
+ r = find_pkcs11_token_auto(&found);
+ if (r < 0)
+ return r;
+ r = strv_consume(&arg_pkcs11_token_uri, TAKE_PTR(found));
+ } else {
+ if (!pkcs11_uri_valid(optarg))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not a valid PKCS#11 URI: %s", optarg);
+
+ r = strv_extend(&arg_pkcs11_token_uri, optarg);
+ }
if (r < 0)
return r;