[gnome-keyring/dbus-api] [gck] PKCS#11 objects now track the module they're in.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-keyring/dbus-api] [gck] PKCS#11 objects now track the module they're in.
- Date: Tue, 21 Jul 2009 00:36:57 +0000 (UTC)
commit 3f1bb2106099d6f6e0f11261710b466248d3e726
Author: Stef Walter <stef memberwebs com>
Date: Sat Jul 18 20:13:18 2009 +0000
[gck] PKCS#11 objects now track the module they're in.
Since multiple modules share the same address space, this is
a necessary change for future robustness and changes.
pkcs11/gck/gck-certificate-key.c | 4 +-
pkcs11/gck/gck-certificate-key.h | 3 +-
pkcs11/gck/gck-certificate-trust.c | 4 +-
pkcs11/gck/gck-certificate-trust.h | 3 +-
pkcs11/gck/gck-certificate.c | 5 ++-
pkcs11/gck/gck-object.c | 41 +++++++++++++++++++++++++-
pkcs11/gck/gck-object.h | 2 +
pkcs11/gck/gck-private-key.c | 4 ++-
pkcs11/gck/gck-public-key.c | 4 ++-
pkcs11/gck/tests/unit-test-memory-store.c | 13 +++++++-
pkcs11/gck/tests/unit-test-store.c | 9 ++++++
pkcs11/roots-store/gck-roots-certificate.c | 20 +++++++++++--
pkcs11/roots-store/gck-roots-certificate.h | 3 +-
pkcs11/roots-store/gck-roots-module.c | 2 +-
pkcs11/ssh-store/gck-ssh-module.c | 2 +-
pkcs11/ssh-store/gck-ssh-private-key.c | 11 ++++--
pkcs11/ssh-store/gck-ssh-private-key.h | 3 +-
pkcs11/ssh-store/gck-ssh-public-key.c | 5 ++-
pkcs11/ssh-store/gck-ssh-public-key.h | 3 +-
pkcs11/user-store/gck-user-module.c | 2 +-
pkcs11/user-store/gck-user-private-key.c | 4 ++-
pkcs11/user-store/gck-user-public-key.c | 4 ++-
pkcs11/user-store/gck-user-storage.c | 33 +++++++++++++++++----
pkcs11/user-store/gck-user-storage.h | 2 +-
pkcs11/user-store/tests/.gitignore | 2 +
pkcs11/user-store/tests/Makefile.am | 7 ++++
pkcs11/user-store/tests/p11-tests.conf | 2 +
27 files changed, 159 insertions(+), 38 deletions(-)
---
diff --git a/pkcs11/gck/gck-certificate-key.c b/pkcs11/gck/gck-certificate-key.c
index a671788..f50d3ca 100644
--- a/pkcs11/gck/gck-certificate-key.c
+++ b/pkcs11/gck/gck-certificate-key.c
@@ -137,9 +137,9 @@ gck_certificate_key_class_init (GckCertificateKeyClass *klass)
*/
GckCertificateKey*
-gck_certificate_key_new (GckCertificate *cert)
+gck_certificate_key_new (GckModule *module, GckCertificate *cert)
{
- return g_object_new (GCK_TYPE_CERTIFICATE_KEY, "certificate", cert, NULL);
+ return g_object_new (GCK_TYPE_CERTIFICATE_KEY, "module", module, "certificate", cert, NULL);
}
GckCertificate*
diff --git a/pkcs11/gck/gck-certificate-key.h b/pkcs11/gck/gck-certificate-key.h
index 15bc6a2..1535e7b 100644
--- a/pkcs11/gck/gck-certificate-key.h
+++ b/pkcs11/gck/gck-certificate-key.h
@@ -48,7 +48,8 @@ struct _GckCertificateKeyClass {
GType gck_certificate_key_get_type (void);
-GckCertificateKey* gck_certificate_key_new (GckCertificate *cert);
+GckCertificateKey* gck_certificate_key_new (GckModule *module,
+ GckCertificate *cert);
GckCertificate* gck_certificate_key_get_certificate (GckCertificateKey *self);
diff --git a/pkcs11/gck/gck-certificate-trust.c b/pkcs11/gck/gck-certificate-trust.c
index 8910daa..40b2355 100644
--- a/pkcs11/gck/gck-certificate-trust.c
+++ b/pkcs11/gck/gck-certificate-trust.c
@@ -360,9 +360,9 @@ gck_certificate_trust_class_init (GckCertificateTrustClass *klass)
*/
GckCertificateTrust*
-gck_certificate_trust_new (GckCertificate *cert)
+gck_certificate_trust_new (GckModule *module, GckCertificate *cert)
{
- return g_object_new (GCK_TYPE_CERTIFICATE_TRUST, "certificate", cert, NULL);
+ return g_object_new (GCK_TYPE_CERTIFICATE_TRUST, "module", module, "certificate", cert, NULL);
}
GckCertificate*
diff --git a/pkcs11/gck/gck-certificate-trust.h b/pkcs11/gck/gck-certificate-trust.h
index cb6a4ce..518ad16 100644
--- a/pkcs11/gck/gck-certificate-trust.h
+++ b/pkcs11/gck/gck-certificate-trust.h
@@ -48,7 +48,8 @@ struct _GckCertificateTrustClass {
GType gck_certificate_trust_get_type (void);
-GckCertificateTrust* gck_certificate_trust_new (GckCertificate *cert);
+GckCertificateTrust* gck_certificate_trust_new (GckModule *module,
+ GckCertificate *cert);
GckCertificate* gck_certificate_trust_get_certificate (GckCertificateTrust *self);
diff --git a/pkcs11/gck/gck-certificate.c b/pkcs11/gck/gck-certificate.c
index 98734a3..a024a91 100644
--- a/pkcs11/gck/gck-certificate.c
+++ b/pkcs11/gck/gck-certificate.c
@@ -30,6 +30,7 @@
#include "gck-factory.h"
#include "gck-key.h"
#include "gck-manager.h"
+#include "gck-session.h"
#include "gck-sexp.h"
#include "gck-serializable.h"
#include "gck-transaction.h"
@@ -260,7 +261,7 @@ factory_create_certificate (GckSession *session, GckTransaction *transaction,
return;
}
- cert = g_object_new (GCK_TYPE_CERTIFICATE, NULL);
+ cert = g_object_new (GCK_TYPE_CERTIFICATE, "module", gck_session_get_module (session), NULL);
/* Load the certificate from the data specified */
if (!gck_serializable_load (GCK_SERIALIZABLE (cert), NULL, attr->pValue, attr->ulValueLen)) {
@@ -557,7 +558,7 @@ gck_certificate_real_load (GckSerializable *base, GckLogin *login, const guchar
/* Create ourselves a public key with that */
wrapper = gck_sexp_new (sexp);
if (!self->pv->key)
- self->pv->key = gck_certificate_key_new (self);
+ self->pv->key = gck_certificate_key_new (gck_object_get_module (GCK_OBJECT (self)), self);
gck_key_set_base_sexp (GCK_KEY (self->pv->key), wrapper);
gck_sexp_unref (wrapper);
diff --git a/pkcs11/gck/gck-object.c b/pkcs11/gck/gck-object.c
index b9fef0c..59e156f 100644
--- a/pkcs11/gck/gck-object.c
+++ b/pkcs11/gck/gck-object.c
@@ -36,6 +36,7 @@
enum {
PROP_0,
PROP_HANDLE,
+ PROP_MODULE,
PROP_MANAGER,
PROP_STORE,
PROP_UNIQUE
@@ -55,6 +56,7 @@ typedef struct _GckObjectLifetime {
struct _GckObjectPrivate {
CK_OBJECT_HANDLE handle;
+ GckModule *module;
GckManager *manager;
GckStore *store;
gchar *unique;
@@ -121,6 +123,15 @@ start_callback (GckTransaction *transaction, GObject *obj, gpointer user_data)
return TRUE;
}
+static void
+module_went_away (gpointer data, GObject *old_module)
+{
+ GckObject *self = GCK_OBJECT (data);
+ g_return_if_fail (self->pv->module);
+ g_warning ("module destroyed before object that module contained");
+ self->pv->module = NULL;
+}
+
/* -----------------------------------------------------------------------------
* OBJECT
*/
@@ -244,9 +255,9 @@ static GObject*
gck_object_constructor (GType type, guint n_props, GObjectConstructParam *props)
{
GckObject *self = GCK_OBJECT (G_OBJECT_CLASS (gck_object_parent_class)->constructor(type, n_props, props));
- g_return_val_if_fail (self, NULL);
-
+ g_return_val_if_fail (self, NULL);
+ g_return_val_if_fail (GCK_IS_MODULE (self->pv->module), NULL);
return G_OBJECT (self);
}
@@ -291,6 +302,10 @@ gck_object_finalize (GObject *obj)
g_assert (self->pv->manager == NULL);
g_free (self->pv->unique);
+
+ /* This is done here, as an object must have a module even after dispose */
+ g_object_weak_unref (G_OBJECT (self->pv->module), module_went_away, self);
+ self->pv->module = NULL;
g_assert (self->pv->lifetime == NULL);
@@ -309,6 +324,12 @@ gck_object_set_property (GObject *obj, guint prop_id, const GValue *value,
case PROP_HANDLE:
gck_object_set_handle (self, g_value_get_ulong (value));
break;
+ case PROP_MODULE:
+ g_return_if_fail (!self->pv->module);
+ self->pv->module = g_value_get_object (value);
+ g_return_if_fail (GCK_IS_MODULE (self->pv->module));
+ g_object_weak_ref (G_OBJECT (self->pv->module), module_went_away, self);
+ break;
case PROP_MANAGER:
manager = g_value_get_object (value);
if (self->pv->manager) {
@@ -357,6 +378,10 @@ gck_object_get_property (GObject *obj, guint prop_id, GValue *value,
case PROP_HANDLE:
g_value_set_ulong (value, gck_object_get_handle (self));
break;
+ case PROP_MODULE:
+ g_return_if_fail (GCK_IS_MODULE (self->pv->module));
+ g_value_set_object (value, gck_object_get_module (self));
+ break;
case PROP_MANAGER:
g_value_set_object (value, gck_object_get_manager (self));
break;
@@ -395,6 +420,10 @@ gck_object_class_init (GckObjectClass *klass)
g_param_spec_ulong ("handle", "Handle", "Object handle",
0, G_MAXULONG, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_MODULE,
+ g_param_spec_object ("module", "Module", "Object module",
+ GCK_TYPE_MODULE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (gobject_class, PROP_MANAGER,
g_param_spec_object ("manager", "Manager", "Object manager",
GCK_TYPE_MANAGER, G_PARAM_READWRITE));
@@ -545,6 +574,14 @@ gck_object_get_manager (GckObject *self)
return self->pv->manager;
}
+GckModule*
+gck_object_get_module (GckObject *self)
+{
+ g_return_val_if_fail (GCK_IS_OBJECT (self), NULL);
+ g_return_val_if_fail (GCK_IS_MODULE (self->pv->module), NULL);
+ return self->pv->module;
+}
+
const gchar*
gck_object_get_unique (GckObject *self)
{
diff --git a/pkcs11/gck/gck-object.h b/pkcs11/gck/gck-object.h
index a1129c8..0a3b065 100644
--- a/pkcs11/gck/gck-object.h
+++ b/pkcs11/gck/gck-object.h
@@ -69,6 +69,8 @@ CK_OBJECT_HANDLE gck_object_get_handle (GckObject *self);
void gck_object_set_handle (GckObject *self,
CK_OBJECT_HANDLE handle);
+GckModule* gck_object_get_module (GckObject *self);
+
GckManager* gck_object_get_manager (GckObject *self);
const gchar* gck_object_get_unique (GckObject *self);
diff --git a/pkcs11/gck/gck-private-key.c b/pkcs11/gck/gck-private-key.c
index 46136d1..cd86093 100644
--- a/pkcs11/gck/gck-private-key.c
+++ b/pkcs11/gck/gck-private-key.c
@@ -26,6 +26,7 @@
#include "gck-attributes.h"
#include "gck-factory.h"
#include "gck-private-key.h"
+#include "gck-session.h"
#include "gck-transaction.h"
#include "gck-util.h"
@@ -156,7 +157,8 @@ factory_create_private_key (GckSession *session, GckTransaction *transaction,
if (sexp == NULL)
return;
- *object = g_object_new (GCK_TYPE_PRIVATE_KEY, "base-sexp", sexp, NULL);
+ *object = g_object_new (GCK_TYPE_PRIVATE_KEY, "base-sexp", sexp,
+ "module", gck_session_get_module (session), NULL);
gck_private_key_store_private (GCK_PRIVATE_KEY (*object), sexp, G_MAXUINT);
gck_sexp_unref (sexp);
}
diff --git a/pkcs11/gck/gck-public-key.c b/pkcs11/gck/gck-public-key.c
index 9642b8d..404474c 100644
--- a/pkcs11/gck/gck-public-key.c
+++ b/pkcs11/gck/gck-public-key.c
@@ -27,6 +27,7 @@
#include "gck-crypto.h"
#include "gck-factory.h"
#include "gck-public-key.h"
+#include "gck-session.h"
#include "gck-transaction.h"
#include "gck-util.h"
@@ -149,7 +150,8 @@ factory_create_public_key (GckSession *session, GckTransaction *transaction,
sexp = gck_public_key_create_sexp (session, transaction, attrs, n_attrs);
if (sexp != NULL) {
- *object = g_object_new (GCK_TYPE_PUBLIC_KEY, "base-sexp", sexp, NULL);
+ *object = g_object_new (GCK_TYPE_PUBLIC_KEY, "base-sexp", sexp,
+ "module", gck_session_get_module (session), NULL);
gck_sexp_unref (sexp);
}
}
diff --git a/pkcs11/gck/tests/unit-test-memory-store.c b/pkcs11/gck/tests/unit-test-memory-store.c
index 5aa69f0..880e867 100644
--- a/pkcs11/gck/tests/unit-test-memory-store.c
+++ b/pkcs11/gck/tests/unit-test-memory-store.c
@@ -27,11 +27,13 @@
#include <unistd.h>
#include "run-auto-test.h"
+#include "test-module.h"
#include "gck/gck-object.h"
#include "gck/gck-memory-store.h"
#include "gck/gck-transaction.h"
+static GckModule *module = NULL;
static GckStore *store = NULL;
static GckObject *object = NULL;
static GckTransaction *transaction = NULL;
@@ -61,11 +63,14 @@ DEFINE_SETUP(memory_store)
{
CK_ATTRIBUTE attr;
CK_ULONG twentyfour = 24;
+
+ module = test_module_initialize ();
+ test_module_enter ();
attr.type = CKA_LABEL;
attr.pValue = "label";
attr.ulValueLen = 5;
-
+
store = GCK_STORE (gck_memory_store_new ());
gck_store_register_schema (store, &attr, test_validator, 0);
@@ -83,7 +88,7 @@ DEFINE_SETUP(memory_store)
gck_store_register_schema (store, &attr, NULL, GCK_STORE_IS_INTERNAL);
- object = g_object_new (GCK_TYPE_OBJECT, NULL);
+ object = g_object_new (GCK_TYPE_OBJECT, "module", module, NULL);
transaction = gck_transaction_new ();
}
@@ -99,6 +104,10 @@ DEFINE_TEARDOWN(memory_store)
if (object != NULL)
g_object_unref (object);
object = NULL;
+
+ test_module_leave ();
+ test_module_finalize ();
+ module = NULL;
}
DEFINE_TEST(get_attribute_default)
diff --git a/pkcs11/gck/tests/unit-test-store.c b/pkcs11/gck/tests/unit-test-store.c
index cf5d8f9..a53fd14 100644
--- a/pkcs11/gck/tests/unit-test-store.c
+++ b/pkcs11/gck/tests/unit-test-store.c
@@ -27,13 +27,18 @@
#include <unistd.h>
#include "run-auto-test.h"
+#include "test-module.h"
#include "gck/gck-store.h"
+static GckModule *module = NULL;
static GckStore *store = NULL;
DEFINE_SETUP(store)
{
+ module = test_module_initialize ();
+ test_module_enter ();
+
store = g_object_new (GCK_TYPE_STORE, NULL);
}
@@ -41,6 +46,10 @@ DEFINE_TEARDOWN(store)
{
g_object_unref (store);
store = NULL;
+
+ test_module_leave ();
+ test_module_finalize ();
+ module = NULL;
}
DEFINE_TEST(store_schema)
diff --git a/pkcs11/roots-store/gck-roots-certificate.c b/pkcs11/roots-store/gck-roots-certificate.c
index 9357ffb..b3f11da 100644
--- a/pkcs11/roots-store/gck-roots-certificate.c
+++ b/pkcs11/roots-store/gck-roots-certificate.c
@@ -80,7 +80,19 @@ gck_roots_certificate_get_attribute (GckObject *base, CK_ATTRIBUTE_PTR attr)
static void
gck_roots_certificate_init (GckRootsCertificate *self)
{
- self->trust = gck_certificate_trust_new (GCK_CERTIFICATE (self));
+
+}
+
+static GObject*
+gck_roots_certificate_constructor (GType type, guint n_props, GObjectConstructParam *props)
+{
+ GckRootsCertificate *self = GCK_ROOTS_CERTIFICATE (G_OBJECT_CLASS (gck_roots_certificate_parent_class)->constructor(type, n_props, props));
+ g_return_val_if_fail (self, NULL);
+
+ self->trust = gck_certificate_trust_new (gck_object_get_module (GCK_OBJECT (self)),
+ GCK_CERTIFICATE (self));
+
+ return G_OBJECT (self);
}
static void
@@ -148,6 +160,7 @@ gck_roots_certificate_class_init (GckRootsCertificateClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GckObjectClass *gck_class = GCK_OBJECT_CLASS (klass);
+ gobject_class->constructor = gck_roots_certificate_constructor;
gobject_class->dispose = gck_roots_certificate_dispose;
gobject_class->finalize = gck_roots_certificate_finalize;
gobject_class->set_property = gck_roots_certificate_set_property;
@@ -169,9 +182,10 @@ gck_roots_certificate_class_init (GckRootsCertificateClass *klass)
*/
GckRootsCertificate*
-gck_roots_certificate_new (const gchar *unique, const gchar *path)
+gck_roots_certificate_new (GckModule *module, const gchar *unique, const gchar *path)
{
- return g_object_new (GCK_TYPE_ROOTS_CERTIFICATE, "unique", unique, "path", path, NULL);
+ return g_object_new (GCK_TYPE_ROOTS_CERTIFICATE, "unique", unique, "path", path,
+ "module", module, NULL);
}
const gchar*
diff --git a/pkcs11/roots-store/gck-roots-certificate.h b/pkcs11/roots-store/gck-roots-certificate.h
index f33899f..85b7708 100644
--- a/pkcs11/roots-store/gck-roots-certificate.h
+++ b/pkcs11/roots-store/gck-roots-certificate.h
@@ -42,7 +42,8 @@ struct _GckRootsCertificateClass {
GType gck_roots_certificate_get_type (void);
-GckRootsCertificate* gck_roots_certificate_new (const gchar *hash,
+GckRootsCertificate* gck_roots_certificate_new (GckModule *module,
+ const gchar *hash,
const gchar *path);
const gchar* gck_roots_certificate_get_unique (GckRootsCertificate *self);
diff --git a/pkcs11/roots-store/gck-roots-module.c b/pkcs11/roots-store/gck-roots-module.c
index 730eaf0..cbeef94 100644
--- a/pkcs11/roots-store/gck-roots-module.c
+++ b/pkcs11/roots-store/gck-roots-module.c
@@ -117,7 +117,7 @@ add_certificate_for_data (GckRootsModule *self, const guchar *data,
}
/* Create a new certificate object */
- cert = GCK_CERTIFICATE (gck_roots_certificate_new (unique, path));
+ cert = GCK_CERTIFICATE (gck_roots_certificate_new (GCK_MODULE (self), unique, path));
if (!gck_serializable_load (GCK_SERIALIZABLE (cert), NULL, data, n_data)) {
g_message ("couldn't parse certificate(s): %s", path);
diff --git a/pkcs11/ssh-store/gck-ssh-module.c b/pkcs11/ssh-store/gck-ssh-module.c
index 3ac9f63..f2fa2e6 100644
--- a/pkcs11/ssh-store/gck-ssh-module.c
+++ b/pkcs11/ssh-store/gck-ssh-module.c
@@ -118,7 +118,7 @@ file_load (GckFileTracker *tracker, const gchar *path, GckSshModule *self)
key = g_hash_table_lookup (self->keys_by_path, path);
if (key == NULL) {
unique = g_strdup_printf ("ssh-store:%s", private_path);
- key = gck_ssh_private_key_new (unique);
+ key = gck_ssh_private_key_new (GCK_MODULE (self), unique);
g_free (unique);
g_hash_table_replace (self->keys_by_path, g_strdup (path), key);
diff --git a/pkcs11/ssh-store/gck-ssh-private-key.c b/pkcs11/ssh-store/gck-ssh-private-key.c
index 2a35839..60f1af3 100644
--- a/pkcs11/ssh-store/gck-ssh-private-key.c
+++ b/pkcs11/ssh-store/gck-ssh-private-key.c
@@ -169,12 +169,14 @@ static GObject*
gck_ssh_private_key_constructor (GType type, guint n_props, GObjectConstructParam *props)
{
GckSshPrivateKey *self = GCK_SSH_PRIVATE_KEY (G_OBJECT_CLASS (gck_ssh_private_key_parent_class)->constructor(type, n_props, props));
+ GckObject *object;
gchar *unique;
g_return_val_if_fail (self, NULL);
- unique = g_strdup_printf ("%s.pub", gck_object_get_unique (GCK_OBJECT (self)));
- self->pubkey = gck_ssh_public_key_new (unique);
+ object = GCK_OBJECT (self);
+ unique = g_strdup_printf ("%s.pub", gck_object_get_unique (object));
+ self->pubkey = gck_ssh_public_key_new (gck_object_get_module (object), unique);
g_free (unique);
return G_OBJECT (self);
@@ -278,9 +280,10 @@ gck_ssh_private_key_class_init (GckSshPrivateKeyClass *klass)
*/
GckSshPrivateKey*
-gck_ssh_private_key_new (const gchar *unique)
+gck_ssh_private_key_new (GckModule *module, const gchar *unique)
{
- return g_object_new (GCK_TYPE_SSH_PRIVATE_KEY, "unique", unique, NULL);
+ return g_object_new (GCK_TYPE_SSH_PRIVATE_KEY, "unique", unique,
+ "module", module, NULL);
}
gboolean
diff --git a/pkcs11/ssh-store/gck-ssh-private-key.h b/pkcs11/ssh-store/gck-ssh-private-key.h
index 1218aaf..3cc95be 100644
--- a/pkcs11/ssh-store/gck-ssh-private-key.h
+++ b/pkcs11/ssh-store/gck-ssh-private-key.h
@@ -44,7 +44,8 @@ struct _GckSshPrivateKeyClass {
GType gck_ssh_private_key_get_type (void);
-GckSshPrivateKey* gck_ssh_private_key_new (const gchar *unique);
+GckSshPrivateKey* gck_ssh_private_key_new (GckModule *module,
+ const gchar *unique);
gboolean gck_ssh_private_key_parse (GckSshPrivateKey *self,
const gchar *public_path,
diff --git a/pkcs11/ssh-store/gck-ssh-public-key.c b/pkcs11/ssh-store/gck-ssh-public-key.c
index 879c8ba..561d38c 100644
--- a/pkcs11/ssh-store/gck-ssh-public-key.c
+++ b/pkcs11/ssh-store/gck-ssh-public-key.c
@@ -129,9 +129,10 @@ gck_ssh_public_key_class_init (GckSshPublicKeyClass *klass)
*/
GckSshPublicKey*
-gck_ssh_public_key_new (const gchar *unique)
+gck_ssh_public_key_new (GckModule *module, const gchar *unique)
{
- return g_object_new (GCK_TYPE_SSH_PUBLIC_KEY, "unique", unique, NULL);
+ return g_object_new (GCK_TYPE_SSH_PUBLIC_KEY, "unique", unique,
+ "module", module, NULL);
}
const gchar*
diff --git a/pkcs11/ssh-store/gck-ssh-public-key.h b/pkcs11/ssh-store/gck-ssh-public-key.h
index a7093ef..1d92098 100644
--- a/pkcs11/ssh-store/gck-ssh-public-key.h
+++ b/pkcs11/ssh-store/gck-ssh-public-key.h
@@ -42,7 +42,8 @@ struct _GckSshPublicKeyClass {
GType gck_ssh_public_key_get_type (void);
-GckSshPublicKey* gck_ssh_public_key_new (const gchar *unique);
+GckSshPublicKey* gck_ssh_public_key_new (GckModule *self,
+ const gchar *unique);
const gchar* gck_ssh_public_key_get_label (GckSshPublicKey *key);
diff --git a/pkcs11/user-store/gck-user-module.c b/pkcs11/user-store/gck-user-module.c
index d2d28ff..a916550 100644
--- a/pkcs11/user-store/gck-user-module.c
+++ b/pkcs11/user-store/gck-user-module.c
@@ -260,7 +260,7 @@ gck_user_module_constructor (GType type, guint n_props, GObjectConstructParam *p
if (!self->directory)
self->directory = g_build_filename (g_get_home_dir (), ".gnome2", "keyrings", NULL);
- self->storage = gck_user_storage_new (gck_module_get_manager (GCK_MODULE (self)), self->directory);
+ self->storage = gck_user_storage_new (GCK_MODULE (self), self->directory);
return G_OBJECT (self);
}
diff --git a/pkcs11/user-store/gck-user-private-key.c b/pkcs11/user-store/gck-user-private-key.c
index 7ec5422..60e7740 100644
--- a/pkcs11/user-store/gck-user-private-key.c
+++ b/pkcs11/user-store/gck-user-private-key.c
@@ -31,6 +31,7 @@
#include "gck/gck-manager.h"
#include "gck/gck-object.h"
#include "gck/gck-serializable.h"
+#include "gck/gck-session.h"
#include "gck/gck-sexp.h"
#include "gck/gck-util.h"
@@ -74,7 +75,8 @@ factory_create_private_key (GckSession *session, GckTransaction *transaction,
if (sexp == NULL)
return;
- key = g_object_new (GCK_TYPE_USER_PRIVATE_KEY, "base-sexp", sexp, NULL);
+ key = g_object_new (GCK_TYPE_USER_PRIVATE_KEY, "base-sexp", sexp,
+ "module", gck_session_get_module (session), NULL);
g_return_if_fail (!key->private_sexp);
key->private_sexp = gck_sexp_ref (sexp);
diff --git a/pkcs11/user-store/gck-user-public-key.c b/pkcs11/user-store/gck-user-public-key.c
index b0a6563..a9c750d 100644
--- a/pkcs11/user-store/gck-user-public-key.c
+++ b/pkcs11/user-store/gck-user-public-key.c
@@ -27,6 +27,7 @@
#include "gck/gck-data-der.h"
#include "gck/gck-factory.h"
#include "gck/gck-serializable.h"
+#include "gck/gck-session.h"
#include "gck/gck-object.h"
#include "gck/gck-util.h"
@@ -56,7 +57,8 @@ factory_create_public_key (GckSession *session, GckTransaction *transaction,
sexp = gck_public_key_create_sexp (session, transaction, attrs, n_attrs);
if (sexp != NULL) {
- *object = g_object_new (GCK_TYPE_USER_PUBLIC_KEY, "base-sexp", sexp, NULL);
+ *object = g_object_new (GCK_TYPE_USER_PUBLIC_KEY, "base-sexp", sexp,
+ "module", gck_session_get_module (session), NULL);
gck_sexp_unref (sexp);
}
}
diff --git a/pkcs11/user-store/gck-user-storage.c b/pkcs11/user-store/gck-user-storage.c
index 87ac6c9..12c2263 100644
--- a/pkcs11/user-store/gck-user-storage.c
+++ b/pkcs11/user-store/gck-user-storage.c
@@ -30,6 +30,7 @@
#include "gck/gck-data-file.h"
#include "gck/gck-login.h"
#include "gck/gck-manager.h"
+#include "gck/gck-module.h"
#include "gck/gck-serializable.h"
#include "gck/gck-util.h"
@@ -49,6 +50,7 @@
enum {
PROP_0,
+ PROP_MODULE,
PROP_DIRECTORY,
PROP_MANAGER,
PROP_LOGIN
@@ -57,6 +59,7 @@ enum {
struct _GckUserStorage {
GckStore parent;
+ GckModule *module;
GckManager *manager;
/* Information about file data */
@@ -547,7 +550,7 @@ data_file_entry_added (GckDataFile *store, const gchar *identifier, GckUserStora
}
/* Create a new object for this identifier */
- object = g_object_new (type, "unique", identifier, NULL);
+ object = g_object_new (type, "unique", identifier, "module", self->module, NULL);
g_return_if_fail (GCK_IS_SERIALIZABLE (object));
g_return_if_fail (GCK_SERIALIZABLE_GET_INTERFACE (object)->extension);
@@ -618,7 +621,7 @@ relock_object (GckUserStorage *self, GckTransaction *transaction, const gchar *p
}
/* Create a dummy object for this identifier */
- object = g_object_new (type, "unique", identifier, NULL);
+ object = g_object_new (type, "unique", identifier, "module", self->module, NULL);
if (!GCK_IS_SERIALIZABLE (object)) {
g_warning ("cannot relock unserializable object for file in user store: %s", identifier);
gck_transaction_fail (transaction, CKR_GENERAL_ERROR);
@@ -865,6 +868,7 @@ gck_user_storage_constructor (GType type, guint n_props, GObjectConstructParam *
self->filename = g_build_filename (self->directory, "user.keystore", NULL);
g_return_val_if_fail (self->manager, NULL);
+ g_return_val_if_fail (self->module, NULL);
return G_OBJECT (self);
}
@@ -939,6 +943,10 @@ gck_user_storage_set_property (GObject *obj, guint prop_id, const GValue *value,
self->directory = g_value_dup_string (value);
g_return_if_fail (self->directory);
break;
+ case PROP_MODULE:
+ g_return_if_fail (!self->module);
+ self->module = g_value_get_object (value);
+ break;
case PROP_MANAGER:
g_return_if_fail (!self->manager);
self->manager = g_value_dup_object (value);
@@ -960,6 +968,9 @@ gck_user_storage_get_property (GObject *obj, guint prop_id, GValue *value,
case PROP_DIRECTORY:
g_value_set_string (value, gck_user_storage_get_directory (self));
break;
+ case PROP_MODULE:
+ g_value_set_object (value, self->module);
+ break;
case PROP_MANAGER:
g_value_set_object (value, gck_user_storage_get_manager (self));
break;
@@ -991,6 +1002,10 @@ gck_user_storage_class_init (GckUserStorageClass *klass)
g_param_spec_string ("directory", "Storage Directory", "Directory for storage",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (gobject_class, PROP_MODULE,
+ g_param_spec_object ("module", "Module", "Module for objects",
+ GCK_TYPE_MODULE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (gobject_class, PROP_MANAGER,
g_param_spec_object ("manager", "Object Manager", "Object Manager",
GCK_TYPE_MANAGER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
@@ -1005,12 +1020,18 @@ gck_user_storage_class_init (GckUserStorageClass *klass)
*/
GckUserStorage*
-gck_user_storage_new (GckManager *manager, const gchar *directory)
+gck_user_storage_new (GckModule *module, const gchar *directory)
{
- g_return_val_if_fail (GCK_IS_MANAGER (manager), NULL);
- g_return_val_if_fail (directory, NULL);
+ GckManager *manager;
- return g_object_new (GCK_TYPE_USER_STORAGE,
+ g_return_val_if_fail (GCK_IS_MODULE (module), NULL);
+ g_return_val_if_fail (directory, NULL);
+
+ manager = gck_module_get_manager (module);
+ g_return_val_if_fail (GCK_IS_MANAGER (manager), NULL);
+
+ return g_object_new (GCK_TYPE_USER_STORAGE,
+ "module", module,
"manager", manager,
"directory", directory,
NULL);
diff --git a/pkcs11/user-store/gck-user-storage.h b/pkcs11/user-store/gck-user-storage.h
index 07dd1c9..29faf41 100644
--- a/pkcs11/user-store/gck-user-storage.h
+++ b/pkcs11/user-store/gck-user-storage.h
@@ -45,7 +45,7 @@ struct _GckUserStorageClass {
GType gck_user_storage_get_type (void);
-GckUserStorage* gck_user_storage_new (GckManager *manager,
+GckUserStorage* gck_user_storage_new (GckModule *module,
const gchar *directory);
GckManager* gck_user_storage_get_manager (GckUserStorage *self);
diff --git a/pkcs11/user-store/tests/.gitignore b/pkcs11/user-store/tests/.gitignore
new file mode 100644
index 0000000..b336cc7
--- /dev/null
+++ b/pkcs11/user-store/tests/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/pkcs11/user-store/tests/Makefile.am b/pkcs11/user-store/tests/Makefile.am
new file mode 100644
index 0000000..e5fb1f7
--- /dev/null
+++ b/pkcs11/user-store/tests/Makefile.am
@@ -0,0 +1,7 @@
+
+# Nothing to do
+all:
+
+p11-tests:
+ p11-tests -f p11-tests.conf ../.libs/gck-user-store-standalone.so
+
\ No newline at end of file
diff --git a/pkcs11/user-store/tests/p11-tests.conf b/pkcs11/user-store/tests/p11-tests.conf
new file mode 100644
index 0000000..f81687e
--- /dev/null
+++ b/pkcs11/user-store/tests/p11-tests.conf
@@ -0,0 +1,2 @@
+# Configuration for running p11-tests on this module
+init-string = directory='test-data'
diff --git a/pkcs11/user-store/tests/test-data/.gitempty b/pkcs11/user-store/tests/test-data/.gitempty
new file mode 100644
index 0000000..e69de29
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]