]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homed: fix build without p11kit
authorFlorian Westphal <fw@strlen.de>
Tue, 19 Jan 2021 08:25:15 +0000 (09:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 19 Jan 2021 13:38:39 +0000 (14:38 +0100)
homectl-pkcs11.c: In function 'identity_add_pkcs11_key_data':
homectl-pkcs11.c:155:13: error: implicit declaration of function 'pkcs11_acquire_certificate' [-Werror=implicit-function-declaration]

Restores the P11KIT compile-time test that was removed in 2289a78473282902db1108168df6414ae7d91b2f
("homed: move pkcs11 LUKS glue into shared code").

src/home/homectl-pkcs11.c

index c6aaa2e6d6538e63fcfcbe92793bd9fbf8ca3bb5..52cee9a1738c264df4f55c804084610e32d21036 100644 (file)
@@ -142,6 +142,20 @@ int identity_add_token_pin(JsonVariant **v, const char *pin) {
         return 1;
 }
 
+static int acquire_pkcs11_certificate(
+                const char *uri,
+                const char *askpw_friendly_name,
+                const char *askpw_icon_name,
+                X509 **ret_cert,
+                char **ret_pin_used) {
+#if HAVE_P11KIT
+        return pkcs11_acquire_certificate(uri, askpw_friendly_name, askpw_icon_name, ret_cert, ret_pin_used);
+#else
+        return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
+                               "PKCS#11 tokens not supported on this build.");
+#endif
+}
+
 int identity_add_pkcs11_key_data(JsonVariant **v, const char *uri) {
         _cleanup_(erase_and_freep) void *decrypted_key = NULL, *encrypted_key = NULL;
         _cleanup_(erase_and_freep) char *pin = NULL;
@@ -152,7 +166,7 @@ int identity_add_pkcs11_key_data(JsonVariant **v, const char *uri) {
 
         assert(v);
 
-        r = pkcs11_acquire_certificate(uri, "home directory operation", "user-home", &cert, &pin);
+        r = acquire_pkcs11_certificate(uri, "home directory operation", "user-home", &cert, &pin);
         if (r < 0)
                 return r;