From 7bb9ad33da0154c9a4317f0123046eee85738349 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 28 Jun 2013 13:00:02 +0200 Subject: iter: Add iteration mode where session is not busy In order to use the session we are iterating on for other tasks such as other C_FindObject() calls, we need to make sure that it's not in the middle of a find operation. Finish up the complete find operation in advance of returning objects from a session. Make this the default mode. The previous behavior remains as an option. Add tests. --- trust/extract-info.c | 8 ++++---- trust/extract.c | 2 +- trust/tests/frob-nss-trust.c | 6 +++--- trust/tests/test-bundle.c | 2 +- trust/tests/test-cer.c | 2 +- trust/tests/test-extract.c | 2 +- trust/tests/test-openssl.c | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) (limited to 'trust') diff --git a/trust/extract-info.c b/trust/extract-info.c index 133b1cd..a645d31 100644 --- a/trust/extract-info.c +++ b/trust/extract-info.c @@ -51,7 +51,7 @@ static p11_dict * load_stapled_extensions (CK_FUNCTION_LIST_PTR module, - CK_SLOT_ID slot_id, + CK_SESSION_HANDLE session, CK_ATTRIBUTE *id) { CK_OBJECT_CLASS extension = CKO_X_CERTIFICATE_EXTENSION; @@ -79,9 +79,9 @@ load_stapled_extensions (CK_FUNCTION_LIST_PTR module, if (!id->pValue || !id->ulValueLen) return stapled; - iter = p11_kit_iter_new (NULL); + iter = p11_kit_iter_new (NULL, 0); p11_kit_iter_add_filter (iter, match, 2); - p11_kit_iter_begin_with (iter, module, slot_id, 0); + p11_kit_iter_begin_with (iter, module, 0, session); while (rv == CKR_OK) { rv = p11_kit_iter_next (iter); @@ -291,7 +291,7 @@ extract_info (P11KitIter *iter, attr = p11_attrs_find_valid (ex->attrs, CKA_ID); if (attr) { ex->stapled = load_stapled_extensions (p11_kit_iter_get_module (iter), - p11_kit_iter_get_slot (iter), + p11_kit_iter_get_session (iter), attr); if (!ex->stapled) return false; diff --git a/trust/extract.c b/trust/extract.c index 10f45df..d5ceb13 100644 --- a/trust/extract.c +++ b/trust/extract.c @@ -440,7 +440,7 @@ p11_trust_extract (int argc, limit_modules_if_necessary (modules, ex.flags); - iter = p11_kit_iter_new (uri); + iter = p11_kit_iter_new (uri, 0); p11_kit_iter_add_callback (iter, p11_extract_info_load_filter, &ex, NULL); p11_kit_iter_add_filter (iter, match, p11_attrs_count (match)); diff --git a/trust/tests/frob-nss-trust.c b/trust/tests/frob-nss-trust.c index a81b5e2..fd74db7 100644 --- a/trust/tests/frob-nss-trust.c +++ b/trust/tests/frob-nss-trust.c @@ -108,7 +108,7 @@ dump_trust_module (const char *path) rv = p11_kit_module_initialize (module); return_val_if_fail (rv == CKR_OK, 1); - iter = p11_kit_iter_new (NULL); + iter = p11_kit_iter_new (NULL, 0); p11_kit_iter_add_filter (iter, &match, 1); p11_kit_iter_begin_with (iter, module, 0, 0); @@ -168,7 +168,7 @@ compare_trust_modules (const char *path1, rv = p11_kit_module_initialize (module2); return_val_if_fail (rv == CKR_OK, 1); - iter = p11_kit_iter_new (NULL); + iter = p11_kit_iter_new (NULL, 0); p11_kit_iter_add_filter (iter, &match, 1); p11_kit_iter_begin_with (iter, module1, 0, 0); @@ -182,7 +182,7 @@ compare_trust_modules (const char *path1, p11_attrs_purge (check); /* Check that this object exists */ - iter2 = p11_kit_iter_new (NULL); + iter2 = p11_kit_iter_new (NULL, 0); p11_kit_iter_add_filter (iter2, check, p11_attrs_count (check)); p11_kit_iter_begin_with (iter2, module2, 0, 0); rv = p11_kit_iter_next (iter2); diff --git a/trust/tests/test-bundle.c b/trust/tests/test-bundle.c index bff135e..10f89d2 100644 --- a/trust/tests/test-bundle.c +++ b/trust/tests/test-bundle.c @@ -74,7 +74,7 @@ setup (void *unused) rv = test.module.C_Initialize (NULL); assert_num_eq (CKR_OK, rv); - test.iter = p11_kit_iter_new (NULL); + test.iter = p11_kit_iter_new (NULL, 0); p11_extract_info_init (&test.ex); diff --git a/trust/tests/test-cer.c b/trust/tests/test-cer.c index c48a5ab..fc4d007 100644 --- a/trust/tests/test-cer.c +++ b/trust/tests/test-cer.c @@ -74,7 +74,7 @@ setup (void *unused) rv = test.module.C_Initialize (NULL); assert_num_eq (CKR_OK, rv); - test.iter = p11_kit_iter_new (NULL); + test.iter = p11_kit_iter_new (NULL, 0); p11_extract_info_init (&test.ex); diff --git a/trust/tests/test-extract.c b/trust/tests/test-extract.c index e860996..b121b21 100644 --- a/trust/tests/test-extract.c +++ b/trust/tests/test-extract.c @@ -154,7 +154,7 @@ setup (void *unused) rv = test.module.C_Initialize (NULL); assert_num_eq (CKR_OK, rv); - test.iter = p11_kit_iter_new (NULL); + test.iter = p11_kit_iter_new (NULL, 0); p11_extract_info_init (&test.ex); } diff --git a/trust/tests/test-openssl.c b/trust/tests/test-openssl.c index 7479812..93f8692 100644 --- a/trust/tests/test-openssl.c +++ b/trust/tests/test-openssl.c @@ -78,7 +78,7 @@ setup (void *unused) rv = test.module.C_Initialize (NULL); assert_num_eq (CKR_OK, rv); - test.iter = p11_kit_iter_new (NULL); + test.iter = p11_kit_iter_new (NULL, 0); p11_extract_info_init (&test.ex); -- cgit v1.1