From fcc3a83cc4d540bc2c4096524b5e8003046ba561 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 2 Apr 2013 20:40:53 +0200 Subject: Separate library init from message code Put library init/uninit code its into their own statically linked library so that they don't get linked into the p11-kit executable. Refactor the message code so that the library initialization can plug in its per thread message buffer. https://bugs.freedesktop.org/show_bug.cgi?id=63046 --- common/Makefile.am | 15 ++--- common/lexer.c | 2 +- common/library.c | 85 +++++--------------------- common/library.h | 14 ----- common/message.c | 140 +++++++++++++++++++++++++++++++++++++++++++ common/message.h | 62 +++++++++++++++++++ common/mock.c | 2 +- common/tests/Makefile.am | 3 +- common/tests/test-base64.c | 5 +- common/tests/test-lexer.c | 3 +- common/tests/test-url.c | 5 +- p11-kit/Makefile.am | 2 +- p11-kit/conf.c | 2 +- p11-kit/modules.c | 1 + p11-kit/pin.c | 1 + p11-kit/proxy.c | 1 + p11-kit/tests/Makefile.am | 6 +- p11-kit/tests/conf-test.c | 31 +++++----- p11-kit/tests/test-iter.c | 1 + p11-kit/tests/test-modules.c | 1 + p11-kit/tests/uri-test.c | 5 +- p11-kit/uri.c | 2 +- p11-kit/util.c | 1 + tools/Makefile.am | 3 +- tools/extract-info.c | 2 +- tools/extract-jks.c | 2 +- tools/extract-openssl.c | 2 +- tools/extract-pem.c | 2 +- tools/extract-x509.c | 2 +- tools/extract.c | 2 +- tools/list.c | 2 +- tools/save.c | 2 +- tools/tests/Makefile.am | 3 +- tools/tests/test-extract.c | 3 +- tools/tests/test-openssl.c | 3 +- tools/tests/test-pem.c | 3 +- tools/tests/test-save.c | 5 +- tools/tests/test-x509.c | 3 +- tools/tool.c | 2 +- trust/Makefile.am | 2 +- trust/builder.c | 2 +- trust/module.c | 1 + trust/parser.c | 2 +- trust/session.c | 2 +- trust/tests/Makefile.am | 5 +- trust/tests/test-builder.c | 3 +- trust/tests/test-index.c | 3 +- trust/tests/test-module.c | 2 - trust/tests/test-parser.c | 3 +- trust/tests/test-persist.c | 3 +- trust/tests/test-token.c | 3 +- trust/token.c | 2 +- 52 files changed, 294 insertions(+), 170 deletions(-) create mode 100644 common/message.c create mode 100644 common/message.h diff --git a/common/Makefile.am b/common/Makefile.am index bfed1d7..cb6e95e 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -10,29 +10,30 @@ inc_HEADERS = \ $(NULL) noinst_LTLIBRARIES = \ - libp11-compat.la \ + libp11-common.la \ libp11-library.la \ libp11-mock.la \ $(NULL) -libp11_compat_la_SOURCES = \ - compat.c compat.h \ - $(NULL) - -libp11_library_la_SOURCES = \ +libp11_common_la_SOURCES = \ attrs.c attrs.h \ array.c array.h \ buffer.c buffer.h \ + compat.c compat.h \ constants.c constants.h \ debug.c debug.h \ dict.c dict.h \ hash.c hash.h \ lexer.c lexer.h \ - library.c library.h \ + message.c message.h \ pkcs11.h pkcs11x.h \ url.c url.h \ $(NULL) +libp11_library_la_SOURCES = \ + library.c library.h \ + $(NULL) + libp11_mock_la_SOURCES = \ mock.c mock.h \ $(NULL) diff --git a/common/lexer.c b/common/lexer.c index 9898e2c..329881f 100644 --- a/common/lexer.c +++ b/common/lexer.c @@ -41,7 +41,7 @@ #define P11_DEBUG_FLAG P11_DEBUG_CONF #include "debug.h" #include "lexer.h" -#include "library.h" +#include "message.h" #include #include diff --git a/common/library.c b/common/library.c index 71dd3b9..1f9dc7a 100644 --- a/common/library.c +++ b/common/library.c @@ -41,6 +41,7 @@ #define P11_DEBUG_FLAG P11_DEBUG_LIB #include "debug.h" #include "library.h" +#include "message.h" #include #include @@ -48,13 +49,10 @@ #include #include -#define P11_MAX_MESSAGE 512 +#define P11_MESSAGE_MAX 512 typedef struct { - char message[P11_MAX_MESSAGE]; -#ifdef OS_WIN32 - void *last_error; -#endif + char message[P11_MESSAGE_MAX]; } p11_local; static p11_local * _p11_library_get_thread_local (void); @@ -65,76 +63,18 @@ p11_mutex_t p11_library_mutex; pthread_once_t p11_library_once; #endif -static bool print_messages = true; - -void -p11_message_store (const char* msg, - size_t length) +static char * +thread_local_message (void) { p11_local *local; - - if (length > P11_MAX_MESSAGE - 1) - length = P11_MAX_MESSAGE - 1; - local = _p11_library_get_thread_local (); - if (local != NULL) { - memcpy (local->message, msg, length); - local->message[length] = 0; - } + return local ? local->message : NULL; } -void -p11_message (const char* msg, - ...) +static char * +dont_store_message (void) { - char buffer[P11_MAX_MESSAGE]; - va_list va; - size_t length; - - va_start (va, msg); - length = vsnprintf (buffer, P11_MAX_MESSAGE - 1, msg, va); - va_end (va); - - /* Was it truncated? */ - if (length > P11_MAX_MESSAGE - 1) - length = P11_MAX_MESSAGE - 1; - buffer[length] = 0; - - /* If printing is not disabled, just print out */ - if (print_messages) - fprintf (stderr, "p11-kit: %s\n", buffer); - else - p11_debug_message (P11_DEBUG_LIB, "message: %s", buffer); - p11_message_store (buffer, length); -} - -void -p11_message_quiet (void) -{ - print_messages = false; -} - -void -p11_message_loud (void) -{ - print_messages = true; -} - -const char* -p11_message_last (void) -{ - p11_local *local; - local = _p11_library_get_thread_local (); - return local && local->message[0] ? local->message : NULL; -} - -void -p11_message_clear (void) -{ - p11_local *local; - local = _p11_library_get_thread_local (); - if (local != NULL) - local->message[0] = 0; + return NULL; } static void @@ -170,6 +110,7 @@ p11_library_init_impl (void) p11_debug ("initializing library"); p11_mutex_init (&p11_library_mutex); pthread_key_create (&thread_local, free); + p11_message_storage = thread_local_message; } void @@ -187,6 +128,7 @@ p11_library_uninit (void) free (pthread_getspecific (thread_local)); pthread_setspecific (thread_local, NULL); + p11_message_storage = dont_store_message; pthread_key_delete (thread_local); p11_mutex_uninit (&p11_library_mutex); } @@ -225,6 +167,8 @@ p11_library_init (void) thread_local = TlsAlloc (); if (thread_local == TLS_OUT_OF_INDEXES) p11_debug ("couldn't setup tls"); + else + p11_message_storage = thread_local_message; } void @@ -234,8 +178,6 @@ p11_library_thread_cleanup (void) if (thread_local != TLS_OUT_OF_INDEXES) { p11_debug ("thread stopped, freeing tls"); local = TlsGetValue (thread_local); - if (local->last_error) - LocalFree (local->last_error); LocalFree (local); } } @@ -248,6 +190,7 @@ p11_library_uninit (void) uninit_common (); if (thread_local != TLS_OUT_OF_INDEXES) { + p11_message_storage = dont_store_message; data = TlsGetValue (thread_local); free (data); TlsFree (thread_local); diff --git a/common/library.h b/common/library.h index b310cb9..33a33fb 100644 --- a/common/library.h +++ b/common/library.h @@ -48,20 +48,6 @@ extern p11_mutex_t p11_library_mutex; #define p11_unlock() p11_mutex_unlock (&p11_library_mutex); -void p11_message (const char* msg, - ...) GNUC_PRINTF (1, 2); - -void p11_message_store (const char* msg, - size_t length); - -const char * p11_message_last (void); - -void p11_message_clear (void); - -void p11_message_quiet (void); - -void p11_message_loud (void); - #ifdef OS_WIN32 /* No implementation, because done by DllMain */ diff --git a/common/message.c b/common/message.c new file mode 100644 index 0000000..8b54ad1 --- /dev/null +++ b/common/message.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2011 Collabora Ltd + * Copyright (c) 2012 Stef Walter + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * * The names of contributors to this software may not be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * + * CONTRIBUTORS + * Stef Walter + */ + +#include "config.h" + +#include "compat.h" +#define P11_DEBUG_FLAG P11_DEBUG_LIB +#include "debug.h" +#include "message.h" + +#include +#include +#include +#include +#include + +static bool print_messages = true; + +static char * +default_message_storage (void) +{ + static char message[P11_MESSAGE_MAX] = { 0, }; + return message; +} + +/* Function pointer declared in message.h as extern */ +char * (* p11_message_storage) (void) = default_message_storage; + +void +p11_message_store (const char* msg, + size_t length) +{ + char *buffer; + + /* + * p11_message_storage() is called to get a storage location for + * the last message. It defaults to a globally allocated buffer + * but is overridden in library.c with a function that returns + * per thread buffers. + * + * The returned value is P11_MESSAGE_MAX bytes long + */ + buffer = p11_message_storage (); + + if (length > P11_MESSAGE_MAX - 1) + length = P11_MESSAGE_MAX - 1; + + if (buffer != NULL) { + memcpy (buffer, msg, length); + buffer[length] = 0; + } +} + +void +p11_message (const char* msg, + ...) +{ + char buffer[P11_MESSAGE_MAX]; + va_list va; + size_t length; + + va_start (va, msg); + length = vsnprintf (buffer, P11_MESSAGE_MAX - 1, msg, va); + va_end (va); + + /* Was it truncated? */ + if (length > P11_MESSAGE_MAX - 1) + length = P11_MESSAGE_MAX - 1; + buffer[length] = 0; + + /* If printing is not disabled, just print out */ + if (print_messages) + fprintf (stderr, "p11-kit: %s\n", buffer); + else + p11_debug_message (P11_DEBUG_LIB, "message: %s", buffer); + p11_message_store (buffer, length); +} + +void +p11_message_quiet (void) +{ + print_messages = false; +} + +void +p11_message_loud (void) +{ + print_messages = true; +} + +const char * +p11_message_last (void) +{ + char *buffer; + buffer = p11_message_storage (); + return buffer && buffer[0] ? buffer : NULL; +} + +void +p11_message_clear (void) +{ + char *buffer; + buffer = p11_message_storage (); + if (buffer != NULL) + buffer[0] = 0; +} diff --git a/common/message.h b/common/message.h new file mode 100644 index 0000000..60a7f81 --- /dev/null +++ b/common/message.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2011 Collabora Ltd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * * The names of contributors to this software may not be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * + * CONTRIBUTORS + * Stef Walter + */ + +#ifndef P11_MESSAGE_H_ +#define P11_MESSAGE_H_ + +#include "compat.h" + +#include + +#define P11_MESSAGE_MAX 512 + +extern char * (* p11_message_storage) (void); + +void p11_message (const char* msg, + ...) GNUC_PRINTF (1, 2); + +void p11_message_store (const char* msg, + size_t length); + +const char * p11_message_last (void); + +void p11_message_clear (void); + +void p11_message_quiet (void); + +void p11_message_loud (void); + +#endif /* P11_MESSAGE_H_ */ diff --git a/common/mock.c b/common/mock.c index 9d6c960..1a283b9 100644 --- a/common/mock.c +++ b/common/mock.c @@ -35,9 +35,9 @@ #include "config.h" #include "debug.h" -#include "library.h" #define CRYPTOKI_EXPORTS #include "pkcs11.h" +#include "message.h" #include "mock.h" diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am index d024b80..ba9a72f 100644 --- a/common/tests/Makefile.am +++ b/common/tests/Makefile.am @@ -60,6 +60,5 @@ endif # WITH_ASN1 TESTS = $(CHECK_PROGS) LDADD += \ - $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(CUTEST_LIBS) diff --git a/common/tests/test-base64.c b/common/tests/test-base64.c index c053305..90c1f49 100644 --- a/common/tests/test-base64.c +++ b/common/tests/test-base64.c @@ -36,7 +36,8 @@ #include "CuTest.h" #include "base64.h" -#include "library.h" +#include "debug.h" +#include "message.h" #include #include @@ -196,7 +197,7 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); + p11_debug_init (); SUITE_ADD_TEST (suite, test_decode_simple); SUITE_ADD_TEST (suite, test_decode_thawte); diff --git a/common/tests/test-lexer.c b/common/tests/test-lexer.c index 02ea5c5..58d5d65 100644 --- a/common/tests/test-lexer.c +++ b/common/tests/test-lexer.c @@ -42,7 +42,7 @@ #include "compat.h" #include "debug.h" #include "lexer.h" -#include "library.h" +#include "message.h" #include "pem.h" typedef struct { @@ -260,7 +260,6 @@ main (void) putenv ("P11_KIT_STRICT=1"); p11_debug_init (); - p11_library_init (); SUITE_ADD_TEST (suite, test_basic); SUITE_ADD_TEST (suite, test_corners); diff --git a/common/tests/test-url.c b/common/tests/test-url.c index 096563b..ed84f0c 100644 --- a/common/tests/test-url.c +++ b/common/tests/test-url.c @@ -35,7 +35,8 @@ #include "config.h" #include "CuTest.h" -#include "library.h" +#include "debug.h" +#include "message.h" #include #include @@ -146,7 +147,7 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); + p11_debug_init (); SUITE_ADD_TEST (suite, test_decode_success); SUITE_ADD_TEST (suite, test_decode_skip); diff --git a/p11-kit/Makefile.am b/p11-kit/Makefile.am index 1967403..1ab3b3d 100644 --- a/p11-kit/Makefile.am +++ b/p11-kit/Makefile.am @@ -55,7 +55,7 @@ libp11_kit_la_SOURCES = $(MODULE_SRCS) libp11_kit_la_LIBADD = \ $(LTLIBINTL) \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(top_builddir)/common/libp11-library.la \ $(NULL) diff --git a/p11-kit/conf.c b/p11-kit/conf.c index 2cd5481..c3eb05e 100644 --- a/p11-kit/conf.c +++ b/p11-kit/conf.c @@ -41,7 +41,7 @@ #define P11_DEBUG_FLAG P11_DEBUG_CONF #include "debug.h" #include "lexer.h" -#include "library.h" +#include "message.h" #include "private.h" #include diff --git a/p11-kit/modules.c b/p11-kit/modules.c index 7648167..18400bb 100644 --- a/p11-kit/modules.c +++ b/p11-kit/modules.c @@ -40,6 +40,7 @@ #include "debug.h" #include "dict.h" #include "library.h" +#include "message.h" #include "pkcs11.h" #include "p11-kit.h" #include "private.h" diff --git a/p11-kit/pin.c b/p11-kit/pin.c index dac635c..b64b737 100644 --- a/p11-kit/pin.c +++ b/p11-kit/pin.c @@ -38,6 +38,7 @@ #include "debug.h" #include "dict.h" #include "library.h" +#include "message.h" #include "pkcs11.h" #include "p11-kit.h" #include "pin.h" diff --git a/p11-kit/proxy.c b/p11-kit/proxy.c index 35f0c82..1908d34 100644 --- a/p11-kit/proxy.c +++ b/p11-kit/proxy.c @@ -39,6 +39,7 @@ #include "debug.h" #include "dict.h" #include "library.h" +#include "message.h" #define CRYPTOKI_EXPORTS #include "pkcs11.h" #include "p11-kit.h" diff --git a/p11-kit/tests/Makefile.am b/p11-kit/tests/Makefile.am index bc96bf4..c7b87ae 100644 --- a/p11-kit/tests/Makefile.am +++ b/p11-kit/tests/Makefile.am @@ -12,8 +12,7 @@ INCLUDES = \ LDADD = \ $(top_builddir)/p11-kit/libp11-kit-testable.la \ $(top_builddir)/common/libp11-mock.la \ - $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(CUTEST_LIBS) \ $(LTLIBINTL) @@ -47,8 +46,7 @@ mock_one_la_CFLAGS = \ mock_one_la_LIBADD = \ $(top_builddir)/common/libp11-mock.la \ - $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(NULL) mock_one_la_LDFLAGS = \ diff --git a/p11-kit/tests/conf-test.c b/p11-kit/tests/conf-test.c index e74da1b..d259cf8 100644 --- a/p11-kit/tests/conf-test.c +++ b/p11-kit/tests/conf-test.c @@ -41,7 +41,8 @@ #include #include "conf.h" -#include "library.h" +#include "debug.h" +#include "message.h" #include "p11-kit.h" #include "private.h" @@ -78,7 +79,7 @@ test_parse_ignore_missing (CuTest *tc) CuAssertPtrNotNull (tc, map); CuAssertIntEquals (tc, 0, p11_dict_size (map)); - CuAssertPtrEquals (tc, NULL, (void*)p11_kit_message ()); + CuAssertPtrEquals (tc, NULL, (void*)p11_message_last ()); p11_dict_free (map); } @@ -89,7 +90,7 @@ test_parse_fail_missing (CuTest *tc) map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", 0); CuAssertPtrEquals (tc, map, NULL); - CuAssertPtrNotNull (tc, p11_kit_message ()); + CuAssertPtrNotNull (tc, p11_message_last ()); } static void @@ -131,7 +132,7 @@ test_load_globals_merge (CuTest *tc) SRCDIR "/files/test-user.conf", &user_mode); CuAssertPtrNotNull (tc, config); - CuAssertStrEquals (tc, NULL, p11_kit_message ()); + CuAssertStrEquals (tc, NULL, p11_message_last ()); CuAssertIntEquals (tc, CONF_USER_MERGE, user_mode); CuAssertStrEquals (tc, p11_dict_get (config, "key1"), "system1"); @@ -153,7 +154,7 @@ test_load_globals_no_user (CuTest *tc) SRCDIR "/files/test-user.conf", &user_mode); CuAssertPtrNotNull (tc, config); - CuAssertStrEquals (tc, NULL, p11_kit_message ()); + CuAssertStrEquals (tc, NULL, p11_message_last ()); CuAssertIntEquals (tc, CONF_USER_NONE, user_mode); CuAssertStrEquals (tc, p11_dict_get (config, "key1"), "system1"); @@ -175,7 +176,7 @@ test_load_globals_user_sets_only (CuTest *tc) SRCDIR "/files/test-user-only.conf", &user_mode); CuAssertPtrNotNull (tc, config); - CuAssertStrEquals (tc, NULL, p11_kit_message ()); + CuAssertStrEquals (tc, NULL, p11_message_last ()); CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode); CuAssertStrEquals (tc, p11_dict_get (config, "key1"), NULL); @@ -197,7 +198,7 @@ test_load_globals_system_sets_only (CuTest *tc) SRCDIR "/files/test-user.conf", &user_mode); CuAssertPtrNotNull (tc, config); - CuAssertStrEquals (tc, NULL, p11_kit_message ()); + CuAssertStrEquals (tc, NULL, p11_message_last ()); CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode); CuAssertStrEquals (tc, p11_dict_get (config, "key1"), NULL); @@ -222,7 +223,7 @@ test_load_globals_system_sets_invalid (CuTest *tc) error = errno; CuAssertPtrEquals (tc, NULL, config); CuAssertIntEquals (tc, EINVAL, error); - CuAssertPtrNotNull (tc, p11_kit_message ()); + CuAssertPtrNotNull (tc, p11_message_last ()); p11_dict_free (config); } @@ -242,7 +243,7 @@ test_load_globals_user_sets_invalid (CuTest *tc) error = errno; CuAssertPtrEquals (tc, NULL, config); CuAssertIntEquals (tc, EINVAL, error); - CuAssertPtrNotNull (tc, p11_kit_message ()); + CuAssertPtrNotNull (tc, p11_message_last ()); p11_dict_free (config); } @@ -267,7 +268,7 @@ test_load_modules_merge (CuTest *tc) SRCDIR "/files/system-modules", SRCDIR "/files/user-modules"); CuAssertPtrNotNull (tc, configs); - CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename")); + CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename")); config = p11_dict_get (configs, "one"); CuAssertPtrNotNull (tc, config); @@ -300,7 +301,7 @@ test_load_modules_user_none (CuTest *tc) SRCDIR "/files/system-modules", SRCDIR "/files/user-modules"); CuAssertPtrNotNull (tc, configs); - CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename")); + CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename")); config = p11_dict_get (configs, "one"); CuAssertPtrNotNull (tc, config); @@ -331,7 +332,7 @@ test_load_modules_user_only (CuTest *tc) SRCDIR "/files/system-modules", SRCDIR "/files/user-modules"); CuAssertPtrNotNull (tc, configs); - CuAssertPtrEquals (tc, NULL, (void *)p11_kit_message ()); + CuAssertPtrEquals (tc, NULL, (void *)p11_message_last ()); config = p11_dict_get (configs, "one"); CuAssertPtrNotNull (tc, config); @@ -362,7 +363,7 @@ test_load_modules_no_user (CuTest *tc) SRCDIR "/files/system-modules", SRCDIR "/files/non-existant"); CuAssertPtrNotNull (tc, configs); - CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename")); + CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename")); config = p11_dict_get (configs, "one"); CuAssertPtrNotNull (tc, config); @@ -398,7 +399,7 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); + p11_debug_init (); SUITE_ADD_TEST (suite, test_parse_conf_1); SUITE_ADD_TEST (suite, test_parse_ignore_missing); @@ -416,8 +417,6 @@ main (void) SUITE_ADD_TEST (suite, test_load_modules_user_none); SUITE_ADD_TEST (suite, test_parse_boolean); - p11_kit_be_quiet (); - CuSuiteRun (suite); CuSuiteSummary (suite, output); CuSuiteDetails (suite, output); diff --git a/p11-kit/tests/test-iter.c b/p11-kit/tests/test-iter.c index ccfce2c..08e43b3 100644 --- a/p11-kit/tests/test-iter.c +++ b/p11-kit/tests/test-iter.c @@ -40,6 +40,7 @@ #include "attrs.h" #include "iter.h" #include "library.h" +#include "message.h" #include "mock.h" #include diff --git a/p11-kit/tests/test-modules.c b/p11-kit/tests/test-modules.c index 3f0e4e0..3a6e968 100644 --- a/p11-kit/tests/test-modules.c +++ b/p11-kit/tests/test-modules.c @@ -40,6 +40,7 @@ #include #include +#include "debug.h" #include "library.h" #include "p11-kit.h" #include "private.h" diff --git a/p11-kit/tests/uri-test.c b/p11-kit/tests/uri-test.c index 18ee706..2bc121c 100644 --- a/p11-kit/tests/uri-test.c +++ b/p11-kit/tests/uri-test.c @@ -35,7 +35,8 @@ #include "config.h" #include "CuTest.h" -#include "library.h" +#include "debug.h" +#include "message.h" #include #include @@ -1203,7 +1204,7 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); + p11_debug_init (); SUITE_ADD_TEST (suite, test_uri_parse); SUITE_ADD_TEST (suite, test_uri_parse_bad_scheme); diff --git a/p11-kit/uri.c b/p11-kit/uri.c index 52bd61d..a811b92 100644 --- a/p11-kit/uri.c +++ b/p11-kit/uri.c @@ -38,7 +38,7 @@ #include "buffer.h" #define P11_DEBUG_FLAG P11_DEBUG_URI #include "debug.h" -#include "library.h" +#include "message.h" #include "pkcs11.h" #include "private.h" #include "p11-kit.h" diff --git a/p11-kit/util.c b/p11-kit/util.c index bb074ac..c4e5636 100644 --- a/p11-kit/util.c +++ b/p11-kit/util.c @@ -41,6 +41,7 @@ #define P11_DEBUG_FLAG P11_DEBUG_LIB #include "debug.h" #include "library.h" +#include "message.h" #include "p11-kit.h" #include "private.h" diff --git a/tools/Makefile.am b/tools/Makefile.am index aaf7e99..92c2644 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -27,8 +27,7 @@ p11_kit_CFLAGS = \ p11_kit_LDADD = \ $(top_builddir)/p11-kit/libp11-kit.la \ - $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(LTLIBINTL) \ $(NULL) diff --git a/tools/extract-info.c b/tools/extract-info.c index 1c81e07..133b1cd 100644 --- a/tools/extract-info.c +++ b/tools/extract-info.c @@ -41,7 +41,7 @@ #include "oid.h" #include "dict.h" #include "extract.h" -#include "library.h" +#include "message.h" #include "pkcs11.h" #include "pkcs11x.h" #include "x509.h" diff --git a/tools/extract-jks.c b/tools/extract-jks.c index d72b1dc..2c78a51 100644 --- a/tools/extract-jks.c +++ b/tools/extract-jks.c @@ -40,7 +40,7 @@ #include "debug.h" #include "extract.h" #include "hash.h" -#include "library.h" +#include "message.h" #include "save.h" #include diff --git a/tools/extract-openssl.c b/tools/extract-openssl.c index cf387f7..2b8005a 100644 --- a/tools/extract-openssl.c +++ b/tools/extract-openssl.c @@ -42,7 +42,7 @@ #include "dict.h" #include "extract.h" #include "hash.h" -#include "library.h" +#include "message.h" #include "oid.h" #include "pem.h" #include "pkcs11.h" diff --git a/tools/extract-pem.c b/tools/extract-pem.c index 4d03208..a1a0865 100644 --- a/tools/extract-pem.c +++ b/tools/extract-pem.c @@ -39,7 +39,7 @@ #include "compat.h" #include "debug.h" #include "extract.h" -#include "library.h" +#include "message.h" #include "pem.h" #include "save.h" diff --git a/tools/extract-x509.c b/tools/extract-x509.c index c6fe15f..4a0d9c0 100644 --- a/tools/extract-x509.c +++ b/tools/extract-x509.c @@ -37,7 +37,7 @@ #include "compat.h" #include "debug.h" #include "extract.h" -#include "library.h" +#include "message.h" #include "save.h" #include diff --git a/tools/extract.c b/tools/extract.c index cf08ae9..cd0f369 100644 --- a/tools/extract.c +++ b/tools/extract.c @@ -39,7 +39,7 @@ #include "debug.h" #include "extract.h" #include "iter.h" -#include "library.h" +#include "message.h" #include "oid.h" #include "pkcs11.h" #include "pkcs11x.h" diff --git a/tools/list.c b/tools/list.c index 8430d78..da99940 100644 --- a/tools/list.c +++ b/tools/list.c @@ -44,7 +44,7 @@ #include #include -#include "library.h" +#include "message.h" #include "p11-kit.h" #include "tool.h" #include "uri.h" diff --git a/tools/save.c b/tools/save.c index 856a723..f1605a3 100644 --- a/tools/save.c +++ b/tools/save.c @@ -37,7 +37,7 @@ #include "buffer.h" #include "debug.h" #include "dict.h" -#include "library.h" +#include "message.h" #include "save.h" #include diff --git a/tools/tests/Makefile.am b/tools/tests/Makefile.am index 7936743..f6609ec 100644 --- a/tools/tests/Makefile.am +++ b/tools/tests/Makefile.am @@ -24,8 +24,7 @@ LDADD = \ $(top_builddir)/p11-kit/libp11-kit.la \ $(top_builddir)/common/libp11-data.la \ $(top_builddir)/common/libp11-mock.la \ - $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(builddir)/libtestcommon.la \ $(LIBTASN1_LIBS) \ $(LTLIBINTL) \ diff --git a/tools/tests/test-extract.c b/tools/tests/test-extract.c index 29ee986..74e3c9c 100644 --- a/tools/tests/test-extract.c +++ b/tools/tests/test-extract.c @@ -40,7 +40,7 @@ #include "debug.h" #include "dict.h" #include "extract.h" -#include "library.h" +#include "message.h" #include "mock.h" #include "pkcs11.h" #include "pkcs11x.h" @@ -524,7 +524,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); mock_module_init (); p11_debug_init (); diff --git a/tools/tests/test-openssl.c b/tools/tests/test-openssl.c index 77df109..286b4e9 100644 --- a/tools/tests/test-openssl.c +++ b/tools/tests/test-openssl.c @@ -41,7 +41,7 @@ #include "debug.h" #include "dict.h" #include "extract.h" -#include "library.h" +#include "message.h" #include "mock.h" #include "pkcs11.h" #include "pkcs11x.h" @@ -655,7 +655,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); mock_module_init (); p11_debug_init (); diff --git a/tools/tests/test-pem.c b/tools/tests/test-pem.c index 5c19455..be79279 100644 --- a/tools/tests/test-pem.c +++ b/tools/tests/test-pem.c @@ -40,7 +40,7 @@ #include "debug.h" #include "dict.h" #include "extract.h" -#include "library.h" +#include "message.h" #include "mock.h" #include "pkcs11.h" #include "pkcs11x.h" @@ -249,7 +249,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); mock_module_init (); p11_debug_init (); diff --git a/tools/tests/test-save.c b/tools/tests/test-save.c index 32713ee..d686bd6 100644 --- a/tools/tests/test-save.c +++ b/tools/tests/test-save.c @@ -39,7 +39,7 @@ #include "compat.h" #include "debug.h" #include "dict.h" -#include "library.h" +#include "message.h" #include "save.h" #include "test.h" @@ -537,7 +537,8 @@ main (void) CuSuite* suite = CuSuiteNew (); int ret; - p11_library_init (); + putenv ("P11_KIT_STRICT=1"); + p11_debug_init (); SUITE_ADD_TEST (suite, test_file_write); SUITE_ADD_TEST (suite, test_file_exists); diff --git a/tools/tests/test-x509.c b/tools/tests/test-x509.c index 7cf9787..138e6b7 100644 --- a/tools/tests/test-x509.c +++ b/tools/tests/test-x509.c @@ -40,7 +40,7 @@ #include "debug.h" #include "dict.h" #include "extract.h" -#include "library.h" +#include "message.h" #include "mock.h" #include "pkcs11.h" #include "pkcs11x.h" @@ -259,7 +259,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); mock_module_init (); p11_debug_init (); diff --git a/tools/tool.c b/tools/tool.c index fa68eed..9ec41a4 100644 --- a/tools/tool.c +++ b/tools/tool.c @@ -37,7 +37,7 @@ #include "buffer.h" #include "compat.h" #include "debug.h" -#include "library.h" +#include "message.h" #include "p11-kit.h" #include diff --git a/trust/Makefile.am b/trust/Makefile.am index 60323a8..264ea7c 100644 --- a/trust/Makefile.am +++ b/trust/Makefile.am @@ -36,7 +36,7 @@ p11_kit_trust_la_CFLAGS = \ p11_kit_trust_la_LIBADD = \ $(top_builddir)/common/libp11-data.la \ $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(LIBTASN1_LIBS) \ $(NULL) diff --git a/trust/builder.c b/trust/builder.c index 32f2d1b..e41d73f 100644 --- a/trust/builder.c +++ b/trust/builder.c @@ -44,7 +44,7 @@ #include "debug.h" #include "hash.h" #include "index.h" -#include "library.h" +#include "message.h" #include "oid.h" #include "pkcs11x.h" #include "x509.h" diff --git a/trust/module.c b/trust/module.c index 51a75e0..46ebeb6 100644 --- a/trust/module.c +++ b/trust/module.c @@ -42,6 +42,7 @@ #include "debug.h" #include "dict.h" #include "library.h" +#include "message.h" #include "module.h" #include "parser.h" #include "pkcs11.h" diff --git a/trust/parser.c b/trust/parser.c index 7ea879a..7eb18c9 100644 --- a/trust/parser.c +++ b/trust/parser.c @@ -41,7 +41,7 @@ #include "debug.h" #include "dict.h" #include "hash.h" -#include "library.h" +#include "message.h" #include "module.h" #include "oid.h" #include "parser.h" diff --git a/trust/session.c b/trust/session.c index 2a8c9f9..b04b8bf 100644 --- a/trust/session.c +++ b/trust/session.c @@ -38,7 +38,7 @@ #define P11_DEBUG_FLAG P11_DEBUG_TRUST #include "debug.h" #include "dict.h" -#include "library.h" +#include "message.h" #include "pkcs11.h" #include "module.h" #include "session.h" diff --git a/trust/tests/Makefile.am b/trust/tests/Makefile.am index 653bd0d..90b9fb5 100644 --- a/trust/tests/Makefile.am +++ b/trust/tests/Makefile.am @@ -19,7 +19,7 @@ LDADD = \ $(top_builddir)/trust/libtrust-testable.la \ $(top_builddir)/common/libp11-data.la \ $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(builddir)/libtestdata.la \ $(LIBTASN1_LIBS) \ $(CUTEST_LIBS) \ @@ -41,8 +41,7 @@ noinst_PROGRAMS = \ $(CHECK_PROGS) frob_nss_trust_LDADD = \ - $(top_builddir)/common/libp11-library.la \ - $(top_builddir)/common/libp11-compat.la \ + $(top_builddir)/common/libp11-common.la \ $(top_builddir)/p11-kit/libp11-kit.la TESTS = $(CHECK_PROGS) diff --git a/trust/tests/test-builder.c b/trust/tests/test-builder.c index 5ce3b22..7cab1f6 100644 --- a/trust/tests/test-builder.c +++ b/trust/tests/test-builder.c @@ -44,7 +44,7 @@ #include "hash.h" #include "debug.h" #include "index.h" -#include "library.h" +#include "message.h" #include "oid.h" #include "pkcs11x.h" @@ -1722,7 +1722,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); p11_debug_init (); /* p11_message_quiet (); */ diff --git a/trust/tests/test-index.c b/trust/tests/test-index.c index 14f5a8a..8405061 100644 --- a/trust/tests/test-index.c +++ b/trust/tests/test-index.c @@ -41,8 +41,8 @@ #include "attrs.h" #include "debug.h" -#include "library.h" #include "index.h" +#include "message.h" #include "test-data.h" @@ -1036,7 +1036,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); p11_debug_init (); p11_message_quiet (); diff --git a/trust/tests/test-module.c b/trust/tests/test-module.c index c92e1c3..525a68e 100644 --- a/trust/tests/test-module.c +++ b/trust/tests/test-module.c @@ -42,7 +42,6 @@ #define CRYPTOKI_EXPORTS #include "attrs.h" -#include "debug.h" #include "hash.h" #include "library.h" #include "pkcs11x.h" @@ -898,7 +897,6 @@ main (void) putenv ("P11_KIT_STRICT=1"); p11_library_init (); - p11_debug_init (); SUITE_ADD_TEST (suite, test_get_slot_list); SUITE_ADD_TEST (suite, test_get_slot_info); diff --git a/trust/tests/test-parser.c b/trust/tests/test-parser.c index 94cfc49..147823a 100644 --- a/trust/tests/test-parser.c +++ b/trust/tests/test-parser.c @@ -43,7 +43,7 @@ #include "attrs.h" #include "builder.h" #include "debug.h" -#include "library.h" +#include "message.h" #include "oid.h" #include "parser.h" #include "pkcs11x.h" @@ -570,7 +570,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); p11_debug_init (); SUITE_ADD_TEST (suite, test_parse_der_certificate); diff --git a/trust/tests/test-persist.c b/trust/tests/test-persist.c index b9a79e9..ee73331 100644 --- a/trust/tests/test-persist.c +++ b/trust/tests/test-persist.c @@ -43,7 +43,7 @@ #include "attrs.h" #include "compat.h" #include "debug.h" -#include "library.h" +#include "message.h" #include "persist.h" #include "pkcs11.h" #include "pkcs11x.h" @@ -441,7 +441,6 @@ main (void) putenv ("P11_KIT_STRICT=1"); p11_debug_init (); - p11_library_init (); SUITE_ADD_TEST (suite, test_magic); SUITE_ADD_TEST (suite, test_simple); diff --git a/trust/tests/test-token.c b/trust/tests/test-token.c index 6cf687b..ffd733f 100644 --- a/trust/tests/test-token.c +++ b/trust/tests/test-token.c @@ -42,7 +42,7 @@ #include "attrs.h" #include "debug.h" #include "pkcs11x.h" -#include "library.h" +#include "message.h" #include "test-data.h" #include "token.h" @@ -235,7 +235,6 @@ main (void) int ret; putenv ("P11_KIT_STRICT=1"); - p11_library_init (); p11_debug_init (); SUITE_ADD_TEST (suite, test_token_load); diff --git a/trust/token.c b/trust/token.c index b562788..e7c91cd 100644 --- a/trust/token.c +++ b/trust/token.c @@ -41,7 +41,7 @@ #define P11_DEBUG_FLAG P11_DEBUG_TRUST #include "debug.h" #include "errno.h" -#include "library.h" +#include "message.h" #include "module.h" #include "parser.h" #include "pkcs11.h" -- cgit v1.1