After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 680652 - gcr_pkcs11_get_modules() returns NULL when not initialized
gcr_pkcs11_get_modules() returns NULL when not initialized
Status: RESOLVED FIXED
Product: gcr
Classification: Core
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME keyring maintainer(s)
GNOME keyring maintainer(s)
Depends on:
Blocks: 680653
 
 
Reported: 2012-07-26 14:05 UTC by Stef Walter
Modified: 2019-02-22 11:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gcr: Don't fail preconditions when pkcs11 isn't initialized (3.24 KB, patch)
2012-07-26 14:52 UTC, Stef Walter
none Details | Review
gcr: Don't fail preconditions when pkcs11 isn't initialized (3.24 KB, patch)
2012-07-26 17:03 UTC, Stef Walter
committed Details | Review

Description Stef Walter 2012-07-26 14:05:19 UTC
gcr_pkcs11_get_modules() should return an empty list if no gcr_pkcs11_initialize() yet. It shouldn't need to warn about this.

We use gcr_pkcs11_get_modules() in various code that doesn't expect to do a long running operation like gcr_pkcs11_initialize(). So gcr_pkcs11_initialize() needs to be called separately before use of the pkcs11 stuff.
Comment 1 Stef Walter 2012-07-26 14:52:48 UTC
Created attachment 219693 [details] [review]
gcr: Don't fail preconditions when pkcs11 isn't initialized

 * Callers should initialize pkcs11 early, because initialize can
   be a long running call, and should be handled appropriately in
   the user interface.
Comment 2 Dan Winship 2012-07-26 15:14:29 UTC
Comment on attachment 219693 [details] [review]
gcr: Don't fail preconditions when pkcs11 isn't initialized

>+ * An empty list of modules will be returnef if gcr_pkcs11_set_modules(),
                                             ^ typo

but isn't return-if-fail correct? You shouldn't be calling gcr_pkcs11_get_modules() if you haven't initialized gcr-pkcs11...
Comment 3 Stef Walter 2012-07-26 17:02:26 UTC
(In reply to comment #2)
> (From update of attachment 219693 [details] [review])
> >+ * An empty list of modules will be returnef if gcr_pkcs11_set_modules(),
>                                              ^ typo
> 
> but isn't return-if-fail correct? You shouldn't be calling
> gcr_pkcs11_get_modules() if you haven't initialized gcr-pkcs11...

Yeah, that's what I thought at first too but: We call gcr_pkcs11_get_modules() from the GcrPkcs11Importer. gcr_importer_create_for_parsed() calls for all registered importers, of which GcrPkcs11Importer is one. Not all importers use PKCS#11 modules. So we want the GcrPkcs11Importer to be a noop if PKCS#11 hasn't been initialized.

Another way to do that is to only register the GcrPkcs11Importer once pkcs11 modules have been initialized. Does that seem better?
Comment 4 Stef Walter 2012-07-26 17:03:22 UTC
Created attachment 219705 [details] [review]
gcr: Don't fail preconditions when pkcs11 isn't initialized

* Callers should initialize pkcs11 early, because initialize can
   be a long running call, and should be handled appropriately in
   the user interface.
Comment 5 Stef Walter 2012-08-16 11:04:25 UTC
Attachment 219705 [details] pushed as a6fe45c - gcr: Don't fail preconditions when pkcs11 isn't initialized