summaryrefslogtreecommitdiff
path: root/trust/module.c
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2013-07-03 12:47:14 +0200
committerStef Walter <stef@thewalter.net>2013-07-03 13:14:48 +0200
commita2165fe35e336fd807af053a21a396b020f90a23 (patch)
treea4f62b49fcd4fff87aa8a9213912b4426315bd74 /trust/module.c
parent269c4c2e82543de273fa9415dec1b9b6e00c51af (diff)
downloadp11-kit-a2165fe35e336fd807af053a21a396b020f90a23.tar.gz
trust: Initial support for writing out token objects
* The objects are written out in the p11-kit persist format * Parser marks files in p11-kit persist format as modifiable
Diffstat (limited to 'trust/module.c')
-rw-r--r--trust/module.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/trust/module.c b/trust/module.c
index 22e288c..d2fcba6 100644
--- a/trust/module.c
+++ b/trust/module.c
@@ -1102,7 +1102,6 @@ sys_C_SetAttributeValue (CK_SESSION_HANDLE handle,
attrs = lookup_object_inlock (session, object, &index);
if (attrs == NULL) {
rv = CKR_OBJECT_HANDLE_INVALID;
-
} else if (p11_attrs_find_bool (attrs, CKA_MODIFIABLE, &val) && !val) {
/* TODO: This should be replaced with CKR_ACTION_PROHIBITED */
rv = CKR_ATTRIBUTE_READ_ONLY;
@@ -1110,11 +1109,20 @@ sys_C_SetAttributeValue (CK_SESSION_HANDLE handle,
if (rv == CKR_OK)
rv = check_index_writable (session, index);
- if (rv == CKR_OK) {
- if (index == p11_token_index (session->token))
- p11_token_reload (session->token, attrs);
- rv = p11_index_set (index, object, template, count);
+
+ /* Reload the item if applicable */
+ if (rv == CKR_OK && index == p11_token_index (session->token)) {
+ if (p11_token_reload (session->token, attrs)) {
+ attrs = p11_index_lookup (index, object);
+ if (p11_attrs_find_bool (attrs, CKA_MODIFIABLE, &val) && !val) {
+ /* TODO: This should be replaced with CKR_ACTION_PROHIBITED */
+ rv = CKR_ATTRIBUTE_READ_ONLY;
+ }
+ }
}
+
+ if (rv == CKR_OK)
+ rv = p11_index_set (index, object, template, count);
}
p11_unlock ();