]> granicus.if.org Git - p11-kit/commitdiff
iter: Don't skip tokens that don't have CKF_TOKEN_INITIALIZED
authorStef Walter <stefw@gnome.org>
Fri, 8 Mar 2013 21:50:43 +0000 (22:50 +0100)
committerStef Walter <stefw@gnome.org>
Fri, 8 Mar 2013 21:54:56 +0000 (22:54 +0100)
This flag is not required to be set unless C_InitToken has been
called. Many modules, like libnssckbi.so, do not set this flag.

p11-kit/iter.c
p11-kit/tests/test-iter.c

index 1807afea44755a790a31252630d812fa8d2ef199..7f23c53909533091a7def9e4d5304c213e2ce4f7 100644 (file)
@@ -482,10 +482,6 @@ move_next_session (P11KitIter *iter)
                if (rv != CKR_OK || !p11_match_uri_token_info (&iter->match_token, &tinfo))
                        continue;
 
-               /* Token is not initialized, we're not going to get further, so skip */
-               if (!(tinfo.flags & CKF_TOKEN_INITIALIZED))
-                       continue;
-
                rv = (iter->module->C_OpenSession) (iter->slot, iter->session_flags,
                                                    NULL, NULL, &iter->session);
                if (rv != CKR_OK)
index 275d2d2934a55e2c99a40b5d50fc11091c737496..81aa06c9310c02157466f9398bcfa8f29a15b968 100644 (file)
@@ -805,38 +805,6 @@ test_getslotlist_fail_late (CuTest *tc)
        CuAssertTrue (tc, rv == CKR_OK);
 }
 
-static void
-test_token_not_initialized (CuTest *tc)
-{
-       CK_FUNCTION_LIST module;
-       P11KitIter *iter;
-       CK_RV rv;
-       int at;
-
-       rv = p11_kit_initialize_module (&mock_module);
-       CuAssertTrue (tc, rv == CKR_OK);
-
-       memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
-       module.C_GetTokenInfo = mock_C_GetTokenInfo_not_initialized;
-
-       iter = p11_kit_iter_new (NULL);
-       p11_kit_iter_begin_with (iter, &module, 0, 0);
-
-       at= 0;
-       while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
-               at++;
-
-       CuAssertTrue (tc, rv == CKR_CANCEL);
-
-       /* Should fail on the first iteration */
-       CuAssertIntEquals (tc, 0, at);
-
-       p11_kit_iter_free (iter);
-
-       rv = p11_kit_finalize_module (&mock_module);
-       CuAssertTrue (tc, rv == CKR_OK);
-}
-
 static void
 test_open_session_fail (CuTest *tc)
 {
@@ -1120,7 +1088,6 @@ main (void)
        SUITE_ADD_TEST (suite, test_module_mismatch);
        SUITE_ADD_TEST (suite, test_getslotlist_fail_first);
        SUITE_ADD_TEST (suite, test_getslotlist_fail_late);
-       SUITE_ADD_TEST (suite, test_token_not_initialized);
        SUITE_ADD_TEST (suite, test_open_session_fail);
        SUITE_ADD_TEST (suite, test_find_init_fail);
        SUITE_ADD_TEST (suite, test_find_objects_fail);