Stef Walter [Tue, 29 Jan 2013 10:43:09 +0000 (11:43 +0100)]
Make the p11-kit tool have distinct commands
* Change the -l argument into the list-modules command.
* Add proper functions for printing usage
* Support for external commands in the path or /usr/share/p11-kit
Stef Walter [Thu, 24 Jan 2013 13:36:59 +0000 (14:36 +0100)]
Further tweaks and cleanup for functions dealing with PKCS#11 attributes
* Check that the size is correct when looking for a boolean
or a ulong.
* Make sure that the length is not the invalid negative ulong.
* Functions for dumping out attribute contents
* Make it possible to use attributes in hash tables
Stef Walter [Wed, 23 Jan 2013 13:29:25 +0000 (14:29 +0100)]
Use the stdbool.h C99 bool type
It was getting really wild knowing whether a function returning
an int would return -1 on failure or 0 or whether the int return
value was actually a number etc..
Stef Walter [Wed, 2 Jan 2013 15:52:02 +0000 (16:52 +0100)]
Move the pkcs11.h header files into common directory
* Allows use of them across the whole project
* Put a stub file in the p11-kit/ directory, so we can still refer
to the headers using that path, which is what it will be at
when in the installed includes directory.
Stef Walter [Mon, 7 Jan 2013 10:01:09 +0000 (11:01 +0100)]
Fix documentation warnings.
* P11_KIT_URI_NO_MEMORY is an unexpected state, that will probably
never actually be returned. But kept for API compatibility.
* make distcheck doc fix
Stef Walter [Mon, 7 Jan 2013 08:20:25 +0000 (09:20 +0100)]
Guarantee that the key is freed when replaced
* When setting a key in a map that already exists, then free
the old key and replace with the new one.
* Fix related bug where key was not properly allocated
* Add tests for this
Stef Walter [Tue, 18 Sep 2012 14:26:06 +0000 (16:26 +0200)]
Refuse to load the p11-kit-proxy.so as a registered module
* Since p11-kit-proxy.so is a symlink to the libp11-kit.so library
we check that we are not calling into our known CK_FUNCTION_LIST
for the proxy code.
* Although such a configuration is invalid, detecting this directly
prevents strange initialization loop issues that are hard to debug.
Stef Walter [Tue, 18 Sep 2012 12:01:54 +0000 (14:01 +0200)]
Don't fail initialization if last initialized module fails
* We weren't resetting the result code after a failure,
so even though failures for critical modules didn't interrupt
the initialization loop, the result still leaked to callers.
* Also print an error message clearly indicating that a module
failed to initialize, regardless of whether critical or not.
Stef Walter [Thu, 6 Sep 2012 09:01:57 +0000 (11:01 +0200)]
Change the default of 'user-config' to merge.
* This allows user configured PKCS#11 modules by default.
* Admins can change this to 'none' in /etc/pkcs11/pkcs11.conf
to go back to the previous behavior.
* Posted to the mailing list.
Stef Walter [Tue, 17 Jul 2012 06:08:04 +0000 (08:08 +0200)]
Don't rely on loading order for duplicate modules
* We had relied on module 'two' loading before 'two-duplicate'
in the conf tests. However this isn't always the case, and the
name of the module can end up as 'two-duplicate'
Stef Walter [Tue, 17 Jul 2012 06:06:28 +0000 (08:06 +0200)]
Use Windows thread ids instead of handles for comparisons
* It seems that the HANDLE's returned from GetCurrentThread
are often equal for two threads. GetCurrentThreadID doesn't
have this problem.
* Separate our cross platform thread_t and thread_id_t types
even though on unix they're the same thing.
Stef Walter [Mon, 16 Jul 2012 15:56:24 +0000 (17:56 +0200)]
Use '.module' extension on module configs
* And want alphanumeric/_.- filenames
* Currently this is just a warning, soon it will be enforced
* The name of a module does not include the extension
Andreas Metzler and Ubuntu both worked on this patch, and I've made
some more changes.
See https://bugs.launchpad.net/ubuntu/+source/p11-kit/+bug/911436
Stef Walter [Fri, 8 Jun 2012 07:29:59 +0000 (09:29 +0200)]
Fix the flags in pin.h
* Due to a brain fart the P11_KIT_PIN_* flags were not
bit flags but decimal numbers.
* This necessarily breaks API/ABI for users of the
P11_KIT_PIN_FLAGS_RETRY, P11_KIT_PIN_FLAGS_MANY_TRIES and
P11_KIT_PIN_FLAGS_FINAL_TRY flags. But those wouldn't have
worked anyway.
Stef Walter [Sun, 13 May 2012 20:27:07 +0000 (22:27 +0200)]
Preconditions to check for input probs and out of memory
* We don't try to guarantee completely robust and problem
free behavior in cases where the caller or process isn't
behaving. We consider these to be outside of our control.
Stef Walter [Sun, 1 Apr 2012 19:53:04 +0000 (21:53 +0200)]
Add enable-in and disable-in options to module config
* These can be used to load certain modules in certain
programs, or prevent loading in others.
* Useful for a key manager like seahorse, so we can load
extra modules (think NSS) that other modules shouldn't
load.
Stef Walter [Tue, 27 Mar 2012 10:14:56 +0000 (12:14 +0200)]
Fix broken hashmap behavior
* We were relying on undefined gcc behavior related to the &
operator.
* This would show up as a test failure when running with -O2 on
certain GCC versions, as well as failure on clang 3.1
Stef Walter [Mon, 23 Jan 2012 08:09:31 +0000 (09:09 +0100)]
Remove automatic reinitialization of PKCS#11 after fork
* First of all one should only call async-signal-safe functions
from the callbacks of pthread_atfork(), and so we cannot
reinitialize directly.
* Some modules use pthread_atfork() to detect forking and setup
their internal state. If we call into them in our pthread_atfork()
callback then this is inherently racy.
* There was danger of endless loops and deadlocks which are caused
by handlers which fork in their C_Initialize
* Many processes do fork/exec, reinitializing PKCS#11 for these
forks is quite resourc intensive when the child process won't use
PKCS#11 at all.
Stef Walter [Tue, 20 Dec 2011 14:18:37 +0000 (15:18 +0100)]
Reorganize tests, work around optimization bug
* Encountered a gcc optimization bug in gcc 4.6.1 which seems to
be reordering related function calls eroneously. This bug seems
to be fixed in 4.6.2.
* Reorganize test code to get around this bug building on mingw,
and ubuntu 11.10, both of which use gcc 4.6.1
Stef Walter [Sat, 29 Oct 2011 07:46:02 +0000 (00:46 -0700)]
Make build not depend on gtk-doc or pkg-config
* If enabled, gtk-doc can be used, but we no longer expect the
gtkdoc autoconf/automake macro files to be installed.
* pkg-config is no longer used for checks.
* We still do install pkg-config files, and this is the preferred
way to build against and link to p11-kit.
Stef Walter [Mon, 17 Oct 2011 12:51:31 +0000 (14:51 +0200)]
Initial port to win32
* Tests do not all yet pass, at least not on wine
* Added abstraction of some non-portable functions in compat.h/c
* Build with an argument like this for win32 support:
./autogen.sh --host=i586-mingw32msvc
* This win32 port needs more work from interested parties
Stef Walter [Mon, 10 Oct 2011 15:32:34 +0000 (17:32 +0200)]
Only call C_Initialize and C_Finalize once per module
* Do not concurretnly call C_Initialize or C_Finalize in a module
* The PKCS#11 spec indicates that mone thread should call those functions.
* It's reasonable for a module to expect to only be initialized or
finalized in one thread.
* In particular NSS does not lock its C_Initialize or C_Finalize.
Kalev Lember [Wed, 14 Sep 2011 05:10:46 +0000 (08:10 +0300)]
When a module has a relative path, load it from $libdir/pkcs11
So far we have only supported full paths to the pkcs11 modules in config
files. This change adds relative path support, so that for modules
installed under the standard $libdir/pkcs11, the config file won't have
to spell out the full path.