From bf108eb9429496c4f1d8b30139136f95687307f1 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Tue, 19 Jan 2021 09:25:15 +0100 Subject: [PATCH] homed: fix build without p11kit 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 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/home/homectl-pkcs11.c b/src/home/homectl-pkcs11.c index c6aaa2e6d6..52cee9a173 100644 --- a/src/home/homectl-pkcs11.c +++ b/src/home/homectl-pkcs11.c @@ -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;