]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/home/homework-pkcs11.c
tree-wide: use ASSERT_PTR more
[thirdparty/systemd.git] / src / home / homework-pkcs11.c
index 941ba23b3c30f138e3e3ed465dfd15836d44eef2..be9d905c0e4142c43554f5e70312633f7d4a9c09 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "hexdecoct.h"
 #include "homework-pkcs11.h"
@@ -15,12 +15,11 @@ int pkcs11_callback(
                 void *userdata) {
 
         _cleanup_(erase_and_freep) void *decrypted_key = NULL;
-        struct pkcs11_callback_data *data = userdata;
+        struct pkcs11_callback_data *data = ASSERT_PTR(userdata);
         _cleanup_free_ char *token_label = NULL;
         CK_TOKEN_INFO updated_token_info;
         size_t decrypted_key_size;
         CK_OBJECT_HANDLE object;
-        char **i;
         CK_RV rv;
         int r;
 
@@ -28,7 +27,6 @@ int pkcs11_callback(
         assert(slot_info);
         assert(token_info);
         assert(uri);
-        assert(data);
 
         /* Special return values:
          *
@@ -53,7 +51,7 @@ int pkcs11_callback(
                 if (rv != CKR_OK)
                         return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to log into security token '%s': %s", token_label, p11_kit_strerror(rv));
 
-                log_info("Successully logged into security token '%s' via protected authentication path.", token_label);
+                log_info("Successfully logged into security token '%s' via protected authentication path.", token_label);
                 goto decrypt;
         }
 
@@ -62,10 +60,10 @@ int pkcs11_callback(
                 goto decrypt;
         }
 
-        if (strv_isempty(data->secret->pkcs11_pin))
-                return log_error_errno(SYNTHETIC_ERRNO(ENOANO), "Security Token requires PIN.");
+        if (strv_isempty(data->secret->token_pin))
+                return log_error_errno(SYNTHETIC_ERRNO(ENOANO), "Security token requires PIN.");
 
-        STRV_FOREACH(i, data->secret->pkcs11_pin) {
+        STRV_FOREACH(i, data->secret->token_pin) {
                 rv = m->C_Login(session, CKU_USER, (CK_UTF8CHAR*) *i, strlen(*i));
                 if (rv == CKR_OK) {
                         log_info("Successfully logged into security token '%s' with PIN.", token_label);