diff options
author | Stef Walter <stefw@redhat.com> | 2014-09-03 10:38:40 +0200 |
---|---|---|
committer | Stef Walter <stefw@redhat.com> | 2014-09-03 11:13:44 +0200 |
commit | 375f28fafa5a2f1669331f5e0eba96450545e9ea (patch) | |
tree | 1e6db570999e4373a3ab88e9f528c89c25b1abbb | |
parent | 6ee9bb7e551bd86c4dd829e7660b39efdf186549 (diff) |
Use the g_debug() mechanism from GLib directly
Rather than using our own _gck_debug() and _gcr_debug()
wrappers.
-rw-r--r-- | docs/reference/gck/Makefile.am | 1 | ||||
-rw-r--r-- | docs/reference/gcr/gcr-sections.txt | 4 | ||||
-rw-r--r-- | gck/Makefile.am | 1 | ||||
-rw-r--r-- | gck/gck-debug.c | 173 | ||||
-rw-r--r-- | gck/gck-debug.h | 88 | ||||
-rw-r--r-- | gck/gck-enumerator.c | 72 | ||||
-rw-r--r-- | gck/gck-session.c | 40 | ||||
-rw-r--r-- | gcr/Makefile.am | 1 | ||||
-rw-r--r-- | gcr/gcr-callback-output-stream.c | 2 | ||||
-rw-r--r-- | gcr/gcr-certificate-chain.c | 56 | ||||
-rw-r--r-- | gcr/gcr-debug.c | 164 | ||||
-rw-r--r-- | gcr/gcr-debug.h | 93 | ||||
-rw-r--r-- | gcr/gcr-gnupg-collection.c | 36 | ||||
-rw-r--r-- | gcr/gcr-gnupg-process.c | 50 | ||||
-rw-r--r-- | gcr/gcr-importer.c | 20 | ||||
-rw-r--r-- | gcr/gcr-key-mechanisms.c | 6 | ||||
-rw-r--r-- | gcr/gcr-library.c | 36 | ||||
-rw-r--r-- | gcr/gcr-pkcs11-importer.c | 12 | ||||
-rw-r--r-- | gcr/gcr-record.c | 20 | ||||
-rw-r--r-- | gcr/gcr-secret-exchange.c | 44 | ||||
-rw-r--r-- | gcr/gcr-subject-public-key.c | 44 | ||||
-rw-r--r-- | gcr/gcr-system-prompt.c | 38 | ||||
-rw-r--r-- | gcr/gcr-system-prompter.c | 112 | ||||
-rw-r--r-- | gcr/gcr-trust.c | 14 | ||||
-rw-r--r-- | ui/gcr-prompt-dialog.c | 2 | ||||
-rw-r--r-- | ui/gcr-prompter-tool.c | 10 |
26 files changed, 275 insertions, 864 deletions
diff --git a/docs/reference/gck/Makefile.am b/docs/reference/gck/Makefile.am index 5733c3d..02da77b 100644 --- a/docs/reference/gck/Makefile.am +++ b/docs/reference/gck/Makefile.am @@ -54,7 +54,6 @@ EXTRA_HFILES= # Header files to ignore when scanning. Use base file name, no paths # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h IGNORE_HFILES= \ - gck-debug.h \ gck-private.h \ test-suite.h \ gck-mock.h \ diff --git a/docs/reference/gcr/gcr-sections.txt b/docs/reference/gcr/gcr-sections.txt index c9af8ec..fb4f78b 100644 --- a/docs/reference/gcr/gcr-sections.txt +++ b/docs/reference/gcr/gcr-sections.txt @@ -262,8 +262,6 @@ gcr_pkcs11_get_trust_lookup_uris gcr_pkcs11_set_trust_lookup_uris gcr_pkcs11_get_trust_store_uri gcr_pkcs11_set_trust_store_uri -<SUBSECTION Private> -GcrDebugFlags </SECTION> <SECTION> @@ -881,4 +879,4 @@ gcr_mock_prompter_is_prompting <SECTION> <FILE>GcrDBusPrompterCallback</FILE> -</SECTION>
\ No newline at end of file +</SECTION> diff --git a/gck/Makefile.am b/gck/Makefile.am index 54f1cf9..44a2882 100644 --- a/gck/Makefile.am +++ b/gck/Makefile.am @@ -41,7 +41,6 @@ gck_PUBLIC_FILES = \ gck_INTERNAL_FILES = \ gck/gck-call.c \ - gck/gck-debug.c gck/gck-debug.h \ gck/gck-deprecated.h \ gck/gck-interaction.c \ gck/gck-private.h \ diff --git a/gck/gck-debug.c b/gck/gck-debug.c deleted file mode 100644 index 0ad5b05..0000000 --- a/gck/gck-debug.c +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* - * Copyright (C) 2007 Collabora Ltd. - * Copyright (C) 2007 Nokia Corporation - * Copyright (C) 2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#include "gck.h" -#include "gck-debug.h" - -#include <glib.h> -#include <glib/gstdio.h> - -#include <p11-kit/pkcs11.h> - -#include <sys/types.h> - -#include <unistd.h> - -#ifdef WITH_DEBUG - -static gsize initialized_flags = 0; -static GckDebugFlags current_flags = 0; - -static GDebugKey keys[] = { - { "session", GCK_DEBUG_SESSION }, - { "enumerator", GCK_DEBUG_ENUMERATOR }, - { 0, } -}; - -static void -debug_set_flags (GckDebugFlags new_flags) -{ - current_flags |= new_flags; -} - -void -_gck_debug_set_flags (const gchar *flags_string) -{ - guint nkeys; - - for (nkeys = 0; keys[nkeys].value; nkeys++); - - if (flags_string) - debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys)); -} - -static void -on_gck_log_debug (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) -{ - GString *gstring; - const gchar *progname; - - gstring = g_string_new (NULL); - - progname = g_get_prgname (); - g_string_append_printf (gstring, "(%s:%lu): %s-DEBUG: %s\n", - progname ? progname : "process", - (gulong)getpid (), log_domain, - message ? message : "(NULL) message"); - - /* - * Give up on debug messages if stdout got lost. - */ - if (write (1, gstring->str, gstring->len) != gstring->len) - current_flags = 0; - - g_string_free (gstring, TRUE); -} - -static void -initialize_debug_flags (void) -{ - const gchar *messages_env; - const gchar *debug_env; - - if (g_once_init_enter (&initialized_flags)) { - messages_env = g_getenv ("G_MESSAGES_DEBUG"); - debug_env = g_getenv ("GCK_DEBUG"); -#ifdef GCK_DEBUG - if (debug_env == NULL) - debug_env = G_STRINGIFY (GCK_DEBUG); -#endif - - /* - * If the caller is selectively asking for certain debug - * messages with the GCK_DEBUG environment variable, then - * we install our own output handler and only print those - * messages. This happens irrespective of G_MESSAGES_DEBUG - */ - if (messages_env == NULL && debug_env != NULL) - g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - on_gck_log_debug, NULL); - - /* - * If the caller is using G_MESSAGES_DEBUG then we enable - * all our debug messages, and let Glib filter which ones - * to display. - */ - if (messages_env != NULL && debug_env == NULL) - debug_env = "all"; - - _gck_debug_set_flags (debug_env); - - g_once_init_leave (&initialized_flags, 1); - } -} - -gboolean -_gck_debug_flag_is_set (GckDebugFlags flag) -{ - if G_UNLIKELY (!initialized_flags) - initialize_debug_flags (); - return (flag & current_flags) != 0; -} - -void -_gck_debug_message (GckDebugFlags flag, - const gchar *format, - ...) -{ - va_list args; - - if G_UNLIKELY (!initialized_flags) - initialize_debug_flags (); - - if (flag & current_flags) { - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); - va_end (args); - } -} - -#else /* !WITH_DEBUG */ - -gboolean -_gck_debug_flag_is_set (GckDebugFlags flag) -{ - return FALSE; -} - -void -_gck_debug_message (GckDebugFlags flag, - const gchar *format, - ...) -{ -} - -void -_gck_debug_set_flags (const gchar *flags_string) -{ -} - -#endif /* !WITH_DEBUG */ diff --git a/gck/gck-debug.h b/gck/gck-debug.h deleted file mode 100644 index 4243292..0000000 --- a/gck/gck-debug.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2007 Nokia Corporation - * Copyright (C) 2007-2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef GCK_DEBUG_H -#define GCK_DEBUG_H - -#include "config.h" - -#include <glib.h> - -G_BEGIN_DECLS - -/* Please keep this enum in sync with #keys in gck-debug.c */ -typedef enum { - GCK_DEBUG_SESSION = 1 << 1, - GCK_DEBUG_ENUMERATOR = 1 << 2, -} GckDebugFlags; - -gboolean _gck_debug_flag_is_set (GckDebugFlags flag); - -void _gck_debug_set_flags (const gchar *flags_string); - -void _gck_debug_message (GckDebugFlags flag, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); - -void _gck_debug_init (void); - -G_END_DECLS - -#endif /* GCK_DEBUG_H */ - -/* ----------------------------------------------------------------------------- - * Below this point is outside the GCK_DEBUG_H guard - so it can take effect - * more than once. So you can do: - * - * #define DEBUG_FLAG GCK_DEBUG_ONE_THING - * #include "gck-debug.h" - * ... - * DEBUG ("if we're debugging one thing"); - * ... - * #undef DEBUG_FLAG - * #define DEBUG_FLAG GCK_DEBUG_OTHER_THING - * #include "gck-debug.h" - * ... - * DEBUG ("if we're debugging the other thing"); - * ... - */ - -#ifdef DEBUG_FLAG -#ifdef WITH_DEBUG - -#undef _gck_debug -#define _gck_debug(format, ...) \ - _gck_debug_message (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__) - -#undef _gck_debugging -#define _gck_debugging \ - _gck_debug_flag_is_set (DEBUG_FLAG) - -#else /* !defined (WITH_DEBUG) */ - -#undef _gck_debug -#define _gck_debug(format, ...) \ - do {} while (0) - -#undef _gck_debugging -#define _gck_debugging 0 - -#endif /* !defined (WITH_DEBUG) */ - -#endif /* defined (DEBUG_FLAG) */ diff --git a/gck/gck-enumerator.c b/gck/gck-enumerator.c index 353649c..38a1233 100644 --- a/gck/gck-enumerator.c +++ b/gck/gck-enumerator.c @@ -23,8 +23,6 @@ #include "config.h" #include "gck.h" -#define DEBUG_FLAG GCK_DEBUG_ENUMERATOR -#include "gck-debug.h" #include "gck-private.h" #include <string.h> @@ -223,7 +221,7 @@ state_modules (GckEnumeratorState *args, gboolean forward) /* There are no more modules? */ if (!args->modules) { - _gck_debug ("no more modules, stopping enumerator"); + g_debug ("no more modules, stopping enumerator"); return NULL; } @@ -234,11 +232,9 @@ state_modules (GckEnumeratorState *args, gboolean forward) args->slots = gck_module_get_slots (module, TRUE); - if (_gck_debugging) { - GckModuleInfo *info = gck_module_get_info (module); - _gck_debug ("enumerating into module: %s", info->library_description); - gck_module_info_free (info); - } + GckModuleInfo *info = gck_module_get_info (module); + g_debug ("enumerating into module: %s", info->library_description); + gck_module_info_free (info); g_object_unref (module); return state_slots; @@ -263,7 +259,7 @@ state_slots (GckEnumeratorState *args, gboolean forward) /* If there are no more slots go back to start state */ if (!args->slots) { - _gck_debug ("no more slots, want next module"); + g_debug ("no more slots, want next module"); return rewind_state (args, state_modules); } @@ -282,7 +278,7 @@ state_slots (GckEnumeratorState *args, gboolean forward) /* Do we have unrecognized matches? */ if (args->match->any_unrecognized) { - _gck_debug ("token uri had unrecognized, not matching any tokens"); + g_debug ("token uri had unrecognized, not matching any tokens"); matched = FALSE; /* Are we trying to match the slot? */ @@ -290,11 +286,11 @@ state_slots (GckEnumeratorState *args, gboolean forward) /* No match? Go to next slot */ matched = _gck_token_info_match (args->match->token_info, token_info); - _gck_debug ("%s token: %s", matched ? "matched" : "did not match", - token_info->label); + g_debug ("%s token: %s", matched ? "matched" : "did not match", + token_info->label); } else { - _gck_debug ("matching all tokens: %s", token_info->label); + g_debug ("matching all tokens: %s", token_info->label); matched = TRUE; } @@ -349,7 +345,7 @@ state_slot (GckEnumeratorState *args, gboolean forward) return rewind_state (args, state_slots); } - _gck_debug ("opened %s session", flags & CKF_RW_SESSION ? "read-write" : "read-only"); + g_debug ("opened %s session", flags & CKF_RW_SESSION ? "read-write" : "read-only"); args->session = gck_session_from_handle (args->slot, session, args->session_options); return state_session; @@ -381,7 +377,7 @@ state_session (GckEnumeratorState *args, gboolean forward) /* Don't want to authenticate? */ if ((args->session_options & GCK_SESSION_LOGIN_USER) == 0) { - _gck_debug ("no authentication necessary, skipping"); + g_debug ("no authentication necessary, skipping"); return state_find; } @@ -437,15 +433,13 @@ state_find (GckEnumeratorState *args, if (args->match->attributes) { attrs = _gck_attributes_commit_out (args->match->attributes, &n_attrs); - if (_gck_debugging) { - gchar *string = gck_attributes_to_string (args->match->attributes); - _gck_debug ("finding objects matching: %s", string); - g_free (string); - } + gchar *string = gck_attributes_to_string (args->match->attributes); + g_debug ("finding objects matching: %s", string); + g_free (string); } else { attrs = NULL; n_attrs = 0; - _gck_debug ("finding all objects"); + g_debug ("finding all objects"); } session = gck_session_get_handle (args->session); @@ -460,7 +454,7 @@ state_find (GckEnumeratorState *args, if (rv != CKR_OK || count == 0) break; - _gck_debug ("matched %lu objects", count); + g_debug ("matched %lu objects", count); for (i = 0; i < count; i++) { result = g_slice_new0 (GckEnumeratorResult); @@ -473,7 +467,7 @@ state_find (GckEnumeratorState *args, (args->funcs->C_FindObjectsFinal) (session); } - _gck_debug ("finding objects completed with: %s", _gck_stringize_rv (rv)); + g_debug ("finding objects completed with: %s", _gck_stringize_rv (rv)); return state_results; } @@ -509,8 +503,8 @@ state_results (GckEnumeratorState *args, for (count = 0; count < args->want_objects; count++) { result = g_queue_pop_head (args->found); if (result == NULL) { - _gck_debug ("wanted %d objects, have %d, looking for more", - args->want_objects, g_queue_get_length (args->results)); + g_debug ("wanted %d objects, have %d, looking for more", + args->want_objects, g_queue_get_length (args->results)); return rewind_state (args, state_slots); } @@ -541,12 +535,10 @@ state_results (GckEnumeratorState *args, attrs = gck_attributes_ref_sink (gck_builder_end (&builder)); if (GCK_IS_GET_ATTRIBUTE_RV_OK (rv)) { - if (_gck_debugging) { - gchar *string = gck_attributes_to_string (attrs); - _gck_debug ("retrieved attributes for object %lu: %s", - result->handle, string); - g_free (string); - } + gchar *string = gck_attributes_to_string (attrs); + g_debug ("retrieved attributes for object %lu: %s", + result->handle, string); + g_free (string); result->attrs = attrs; g_queue_push_tail (args->results, result); @@ -558,8 +550,8 @@ state_results (GckEnumeratorState *args, } } - _gck_debug ("wanted %d objects, returned %d objects", - args->want_objects, g_queue_get_length (args->results)); + g_debug ("wanted %d objects, returned %d objects", + args->want_objects, g_queue_get_length (args->results)); /* We got all the results we wanted */ return NULL; @@ -703,14 +695,12 @@ static void created_enumerator (GckUriData *uri_data, const gchar *type) { - if (_gck_debugging) { - gchar *attrs, *uri; - attrs = uri_data->attributes ? gck_attributes_to_string (uri_data->attributes) : NULL; - uri = uri_data ? gck_uri_build (uri_data, GCK_URI_FOR_TOKEN | GCK_URI_FOR_MODULE) : NULL; - _gck_debug ("for = %s, tokens = %s, objects = %s", type, uri, attrs); - g_free (attrs); - g_free (uri); - } + gchar *attrs, *uri; + attrs = uri_data->attributes ? gck_attributes_to_string (uri_data->attributes) : NULL; + uri = uri_data ? gck_uri_build (uri_data, GCK_URI_FOR_TOKEN | GCK_URI_FOR_MODULE) : NULL; + g_debug ("for = %s, tokens = %s, objects = %s", type, uri, attrs); + g_free (attrs); + g_free (uri); } GckEnumerator * diff --git a/gck/gck-session.c b/gck/gck-session.c index 7e635c3..05a1386 100644 --- a/gck/gck-session.c +++ b/gck/gck-session.c @@ -23,8 +23,6 @@ #include "config.h" #include "gck.h" -#define DEBUG_FLAG GCK_DEBUG_SESSION -#include "gck-debug.h" #include "gck-private.h" #include "gck/gck-marshal.h" @@ -1388,15 +1386,13 @@ perform_create_object (CreateObject *args) attrs, n_attrs, &args->object); - if (_gck_debugging) { - gchar *string = gck_attributes_to_string (args->attrs); - if (rv == CKR_OK) - _gck_debug ("created object: %s", string); - else - _gck_debug ("failed %s to create object: %s", - _gck_stringize_rv (rv), string); - g_free (string); - } + gchar *string = gck_attributes_to_string (args->attrs); + if (rv == CKR_OK) + g_debug ("created object: %s", string); + else + g_debug ("failed %s to create object: %s", + _gck_stringize_rv (rv), string); + g_free (string); return rv; } @@ -1514,11 +1510,9 @@ perform_find_objects (FindObjects *args) GArray *array; CK_RV rv; - if (_gck_debugging) { - gchar *string = gck_attributes_to_string (args->attrs); - _gck_debug ("matching: %s", string); - g_free (string); - } + gchar *string = gck_attributes_to_string (args->attrs); + g_debug ("matching: %s", string); + g_free (string); attrs = _gck_attributes_commit_out (args->attrs, &n_attrs); @@ -3350,7 +3344,7 @@ _gck_session_authenticate_token (CK_FUNCTION_LIST_PTR funcs, /* No login necessary? */ if ((token_info.flags & CKF_LOGIN_REQUIRED) == 0) { - _gck_debug ("no login required for token, skipping login"); + g_debug ("no login required for token, skipping login"); rv = CKR_OK; break; } @@ -3367,13 +3361,13 @@ _gck_session_authenticate_token (CK_FUNCTION_LIST_PTR funcs, if (session_info.state == CKS_RW_USER_FUNCTIONS || session_info.state == CKS_RO_USER_FUNCTIONS || session_info.state == CKS_RW_SO_FUNCTIONS) { - _gck_debug ("already logged in, skipping login"); + g_debug ("already logged in, skipping login"); rv = CKR_OK; break; } if (token_info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) { - _gck_debug ("trying to log into session: protected authentication path, no password"); + g_debug ("trying to log into session: protected authentication path, no password"); /* No password passed for PAP */ pin = NULL; @@ -3382,7 +3376,7 @@ _gck_session_authenticate_token (CK_FUNCTION_LIST_PTR funcs, /* Not protected auth path */ } else { - _gck_debug ("trying to log into session: want password %s", + g_debug ("trying to log into session: want password %s", request_retry ? "login was incorrect" : ""); if (password == NULL) @@ -3489,7 +3483,7 @@ _gck_session_authenticate_key (CK_FUNCTION_LIST_PTR funcs, /* No authentication needed, on this object */ if (bvalue != CK_TRUE) { - _gck_debug ("key does not require authentication"); + g_debug ("key does not require authentication"); return CKR_OK; } @@ -3525,8 +3519,8 @@ _gck_session_authenticate_key (CK_FUNCTION_LIST_PTR funcs, /* Need to prompt for a password */ } else { - _gck_debug ("trying to log into session: want password %s", - request_retry ? "login was incorrect" : ""); + g_debug ("trying to log into session: want password %s", + request_retry ? "login was incorrect" : ""); if (password == NULL) password = g_object_new (GCK_TYPE_PASSWORD, "key", key, NULL); diff --git a/gcr/Makefile.am b/gcr/Makefile.am index 774cc12..0834c67 100644 --- a/gcr/Makefile.am +++ b/gcr/Makefile.am @@ -87,7 +87,6 @@ gcr_PRIVATE_FILES = \ gcr/gcr-certificate-extensions.c gcr/gcr-certificate-extensions.h \ gcr/gcr-column.c \ gcr/gcr-dbus-constants.h \ - gcr/gcr-debug.c gcr/gcr-debug.h \ gcr/gcr-deprecated-base.h \ gcr/gcr-gnupg-collection.c gcr/gcr-gnupg-collection.h \ gcr/gcr-gnupg-importer.c gcr/gcr-gnupg-importer.h \ diff --git a/gcr/gcr-callback-output-stream.c b/gcr/gcr-callback-output-stream.c index a621505..ac85eab 100644 --- a/gcr/gcr-callback-output-stream.c +++ b/gcr/gcr-callback-output-stream.c @@ -22,8 +22,6 @@ #include "config.h" #include "gcr-callback-output-stream.h" -#define DEBUG_FLAG GCR_DEBUG_GNUPG -#include "gcr-debug.h" #include <glib/gi18n-lib.h> diff --git a/gcr/gcr-certificate-chain.c b/gcr/gcr-certificate-chain.c index c50615c..b0d2d31 100644 --- a/gcr/gcr-certificate-chain.c +++ b/gcr/gcr-certificate-chain.c @@ -24,8 +24,6 @@ #include "gcr-certificate-chain.h" #include "gcr-certificate.h" -#define DEBUG_FLAG GCR_DEBUG_CERTIFICATE_CHAIN -#include "gcr-debug.h" #include "gcr-pkcs11-certificate.h" #include "gcr-simple-certificate.h" #include "gcr-trust.h" @@ -179,7 +177,7 @@ prep_chain_private_thread_safe (GcrCertificateChainPrivate *orig, const gchar *p g_return_val_if_fail (der, NULL); safe = gcr_simple_certificate_new (der, n_der); - _gcr_debug ("copying certificate so it's thread safe"); + g_debug ("copying certificate so it's thread safe"); /* Always set the original certificate onto the safe one */ g_object_set_qdata_full (G_OBJECT (safe), Q_ORIGINAL_CERT, @@ -253,7 +251,7 @@ perform_build_chain (GcrCertificateChainPrivate *pv, GCancellable *cancellable, /* This chain is built */ if (!pv->certificates->len) { - _gcr_debug ("empty certificate chain"); + g_debug ("empty certificate chain"); return TRUE; } @@ -264,18 +262,16 @@ perform_build_chain (GcrCertificateChainPrivate *pv, GCancellable *cancellable, certificate = pop_certificate (input, NULL); g_ptr_array_add (pv->certificates, certificate); - if (_gcr_debugging) { - subject = gcr_certificate_get_subject_dn (certificate); - _gcr_debug ("first certificate: %s", subject); - g_free (subject); - } + subject = gcr_certificate_get_subject_dn (certificate); + g_debug ("first certificate: %s", subject); + g_free (subject); if (lookups && pv->peer) { ret = gcr_trust_is_certificate_pinned (certificate, pv->purpose, pv->peer, cancellable, &error); if (!ret && error) { - _gcr_debug ("failed to lookup pinned certificate: %s", - egg_error_message (error)); + g_debug ("failed to lookup pinned certificate: %s", + egg_error_message (error)); g_propagate_error (rerror, error); g_ptr_array_unref (input); return FALSE; @@ -286,8 +282,8 @@ perform_build_chain (GcrCertificateChainPrivate *pv, GCancellable *cancellable, * is irrelevant, so truncate chain and consider built. */ if (ret) { - _gcr_debug ("found pinned certificate for peer '%s', truncating chain", - pv->peer); + g_debug ("found pinned certificate for peer '%s', truncating chain", + pv->peer); g_ptr_array_unref (input); pv->status = GCR_CERTIFICATE_CHAIN_PINNED; @@ -301,7 +297,7 @@ perform_build_chain (GcrCertificateChainPrivate *pv, GCancellable *cancellable, /* Stop the chain if previous was self-signed */ if (gcr_certificate_is_issuer (certificate, certificate)) { - _gcr_debug ("found self-signed certificate"); + g_debug ("found self-signed certificate"); pv->status = GCR_CERTIFICATE_CHAIN_SELFSIGNED; break; } @@ -309,42 +305,38 @@ perform_build_chain (GcrCertificateChainPrivate *pv, GCancellable *cancellable, /* Get the next certificate */ certificate = pop_certificate (input, issued); if (certificate) { - if (_gcr_debugging) { - subject = gcr_certificate_get_subject_dn (certificate); - _gcr_debug ("next certificate: %s", subject); - g_free (subject); - } + subject = gcr_certificate_get_subject_dn (certificate); + g_debug ("next certificate: %s", subject); + g_free (subject); /* No more in chain, try to lookup */ } else if (lookups) { certificate = gcr_pkcs11_certificate_lookup_issuer (issued, cancellable, &error); if (error != NULL) { - _gcr_debug ("failed to lookup issuer: %s", error->message); + g_debug ("failed to lookup issuer: %s", error->message); g_propagate_error (rerror, error); g_ptr_array_unref (input); return FALSE; } else if (certificate) { - if (_gcr_debugging) { - subject = gcr_certificate_get_subject_dn (certificate); - _gcr_debug ("found issuer certificate: %s", subject); - g_free (subject); - } + subject = gcr_certificate_get_subject_dn (certificate); + g_debug ("found issuer certificate: %s", subject); + g_free (subject); } else { - _gcr_debug ("no issuer found"); + g_debug ("no issuer found"); } /* No more in chain, and can't lookup */ } else { - _gcr_debug ("no more certificates available, and no lookups"); + g_debug ("no more certificates available, and no lookups"); certificate = NULL; } /* Stop the chain if nothing found */ if (certificate == NULL) { - _gcr_debug ("chain is incomplete"); + g_debug ("chain is incomplete"); pv->status = GCR_CERTIFICATE_CHAIN_INCOMPLETE; break; } @@ -358,15 +350,15 @@ perform_build_chain (GcrCertificateChainPrivate *pv, GCancellable *cancellable, cancellable, &error); if (!ret && error) { - _gcr_debug ("failed to lookup anchored certificate: %s", - egg_error_message (error)); + g_debug ("failed to lookup anchored certificate: %s", + egg_error_message (error)); g_propagate_error (rerror, error); g_ptr_array_unref (input); return FALSE; /* Stop the chain at the first anchor */ } else if (ret) { - _gcr_debug ("found anchored certificate"); + g_debug ("found anchored certificate"); pv->status = GCR_CERTIFICATE_CHAIN_ANCHORED; break; } @@ -389,7 +381,7 @@ thread_build_chain (GSimpleAsyncResult *result, GObject *object, pv = g_object_get_qdata (G_OBJECT (result), Q_OPERATION_DATA); g_assert (pv); - _gcr_debug ("building asynchronously in another thread"); + g_debug ("building asynchronously in another thread"); if (!perform_build_chain (pv, cancellable, &error)) { g_simple_async_result_set_from_error (result, error); diff --git a/gcr/gcr-debug.c b/gcr/gcr-debug.c deleted file mode 100644 index 172590b..0000000 --- a/gcr/gcr-debug.c +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* - * Copyright (C) 2007 Collabora Ltd. - * Copyright (C) 2007 Nokia Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#include "gcr-debug.h" - -#include <errno.h> -#include <fcntl.h> -#include <stdarg.h> -#include <sys/stat.h> -#include <unistd.h> - -#include <glib.h> -#include <glib/gstdio.h> - -#ifdef WITH_DEBUG - -static GcrDebugFlags current_flags = 0; - -static GDebugKey keys[] = { - { "library", GCR_DEBUG_LIBRARY }, - { "certificate-chain", GCR_DEBUG_CERTIFICATE_CHAIN }, - { "parse", GCR_DEBUG_PARSE }, - { "gnupg", GCR_DEBUG_GNUPG }, - { "trust", GCR_DEBUG_TRUST }, - { "import", GCR_DEBUG_IMPORT }, - { "key", GCR_DEBUG_KEY }, - { "prompt", GCR_DEBUG_PROMPT }, - { "secret-exchange", GCR_DEBUG_SECRET_EXCHANGE }, - { 0, } -}; - -static void -debug_set_flags (GcrDebugFlags new_flags) -{ - current_flags |= new_flags; -} - -void -_gcr_debug_set_flags (const gchar *flags_string) -{ - guint nkeys; - - for (nkeys = 0; keys[nkeys].value; nkeys++); - - if (flags_string) - debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys)); -} - -gboolean -_gcr_debug_flag_is_set (GcrDebugFlags flag) -{ - return (flag & current_flags) != 0; -} - -static void -on_gcr_log_debug (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) -{ - GString *gstring; - const gchar *progname; - - gstring = g_string_new (NULL); - - progname = g_get_prgname (); - g_string_append_printf (gstring, "(%s:%lu): %s-DEBUG: %s\n", - progname ? progname : "process", - (gulong)getpid (), log_domain, - message ? message : "(NULL) message"); - - /* - * Give up on debug messages if stdout got lost. - */ - if (write (1, gstring->str, gstring->len) != gstring->len) - current_flags = 0; - - g_string_free (gstring, TRUE); -} - -void -_gcr_debug_message (GcrDebugFlags flag, const gchar *format, ...) -{ - static gsize initialized_flags = 0; - const gchar *messages_env; - const gchar *debug_env; - va_list args; - - if (g_once_init_enter (&initialized_flags)) { - messages_env = g_getenv ("G_MESSAGES_DEBUG"); - debug_env = g_getenv ("GCR_DEBUG"); -#ifdef GCR_DEBUG - if (debug_env == NULL) - debug_env = G_STRINGIFY (GCR_DEBUG); -#endif - - /* - * If the caller is selectively asking for certain debug - * messages with the GCR_DEBUG environment variable, then - * we install our own output handler and only print those - * messages. This happens irrespective of G_MESSAGES_DEBUG - */ - if (messages_env == NULL && debug_env != NULL) - g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - on_gcr_log_debug, NULL); - - /* - * If the caller is using G_MESSAGES_DEBUG then we enable - * all our debug messages, and let Glib filter which ones - * to display. - */ - if (messages_env != NULL && debug_env == NULL) - debug_env = "all"; - - _gcr_debug_set_flags (debug_env); - - g_once_init_leave (&initialized_flags, 1); - } - - if (flag & current_flags) { - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); - va_end (args); - } -} - -#else /* !WITH_DEBUG */ - -gboolean -_gcr_debug_flag_is_set (GcrDebugFlags flag) -{ - return FALSE; -} - -void -_gcr_debug_message (GcrDebugFlags flag, const gchar *format, ...) -{ -} - -void -_gcr_debug_set_flags (const gchar *flags_string) -{ -} - -#endif /* !WITH_DEBUG */ diff --git a/gcr/gcr-debug.h b/gcr/gcr-debug.h deleted file mode 100644 index 49dd939..0000000 --- a/gcr/gcr-debug.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2007 Nokia Corporation - * Copyright (C) 2007-2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef GCR_DEBUG_H -#define GCR_DEBUG_H - -#include "config.h" - -#include <glib.h> - -G_BEGIN_DECLS - -/* Please keep this enum in sync with #keys in gcr-debug.c */ -typedef enum { - GCR_DEBUG_LIBRARY = 1 << 1, - GCR_DEBUG_CERTIFICATE_CHAIN = 1 << 2, - GCR_DEBUG_PARSE = 1 << 3, - GCR_DEBUG_GNUPG = 1 << 4, - GCR_DEBUG_TRUST = 1 << 5, - GCR_DEBUG_IMPORT = 1 << 6, - GCR_DEBUG_KEY = 1 << 7, - GCR_DEBUG_PROMPT = 1 << 8, - GCR_DEBUG_SECRET_EXCHANGE = 1 << 9, -} GcrDebugFlags; - -gboolean _gcr_debug_flag_is_set (GcrDebugFlags flag); - -void _gcr_debug_set_flags (const gchar *flags_string); - -void _gcr_debug_message (GcrDebugFlags flag, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); - -G_END_DECLS - -#endif /* GCR_DEBUG_H */ - -/* ----------------------------------------------------------------------------- - * Below this point is outside the GCR_DEBUG_H guard - so it can take effect - * more than once. So you can do: - * - * #define DEBUG_FLAG GCR_DEBUG_ONE_THING - * #include "gcr-debug.h" - * ... - * DEBUG ("if we're debugging one thing"); - * ... - * #undef DEBUG_FLAG - * #define DEBUG_FLAG GCR_DEBUG_OTHER_THING - * #include "gcr-debug.h" - * ... - * DEBUG ("if we're debugging the other thing"); - * ... - */ - -#ifdef DEBUG_FLAG -#ifdef WITH_DEBUG - -#undef _gcr_debug -#define _gcr_debug(format, ...) \ - _gcr_debug_message (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__) - -#undef _gcr_debugging -#define _gcr_debugging \ - _gcr_debug_flag_is_set (DEBUG_FLAG) - -#else /* !defined (WITH_DEBUG) */ - -#undef _gcr_debug -#define _gcr_debug(format, ...) \ - do {} while (0) - -#undef _gcr_debugging -#define _gcr_debugging 0 - -#endif /* !defined (WITH_DEBUG) */ - -#endif /* defined (DEBUG_FLAG) */ diff --git a/gcr/gcr-gnupg-collection.c b/gcr/gcr-gnupg-collection.c index f16f7f7..e46f348 100644 --- a/gcr/gcr-gnupg-collection.c +++ b/gcr/gcr-gnupg-collection.c @@ -23,8 +23,6 @@ #include "gcr-callback-output-stream.h" #include "gcr-collection.h" -#define DEBUG_FLAG GCR_DEBUG_GNUPG -#include "gcr-debug.h" #include "gcr-gnupg-collection.h" #include "gcr-gnupg-key.h" #include "gcr-gnupg-process.h" @@ -308,8 +306,8 @@ process_records_as_public_key (GcrGnupgCollectionLoad *load, GPtrArray *records, if (fingerprint && load->attributes) attr_records = g_hash_table_lookup (load->attributes, fingerprint); if (attr_records) { - _gcr_debug ("adding %d user id attribute(s) to key/fingerprint: %s/%s", - (gint)attr_records->len, keyid, fingerprint); + g_debug ("adding %d user id attribute(s) to key/fingerprint: %s/%s", + (gint)attr_records->len, keyid, fingerprint); if (!g_hash_table_lookup_extended (load->attributes, fingerprint, (gpointer*)&orig_fingerprint, NULL)) @@ -333,13 +331,13 @@ process_records_as_public_key (GcrGnupgCollectionLoad *load, GPtrArray *records, /* Already have this key, just update */ if (key) { - _gcr_debug ("updating public key: %s", keyid); + g_debug ("updating public key: %s", keyid); _gcr_gnupg_key_set_public_records (key, records); /* Add a new key */ } else { key = _gcr_gnupg_key_new (records, NULL); - _gcr_debug ("creating public key: %s", keyid); + g_debug ("creating public key: %s", keyid); g_hash_table_insert (load->collection->pv->items, g_strdup (keyid), key); gcr_collection_emit_added (GCR_COLLECTION (load->collection), G_OBJECT (key)); } @@ -359,7 +357,7 @@ process_records_as_secret_key (GcrGnupgCollectionLoad *load, GPtrArray *records, /* Tell the private key that it's a secret one */ } else { - _gcr_debug ("adding secret records to key: %s", keyid); + g_debug ("adding secret records to key: %s", keyid); _gcr_gnupg_key_set_secret_records (key, records); } } @@ -413,7 +411,7 @@ process_outstanding_attribute (GcrGnupgCollectionLoad *load, GcrRecord *record) /* Do we have enough data for this attribute? */ if (!load->attribute_buf || load->attribute_buf->len < length) { - _gcr_debug ("not enough attribute data in buffer: %u", length); + g_debug ("not enough attribute data in buffer: %u", length); return FALSE; } @@ -427,8 +425,8 @@ process_outstanding_attribute (GcrGnupgCollectionLoad *load, GcrRecord *record) g_hash_table_insert (load->attributes, g_strdup (fingerprint), records); } - _gcr_debug ("new attribute of length %d for key with fingerprint %s", - length, fingerprint); + g_debug ("new attribute of length %d for key with fingerprint %s", + length, fingerprint); xa1 = _gcr_gnupg_build_xa1_record (record, load->attribute_buf->data, length); g_ptr_array_add (records, xa1); @@ -454,8 +452,8 @@ process_outstanding_attributes (GcrGnupgCollectionLoad *load) if (load->attribute_queue == NULL) return; - _gcr_debug ("%d outstanding attribute records", - (gint)g_queue_get_length (load->attribute_queue)); + g_debug ("%d outstanding attribute records", + (gint)g_queue_get_length (load->attribute_queue)); for (;;) { record = g_queue_peek_head (load->attribute_queue); @@ -475,7 +473,7 @@ on_line_parse_output (const gchar *line, gpointer user_data) GcrRecord *record; GQuark schema; - _gcr_debug ("output: %s", line); + g_debug ("output: %s", line); record = _gcr_record_parse_colons (line, -1); if (!record) { @@ -490,7 +488,7 @@ on_line_parse_output (const gchar *line, gpointer user_data) * it's a new key being listed. */ if (schema == GCR_RECORD_SCHEMA_PUB || schema == GCR_RECORD_SCHEMA_SEC) { - _gcr_debug ("start of new key"); + g_debug ("start of new key"); if (load->records->len) process_records_as_key (load); g_assert (!load->records->len); @@ -600,13 +598,13 @@ on_gnupg_process_completed (GObject *source, GAsyncResult *result, gpointer user /* If we completed loading public keys, then go and load secret */ switch (load->loading_phase) { case GCR_LOADING_PHASE_PUBLIC: - _gcr_debug ("public load phase completed"); + g_debug ("public load phase completed"); load->loading_phase = GCR_LOADING_PHASE_SECRET; spawn_gnupg_list_process (load, res); g_object_unref (res); return; case GCR_LOADING_PHASE_SECRET: - _gcr_debug ("secret load phase completed"); + g_debug ("secret load phase completed"); /* continue below */ break; default: @@ -619,7 +617,7 @@ on_gnupg_process_completed (GObject *source, GAsyncResult *result, gpointer user object = g_hash_table_lookup (load->collection->pv->items, keyid); if (object != NULL) { g_object_ref (object); - _gcr_debug ("removing key no longer present in keyring: %s", (gchar*)keyid); + g_debug ("removing key no longer present in keyring: %s", (gchar*)keyid); g_hash_table_remove (load->collection->pv->items, keyid); gcr_collection_emit_removed (GCR_COLLECTION (load->collection), object); g_object_unref (object); @@ -640,14 +638,14 @@ spawn_gnupg_list_process (GcrGnupgCollectionLoad *load, GSimpleAsyncResult *res) switch (load->loading_phase) { case GCR_LOADING_PHASE_PUBLIC: - _gcr_debug ("starting public load phase"); + g_debug ("starting public load phase"); g_ptr_array_add (argv, (gpointer)"--list-keys"); /* Load photos in public phase */ flags = GCR_GNUPG_PROCESS_WITH_ATTRIBUTES | GCR_GNUPG_PROCESS_WITH_STATUS; break; case GCR_LOADING_PHASE_SECRET: - _gcr_debug ("starting secret load phase"); + g_debug ("starting secret load phase"); g_ptr_array_add (argv, (gpointer)"--list-secret-keys"); break; default: diff --git a/gcr/gcr-gnupg-process.c b/gcr/gcr-gnupg-process.c index 63fab11..a53d6db 100644 --- a/gcr/gcr-gnupg-process.c +++ b/gcr/gcr-gnupg-process.c @@ -21,8 +21,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_GNUPG -#include "gcr-debug.h" #include "gcr-gnupg-process.h" #include "gcr-util.h" @@ -422,7 +420,7 @@ run_async_ready_callback (GcrGnupgProcess *self) GAsyncReadyCallback callback; gpointer user_data; - _gcr_debug ("running async callback"); + g_debug ("running async callback"); /* Remove these before completing */ callback = self->pv->async_callback; @@ -444,7 +442,7 @@ on_run_async_ready_callback_later (gpointer user_data) static void run_async_ready_callback_later (GcrGnupgProcess *self) { - _gcr_debug ("running async callback later"); + g_debug ("running async callback later"); g_idle_add_full (G_PRIORITY_DEFAULT, on_run_async_ready_callback_later, g_object_ref (self), g_object_unref); } @@ -459,10 +457,10 @@ complete_run_process (GcrGnupgProcess *self) self->pv->complete = TRUE; if (self->pv->error == NULL) { - _gcr_debug ("completed process"); + g_debug ("completed process"); } else { - _gcr_debug ("completed process with error: %s", - self->pv->error->message); + g_debug ("completed process with error: %s", + self->pv->error->message); } } @@ -471,7 +469,7 @@ complete_source_is_done (GnupgSource *gnupg_source) { GcrGnupgProcess *self = gnupg_source->process; - _gcr_debug ("all fds closed and process exited, completing"); + g_debug ("all fds closed and process exited, completing"); g_assert (gnupg_source->child_sig == 0); @@ -494,7 +492,7 @@ close_fd (int *fd) { g_assert (fd); if (*fd >= 0) { - _gcr_debug ("closing fd: %d", *fd); + g_debug ("closing fd: %d", *fd); close (*fd); } *fd = -1; @@ -614,7 +612,7 @@ emit_status_for_each_line (const gchar *line, gpointer user_data) GcrRecord *record; if (g_str_has_prefix (line, "[GNUPG:] ")) { - _gcr_debug ("received status line: %s", line); + g_debug ("received status line: %s", line); line += 9; } else { g_message ("gnupg status record was not prefixed appropriately: %s", line); @@ -634,7 +632,7 @@ emit_status_for_each_line (const gchar *line, gpointer user_data) static void emit_error_for_each_line (const gchar *line, gpointer user_data) { - _gcr_debug ("received error line: %s", line); + g_debug ("received error line: %s", line); g_signal_emit (GCR_GNUPG_PROCESS (user_data), signals[ERROR_LINE], 0, line); } @@ -704,7 +702,7 @@ on_gnupg_source_attribute (GcrGnupgProcess *self, g_warning ("couldn't read attribute data from gnupg process"); result = FALSE; } else if (buffer->len > 0) { - _gcr_debug ("received %d bytes of attribute data", (gint)buffer->len); + g_debug ("received %d bytes of attribute data", (gint)buffer->len); if (self->pv->attributes != NULL) g_output_stream_write_all (self->pv->attributes, buffer->data, buffer->len, NULL, @@ -727,7 +725,7 @@ on_gnupg_source_output (GcrGnupgProcess *self, g_warning ("couldn't read output data from gnupg process"); result = FALSE; } else if (buffer->len > 0) { - _gcr_debug ("received %d bytes of output data", (gint)buffer->len); + g_debug ("received %d bytes of output data", (gint)buffer->len); if (self->pv->output != NULL) g_output_stream_write_all (self->pv->output, buffer->data, buffer->len, NULL, gnupg_source->cancellable, NULL); @@ -853,7 +851,7 @@ on_gnupg_process_child_exited (GPid pid, gint status, gpointer user_data) gint code; guint i; - _gcr_debug ("process exited: %d", (int)pid); + g_debug ("process exited: %d", (int)pid); g_spawn_close_pid (gnupg_source->child_pid); gnupg_source->child_pid = 0; @@ -875,7 +873,7 @@ on_gnupg_process_child_exited (GPid pid, gint status, gpointer user_data) /* Take this as the async result error */ if (error && !self->pv->error) { - _gcr_debug ("%s", error->message); + g_debug ("%s", error->message); self->pv->error = error; /* Already have an error, just print out message */ @@ -919,7 +917,7 @@ on_cancellable_cancelled (GCancellable *cancellable, gpointer user_data) g_assert (gnupg_source->process); - _gcr_debug ("process cancelled"); + g_debug ("process cancelled"); /* Set an error, which is respected when this actually completes. */ if (gnupg_source->process->pv->error == NULL) @@ -928,8 +926,8 @@ on_cancellable_cancelled (GCancellable *cancellable, gpointer user_data) /* Try and kill the child process */ if (gnupg_source->child_pid) { - _gcr_debug ("sending term signal to process: %d", - (int)gnupg_source->child_pid); + g_debug ("sending term signal to process: %d", + (int)gnupg_source->child_pid); kill (gnupg_source->child_pid, SIGTERM); } } @@ -1033,14 +1031,12 @@ _gcr_gnupg_process_run_async (GcrGnupgProcess *self, const gchar **argv, const g g_ptr_array_add (envs, (gpointer)"LOCALE=C"); g_ptr_array_add (envs, NULL); - if (_gcr_debugging) { - gchar *command = g_strjoinv (" ", (gchar**)args->pdata); - gchar *environ = g_strjoinv (", ", (gchar**)envs->pdata); - _gcr_debug ("running command: %s", command); - _gcr_debug ("process environment: %s", environ); - g_free (command); - g_free (environ); - } + gchar *command = g_strjoinv (" ", (gchar**)args->pdata); + gchar *environ = g_strjoinv (", ", (gchar**)envs->pdata); + g_debug ("running command: %s", command); + g_debug ("process environment: %s", environ); + g_free (command); + g_free (environ); g_spawn_async_with_pipes (self->pv->directory, (gchar**)args->pdata, (gchar**)envs->pdata, G_SPAWN_DO_NOT_REAP_CHILD, @@ -1067,7 +1063,7 @@ _gcr_gnupg_process_run_async (GcrGnupgProcess *self, const gchar **argv, const g return; } - _gcr_debug ("process started: %d", (int)pid); + g_debug ("process started: %d", (int)pid); source = g_source_new (&gnupg_source_funcs, sizeof (GnupgSource)); diff --git a/gcr/gcr-importer.c b/gcr/gcr-importer.c index 528d06b..ef029e1 100644 --- a/gcr/gcr-importer.c +++ b/gcr/gcr-importer.c @@ -21,8 +21,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_IMPORT -#include "gcr-debug.h" #include "gcr-deprecated-base.h" #include "gcr-importer.h" #include "gcr-internal.h" @@ -232,11 +230,9 @@ gcr_importer_create_for_parsed (GcrParsed *parsed) seen = g_hash_table_new (g_direct_hash, g_direct_equal); - if (_gcr_debugging) { - gchar *a = gck_attributes_to_string (attrs); - _gcr_debug ("looking for importer for: %s", a); - g_free (a); - } + gchar *a = gck_attributes_to_string (attrs); + g_debug ("looking for importer for: %s", a); + g_free (a); for (i = 0; i < registered_importers->len; ++i) { registered = &(g_array_index (registered_importers, GcrRegistered, i)); @@ -251,12 +247,10 @@ gcr_importer_create_for_parsed (GcrParsed *parsed) } } - if (_gcr_debugging) { - gchar *a = gck_attributes_to_string (registered->attrs); - _gcr_debug ("importer %s %s: %s", g_type_name (registered->importer_type), - matched ? "matched" : "didn't match", a); - g_free (a); - } + gchar *a = gck_attributes_to_string (registered->attrs); + g_debug ("importer %s %s: %s", g_type_name (registered->importer_type), + matched ? "matched" : "didn't match", a); + g_free (a); if (matched) { if (check_if_seen_or_add (seen, GUINT_TO_POINTER (registered->importer_type))) diff --git a/gcr/gcr-key-mechanisms.c b/gcr/gcr-key-mechanisms.c index a23ee4d..dce6038 100644 --- a/gcr/gcr-key-mechanisms.c +++ b/gcr/gcr-key-mechanisms.c @@ -17,8 +17,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_KEY -#include "gcr-debug.h" #include "gcr-key-mechanisms.h" #include <glib/gi18n-lib.h> @@ -52,7 +50,7 @@ find_first_usable_mechanism (GckObject *key, gsize i; if (gck_attributes_find_boolean (attrs, action_attr_type, &can) && !can) { - _gcr_debug ("key not capable of needed action"); + g_debug ("key not capable of needed action"); return GCK_INVALID; } @@ -63,7 +61,7 @@ find_first_usable_mechanism (GckObject *key, g_object_unref (session); if (!mechs) { - _gcr_debug ("couldn't get slot mechanisms"); + g_debug ("couldn't get slot mechanisms"); return GCK_INVALID; } diff --git a/gcr/gcr-library.c b/gcr/gcr-library.c index b0f009a..7275c63 100644 --- a/gcr/gcr-library.c +++ b/gcr/gcr-library.c @@ -19,8 +19,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_LIBRARY -#include "gcr-debug.h" #include "gcr-deprecated-base.h" #include "gcr-internal.h" #include "gcr-library.h" @@ -182,7 +180,7 @@ _gcr_initialize_library (void) /* Initialize the libgcrypt library if needed */ egg_libgcrypt_initialize (); - _gcr_debug ("initialized library"); + g_debug ("initialized library"); } static void @@ -197,7 +195,7 @@ initialize_uris (void) return; if (!initialized_modules) { - _gcr_debug ("modules not initialized"); + g_debug ("modules not initialized"); return; } @@ -225,9 +223,9 @@ initialize_uris (void) trust_lookup_uris = (gchar**)g_ptr_array_free (uris, FALSE); - _gcr_debug ("trust store uri is: %s", trust_store_uri); + g_debug ("trust store uri is: %s", trust_store_uri); debug = g_strjoinv (" ", trust_lookup_uris); - _gcr_debug ("trust lookup uris are: %s", debug); + g_debug ("trust lookup uris are: %s", debug); g_free (debug); initialized_uris = TRUE; @@ -247,7 +245,7 @@ on_initialize_registered (GObject *object, results = gck_modules_initialize_registered_finish (result, &error); if (error != NULL) { - _gcr_debug ("failed %s", error->message); + g_debug ("failed %s", error->message); g_simple_async_result_take_error (res, error); } else { @@ -265,7 +263,7 @@ on_initialize_registered (GObject *object, gck_list_unref_free (results); - _gcr_debug ("completed initialize of registered modules"); + g_debug ("completed initialize of registered modules"); g_simple_async_result_complete (res); g_object_unref (res); } @@ -289,13 +287,13 @@ gcr_pkcs11_initialize_async (GCancellable *cancellable, gcr_pkcs11_initialize_async); if (initialized_modules) { - _gcr_debug ("already initialized, no need to async"); + g_debug ("already initialized, no need to async"); g_simple_async_result_complete_in_idle (res); } else { gck_modules_initialize_registered_async (cancellable, on_initialize_registered, g_object_ref (res)); - _gcr_debug ("starting initialize of registered modules"); + g_debug ("starting initialize of registered modules"); } g_object_unref (res); @@ -347,8 +345,8 @@ gcr_pkcs11_initialize (GCancellable *cancellable, results = gck_modules_initialize_registered (cancellable, &err); if (err == NULL) { - _gcr_debug ("registered module initialize succeeded: %d modules", - g_list_length (results)); + g_debug ("registered module initialize succeeded: %d modules", + g_list_length (results)); G_LOCK (modules); @@ -361,7 +359,7 @@ gcr_pkcs11_initialize (GCancellable *cancellable, G_UNLOCK (modules); } else { - _gcr_debug ("registered module initialize failed: %s", err->message); + g_debug ("registered module initialize failed: %s", err->message); g_propagate_error (error, err); } @@ -387,9 +385,9 @@ GList* gcr_pkcs11_get_modules (void) { if (!initialized_modules) - _gcr_debug ("pkcs11 not yet initialized"); + g_debug ("pkcs11 not yet initialized"); else if (!all_modules) - _gcr_debug ("no modules loaded"); + g_debug ("no modules loaded"); return gck_list_ref_copy (all_modules); } @@ -464,7 +462,7 @@ gcr_pkcs11_add_module_from_file (const gchar *module_path, gpointer unused, module = gck_module_initialize (module_path, NULL, &err); if (module == NULL) { - _gcr_debug ("initializing module failed: %s: %s", + g_debug ("initializing module failed: %s: %s", module_path, err->message); g_propagate_error (error, err); return FALSE; @@ -472,7 +470,7 @@ gcr_pkcs11_add_module_from_file (const gchar *module_path, gpointer unused, gcr_pkcs11_add_module (module); - _gcr_debug ("initialized and added module: %s", module_path); + g_debug ("initialized and added module: %s", module_path); g_object_unref (module); return TRUE; } @@ -507,7 +505,7 @@ gcr_pkcs11_get_trust_store_slot (void) trust_store_uri, egg_error_message (error)); g_clear_error (&error); } else { - _gcr_debug ("no trust store slot found"); + g_debug ("no trust store slot found"); } } @@ -550,7 +548,7 @@ gcr_pkcs11_get_trust_lookup_slots (void) } if (results == NULL) - _gcr_debug ("no trust lookup slots found"); + g_debug ("no trust lookup slots found"); return results; } diff --git a/gcr/gcr-pkcs11-importer.c b/gcr/gcr-pkcs11-importer.c index 0a9ce75..650321e 100644 --- a/gcr/gcr-pkcs11-importer.c +++ b/gcr/gcr-pkcs11-importer.c @@ -22,8 +22,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_IMPORT -#include "gcr-debug.h" #include "gcr-fingerprint.h" #include "gcr-icons.h" #include "gcr-internal.h" @@ -764,16 +762,16 @@ is_slot_importable (GckSlot *slot, guint i; if (token->flags & CKF_WRITE_PROTECTED) { - _gcr_debug ("token is not importable: %s: write protected", token->label); + g_debug ("token is not importable: %s: write protected", token->label); return FALSE; } if (!(token->flags & CKF_TOKEN_INITIALIZED)) { - _gcr_debug ("token is not importable: %s: not initialized", token->label); + g_debug ("token is not importable: %s: not initialized", token->label); return FALSE; } if ((token->flags & CKF_LOGIN_REQUIRED) && !(token->flags & CKF_USER_PIN_INITIALIZED)) { - _gcr_debug ("token is not importable: %s: user pin not initialized", token->label); + g_debug ("token is not importable: %s: user pin not initialized", token->label); return FALSE; } @@ -789,7 +787,7 @@ is_slot_importable (GckSlot *slot, gck_uri_data_free (uri); if (match) { - _gcr_debug ("token is not importable: %s: on the black list", token->label); + g_debug ("token is not importable: %s: on the black list", token->label); return FALSE; } } @@ -812,7 +810,7 @@ _gcr_pkcs11_importer_create_for_parsed (GcrParsed *parsed) importable = is_slot_importable (l->data, token_info); if (importable) { - _gcr_debug ("creating importer for token: %s", token_info->label); + g_debug ("creating importer for token: %s", token_info->label); self = _gcr_pkcs11_importer_new (l->data); if (!gcr_importer_queue_for_parsed (self, parsed)) g_assert_not_reached (); diff --git a/gcr/gcr-record.c b/gcr/gcr-record.c index c4549e0..d5cad5a 100644 --- a/gcr/gcr-record.c +++ b/gcr/gcr-record.c @@ -22,8 +22,6 @@ #include "config.h" #include "gcr-record.h" -#define DEBUG_FLAG GCR_DEBUG_PARSE -#include "gcr-debug.h" #include "egg/egg-timegm.h" @@ -185,12 +183,12 @@ take_and_parse_internal (GcrRecordBlock *block, result->block = block; result->delimiter = delimiter; - _gcr_debug ("parsing line %s", block->value); + g_debug ("parsing line %s", block->value); at = block->value; for (;;) { if (result->n_columns >= MAX_COLUMNS) { - _gcr_debug ("too many record (%d) in gnupg line", MAX_COLUMNS); + g_debug ("too many record (%d) in gnupg line", MAX_COLUMNS); _gcr_record_free (result); return NULL; } @@ -512,12 +510,12 @@ _gcr_record_get_uint (GcrRecord *record, guint column, guint *value) result = g_ascii_strtoll (raw, &end, 10); if (!end || end[0]) { - _gcr_debug ("invalid unsigned integer value: %s", raw); + g_debug ("invalid unsigned integer value: %s", raw); return FALSE; } if (result < 0 || result > G_MAXUINT32) { - _gcr_debug ("unsigned integer value is out of range: %s", raw); + g_debug ("unsigned integer value is out of range: %s", raw); return FALSE; } @@ -558,12 +556,12 @@ _gcr_record_get_ulong (GcrRecord *record, result = g_ascii_strtoull (raw, &end, 10); if (!end || end[0]) { - _gcr_debug ("invalid unsigned long value: %s", raw); + g_debug ("invalid unsigned long value: %s", raw); return FALSE; } if (result < 0 || result > G_MAXULONG) { - _gcr_debug ("unsigned long value is out of range: %s", raw); + g_debug ("unsigned long value is out of range: %s", raw); return FALSE; } @@ -616,7 +614,7 @@ _gcr_record_get_date (GcrRecord *record, memset (&tm, 0, sizeof (tm)); end = strptime (raw, "%Y-%m-%d", &tm); if (!end || end[0]) { - _gcr_debug ("invalid date value: %s", raw); + g_debug ("invalid date value: %s", raw); return NULL; } @@ -683,8 +681,8 @@ _gcr_record_get_raw (GcrRecord *record, guint column) g_return_val_if_fail (record, NULL); if (column >= record->n_columns) { - _gcr_debug ("only %d columns exist, tried to access %d", - record->n_columns, column); + g_debug ("only %d columns exist, tried to access %d", + record->n_columns, column); return NULL; } diff --git a/gcr/gcr-secret-exchange.c b/gcr/gcr-secret-exchange.c index 360c329..1b53eff 100644 --- a/gcr/gcr-secret-exchange.c +++ b/gcr/gcr-secret-exchange.c @@ -19,8 +19,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_SECRET_EXCHANGE -#include "gcr-debug.h" #include "gcr-secret-exchange.h" #include "egg/egg-dh.h" @@ -156,12 +154,12 @@ gcr_secret_exchange_set_property (GObject *obj, case PROP_PROTOCOL: protocol = g_value_get_string (value); if (protocol == NULL) { - _gcr_debug ("automatically selecting secret exchange protocol"); + g_debug ("automatically selecting secret exchange protocol"); } else { if (g_str_equal (protocol, GCR_SECRET_EXCHANGE_PROTOCOL_1)) { - _gcr_debug ("explicitly using secret exchange protocol: %s", - GCR_SECRET_EXCHANGE_PROTOCOL_1); + g_debug ("explicitly using secret exchange protocol: %s", + GCR_SECRET_EXCHANGE_PROTOCOL_1); self->pv->explicit_protocol = TRUE; } else { g_warning ("the GcrSecretExchange protocol %s is unsupported defaulting to %s", @@ -300,11 +298,9 @@ gcr_secret_exchange_begin (GcrSecretExchange *self) g_strchug (result); - if (_gcr_debugging) { - gchar *string = g_strescape (result, ""); - _gcr_debug ("beginning the secret exchange: %s", string); - g_free (string); - } + gchar *string = g_strescape (result, ""); + g_debug ("beginning the secret exchange: %s", string); + g_free (string); if (!g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX)) g_warning ("the prepared data does not have the correct protocol prefix"); @@ -326,7 +322,7 @@ derive_key (GcrSecretExchange *self, klass = GCR_SECRET_EXCHANGE_GET_CLASS (self); g_return_val_if_fail (klass->derive_transport_key, FALSE); - _gcr_debug ("deriving shared transport key"); + g_debug ("deriving shared transport key"); peer = key_file_get_base64 (input, GCR_SECRET_EXCHANGE_PROTOCOL_1, "public", &n_peer); if (peer == NULL) { @@ -416,11 +412,9 @@ gcr_secret_exchange_receive (GcrSecretExchange *self, g_return_val_if_fail (klass->generate_exchange_key, FALSE); g_return_val_if_fail (klass->derive_transport_key, FALSE); - if (_gcr_debugging) { - gchar *string = g_strescape (exchange, ""); - _gcr_debug ("receiving secret exchange: %s", string); - g_free (string); - } + gchar *string = g_strescape (exchange, ""); + g_debug ("receiving secret exchange: %s", string); + g_free (string); /* Parse the input */ input = g_key_file_new (); @@ -562,11 +556,9 @@ gcr_secret_exchange_send (GcrSecretExchange *self, g_strchug (result); - if (_gcr_debugging) { - gchar *string = g_strescape (result, ""); - _gcr_debug ("sending the secret exchange: %s", string); - g_free (string); - } + gchar *string = g_strescape (result, ""); + g_debug ("sending the secret exchange: %s", string); + g_free (string); if (!g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX)) g_warning ("the prepared data does not have the correct protocol prefix: %s", result); @@ -652,7 +644,7 @@ gcr_secret_exchange_default_generate_exchange_key (GcrSecretExchange *exchange, { GcrSecretExchangeDefault *data = exchange->pv->default_exchange; - _gcr_debug ("generating public key"); + g_debug ("generating public key"); if (data == NULL) { data = g_new0 (GcrSecretExchangeDefault, 1); @@ -688,14 +680,14 @@ gcr_secret_exchange_default_derive_transport_key (GcrSecretExchange *exchange, gsize n_ikm; gcry_mpi_t mpi; - _gcr_debug ("deriving transport key"); + g_debug ("deriving transport key"); g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (data->priv != NULL, FALSE); mpi = mpi_from_data (peer, n_peer); if (mpi == NULL) { - _gcr_debug ("invalid peer mpi"); + g_debug ("invalid peer mpi"); return FALSE; } @@ -737,7 +729,7 @@ gcr_secret_exchange_default_encrypt_transport_data (GcrSecretExchange *exchange, g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (data->key != NULL, FALSE); - _gcr_debug ("encrypting data"); + g_debug ("encrypting data"); gcry = gcry_cipher_open (&cih, EXCHANGE_1_CIPHER_ALGO, EXCHANGE_1_CIPHER_MODE, 0); if (gcry != 0) { @@ -802,7 +794,7 @@ gcr_secret_exchange_default_decrypt_transport_data (GcrSecretExchange *exchange, g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (data->key != NULL, FALSE); - _gcr_debug ("decrypting data"); + g_debug ("decrypting data"); if (iv == NULL || n_iv != EXCHANGE_1_IV_LENGTH) { g_message ("secret-exchange: invalid or missing iv"); diff --git a/gcr/gcr-subject-public-key.c b/gcr/gcr-subject-public-key.c index 9a27d54..c8f772c 100644 --- a/gcr/gcr-subject-public-key.c +++ b/gcr/gcr-subject-public-key.c @@ -20,8 +20,6 @@ */ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_KEY -#include "gcr-debug.h" #include "gcr-subject-public-key.h" #include "gcr-types.h" @@ -72,14 +70,14 @@ load_object_basics (GckObject *object, g_assert (type != NULL); if (check_object_basics (builder, klass, type)) { - _gcr_debug ("already loaded: class = %lu, type = %lu", *klass, *type); + g_debug ("already loaded: class = %lu, type = %lu", *klass, *type); return TRUE; } attrs = gck_object_cache_lookup (object, attr_types, G_N_ELEMENTS (attr_types), cancellable, &error); if (error != NULL) { - _gcr_debug ("couldn't load: %s", error->message); + g_debug ("couldn't load: %s", error->message); g_propagate_error (lerror, error); return FALSE; } @@ -90,7 +88,7 @@ load_object_basics (GckObject *object, if (!check_object_basics (builder, klass, type)) return FALSE; - _gcr_debug ("loaded: class = %lu, type = %lu", *klass, *type); + g_debug ("loaded: class = %lu, type = %lu", *klass, *type); return TRUE; } @@ -112,14 +110,14 @@ load_x509_attributes (GckObject *object, GError *error = NULL; if (check_x509_attributes (builder)) { - _gcr_debug ("already loaded"); + g_debug ("already loaded"); return TRUE; } attrs = gck_object_cache_lookup (object, attr_types, G_N_ELEMENTS (attr_types), cancellable, &error); if (error != NULL) { - _gcr_debug ("couldn't load: %s", error->message); + g_debug ("couldn't load: %s", error->message); g_propagate_error (lerror, error); return FALSE; } @@ -154,14 +152,14 @@ load_rsa_attributes (GckObject *object, GError *error = NULL; if (check_rsa_attributes (builder)) { - _gcr_debug ("rsa attributes already loaded"); + g_debug ("rsa attributes already loaded"); return TRUE; } attrs = gck_object_cache_lookup (object, attr_types, G_N_ELEMENTS (attr_types), cancellable, &error); if (error != NULL) { - _gcr_debug ("couldn't load rsa attributes: %s", error->message); + g_debug ("couldn't load rsa attributes: %s", error->message); g_propagate_error (lerror, error); return FALSE; } @@ -189,7 +187,7 @@ lookup_public_key (GckObject *object, attrs = gck_object_cache_lookup (object, attr_types, G_N_ELEMENTS (attr_types), cancellable, &error); if (error != NULL) { - _gcr_debug ("couldn't load private key id: %s", error->message); + g_debug ("couldn't load private key id: %s", error->message); g_propagate_error (lerror, error); return NULL; } @@ -197,7 +195,7 @@ lookup_public_key (GckObject *object, id = gck_attributes_find (attrs, CKA_ID); if (id == NULL || gck_attribute_is_invalid (id)) { gck_attributes_unref (attrs); - _gcr_debug ("couldn't load private key id"); + g_debug ("couldn't load private key id"); g_set_error_literal (lerror, GCK_ERROR, CKR_ATTRIBUTE_TYPE_INVALID, gck_message_from_rv (CKR_ATTRIBUTE_TYPE_INVALID)); return NULL; @@ -212,7 +210,7 @@ lookup_public_key (GckObject *object, g_object_unref (session); if (error != NULL) { - _gcr_debug ("couldn't lookup public key: %s", error->message); + g_debug ("couldn't lookup public key: %s", error->message); g_propagate_error (lerror, error); return NULL; } @@ -278,7 +276,7 @@ load_dsa_attributes (GckObject *object, g_object_unref (publi); if (error != NULL) { - _gcr_debug ("couldn't load rsa attributes: %s", error->message); + g_debug ("couldn't load rsa attributes: %s", error->message); g_propagate_error (lerror, error); return FALSE; } @@ -319,7 +317,7 @@ load_ec_attributes (GckObject *object, gulong klass; if (check_ec_attributes (builder)) { - _gcr_debug ("ec attributes already loaded"); + g_debug ("ec attributes already loaded"); return TRUE; } @@ -341,7 +339,7 @@ load_ec_attributes (GckObject *object, g_object_unref (publi); if (error != NULL) { - _gcr_debug ("couldn't load ec attributes: %s", error->message); + g_debug ("couldn't load ec attributes: %s", error->message); g_propagate_error (lerror, error); return FALSE; } @@ -374,7 +372,7 @@ load_attributes (GckObject *object, ret = load_x509_attributes (object, builder, cancellable, lerror); break; default: - _gcr_debug ("unsupported certificate type: %lu", type); + g_debug ("unsupported certificate type: %lu", type); break; } break; @@ -392,13 +390,13 @@ load_attributes (GckObject *object, ret = load_ec_attributes (object, builder, cancellable, lerror); break; default: - _gcr_debug ("unsupported key type: %lu", type); + g_debug ("unsupported key type: %lu", type); break; } break; default: - _gcr_debug ("unsupported class: %lu", type); + g_debug ("unsupported class: %lu", type); break; } @@ -794,7 +792,7 @@ cert_subject_public_key_from_attributes (GckAttributes *attributes) attr = gck_attributes_find (attributes, CKA_VALUE); if (attr == NULL || gck_attribute_is_invalid (attr)) { - _gcr_debug ("no value attribute for certificate"); + g_debug ("no value attribute for certificate"); return NULL; } @@ -805,7 +803,7 @@ cert_subject_public_key_from_attributes (GckAttributes *attributes) g_bytes_unref (bytes); if (cert == NULL) { - _gcr_debug ("couldn't parse certificate value"); + g_debug ("couldn't parse certificate value"); return NULL; } @@ -828,7 +826,7 @@ _gcr_subject_public_key_for_attributes (GckAttributes *attributes) GNode *asn = NULL; if (!gck_attributes_find_ulong (attributes, CKA_CLASS, &klass)) { - _gcr_debug ("no class in attributes"); + g_debug ("no class in attributes"); return NULL; } @@ -837,7 +835,7 @@ _gcr_subject_public_key_for_attributes (GckAttributes *attributes) } else if (klass == CKO_PUBLIC_KEY || klass == CKO_PRIVATE_KEY) { if (!gck_attributes_find_ulong (attributes, CKA_KEY_TYPE, &key_type)) { - _gcr_debug ("no key type in attributes"); + g_debug ("no key type in attributes"); return NULL; } @@ -854,7 +852,7 @@ _gcr_subject_public_key_for_attributes (GckAttributes *attributes) ret = ec_subject_public_key_from_attributes (attributes, klass, asn); } else { - _gcr_debug ("unsupported key type: %lu", key_type); + g_debug ("unsupported key type: %lu", key_type); ret = FALSE; } diff --git a/gcr/gcr-system-prompt.c b/gcr/gcr-system-prompt.c index 7874ad1..b3e7731 100644 --- a/gcr/gcr-system-prompt.c +++ b/gcr/gcr-system-prompt.c @@ -22,8 +22,6 @@ #include "config.h" #include "gcr-dbus-constants.h" -#define DEBUG_FLAG GCR_DEBUG_PROMPT -#include "gcr-debug.h" #include "gcr-internal.h" #include "gcr-library.h" #include "gcr-prompt.h" @@ -436,7 +434,7 @@ on_prompter_stop_prompting (GObject *source, retval = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), result, &error); if (error != NULL) { - _gcr_debug ("failed to stop prompting: %s", egg_error_message (error)); + g_debug ("failed to stop prompting: %s", egg_error_message (error)); g_clear_error (&error); } @@ -464,7 +462,7 @@ perform_close (GcrSystemPrompt *self, self->pv->closed = TRUE; if (!closed) - _gcr_debug ("closing prompt"); + g_debug ("closing prompt"); if (self->pv->pending) { res = g_object_ref (self->pv->pending); @@ -483,7 +481,7 @@ perform_close (GcrSystemPrompt *self, if (self->pv->begun_prompting) { if (self->pv->connection && self->pv->prompt_path && self->pv->prompt_owner) { - _gcr_debug ("Calling the prompter %s method", GCR_DBUS_PROMPTER_METHOD_STOP); + g_debug ("Calling the prompter %s method", GCR_DBUS_PROMPTER_METHOD_STOP); g_dbus_connection_call (self->pv->connection, self->pv->prompter_bus_name, GCR_DBUS_PROMPTER_OBJECT_PATH, @@ -608,7 +606,7 @@ gcr_system_prompt_get_secret_exchange (GcrSystemPrompt *self) g_return_val_if_fail (GCR_IS_SYSTEM_PROMPT (self), NULL); if (!self->pv->exchange) { - _gcr_debug ("creating new secret exchange"); + g_debug ("creating new secret exchange"); self->pv->exchange = gcr_secret_exchange_new (NULL); } @@ -801,7 +799,7 @@ on_prompter_vanished (GDBusConnection *connection, if (self->pv->prompt_owner) { g_free (self->pv->prompt_owner); self->pv->prompt_owner = NULL; - _gcr_debug ("prompter name owner has vanished: %s", name); + g_debug ("prompter name owner has vanished: %s", name); g_cancellable_cancel (call->cancellable); } @@ -822,11 +820,11 @@ on_bus_connected (GObject *source, self->pv->connection = g_bus_get_finish (result, &error); if (error != NULL) { - _gcr_debug ("failed to connect to bus: %s", egg_error_message (error)); + g_debug ("failed to connect to bus: %s", egg_error_message (error)); } else { g_return_if_fail (self->pv->connection != NULL); - _gcr_debug ("connected to bus"); + g_debug ("connected to bus"); g_main_context_push_thread_default (closure->context); @@ -869,15 +867,15 @@ on_prompter_begin_prompting (GObject *source, self->pv->begun_prompting = TRUE; g_variant_unref (ret); - _gcr_debug ("registered prompt %s: %s", - self->pv->prompter_bus_name, self->pv->prompt_path); + g_debug ("registered prompt %s: %s", + self->pv->prompter_bus_name, self->pv->prompt_path); g_return_if_fail (self->pv->prompt_path != NULL); perform_init_async (self, res); } else { - _gcr_debug ("failed to register prompt %s: %s", - self->pv->prompter_bus_name, egg_error_message (error)); + g_debug ("failed to register prompt %s: %s", + self->pv->prompter_bus_name, egg_error_message (error)); g_simple_async_result_take_error (res, error); g_simple_async_result_complete (res); @@ -940,7 +938,7 @@ perform_init_async (GcrSystemPrompt *self, /* 1. Connect to the session bus */ if (!self->pv->connection) { - _gcr_debug ("connecting to bus"); + g_debug ("connecting to bus"); g_bus_get (G_BUS_TYPE_SESSION, closure->cancellable, on_bus_connected, g_object_ref (res)); @@ -948,7 +946,7 @@ perform_init_async (GcrSystemPrompt *self, } else if (!self->pv->begun_prompting) { g_assert (self->pv->prompt_path != NULL); - _gcr_debug ("calling %s method on prompter", GCR_DBUS_PROMPTER_METHOD_BEGIN); + g_debug ("calling %s method on prompter", GCR_DBUS_PROMPTER_METHOD_BEGIN); g_dbus_connection_call (self->pv->connection, self->pv->prompter_bus_name, GCR_DBUS_PROMPTER_OBJECT_PATH, @@ -1186,7 +1184,7 @@ perform_prompt_async (GcrSystemPrompt *self, return; } - _gcr_debug ("prompting for password"); + g_debug ("prompting for password"); exchange = gcr_system_prompt_get_secret_exchange (self); if (self->pv->received) @@ -1395,9 +1393,9 @@ gcr_system_prompt_open_for_prompter_async (const gchar *prompter_name, g_return_if_fail (cancellable == NULL || G_CANCELLABLE (cancellable)); if (prompter_name == NULL) - _gcr_debug ("opening prompt"); + g_debug ("opening prompt"); else - _gcr_debug ("opening prompt for prompter: %s", prompter_name); + g_debug ("opening prompt for prompter: %s", prompter_name); g_async_initable_new_async (GCR_TYPE_SYSTEM_PROMPT, G_PRIORITY_DEFAULT, @@ -1504,9 +1502,9 @@ gcr_system_prompt_open_for_prompter (const gchar *prompter_name, g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (prompter_name == NULL) - _gcr_debug ("opening prompt"); + g_debug ("opening prompt"); else - _gcr_debug ("opening prompt for prompter: %s", prompter_name); + g_debug ("opening prompt for prompter: %s", prompter_name); return g_initable_new (GCR_TYPE_SYSTEM_PROMPT, cancellable, error, "timeout-seconds", timeout_seconds, diff --git a/gcr/gcr-system-prompter.c b/gcr/gcr-system-prompter.c index 654c686..cdbc867 100644 --- a/gcr/gcr-system-prompter.c +++ b/gcr/gcr-system-prompter.c @@ -22,8 +22,6 @@ #include "config.h" #include "gcr-dbus-constants.h" -#define DEBUG_FLAG GCR_DEBUG_PROMPT -#include "gcr-debug.h" #include "gcr-internal.h" #include "gcr-library.h" #include "gcr-prompt.h" @@ -315,7 +313,7 @@ gcr_system_prompter_dispose (GObject *obj) { GcrSystemPrompter *self = GCR_SYSTEM_PROMPTER (obj); - _gcr_debug ("disposing prompter"); + g_debug ("disposing prompter"); if (self->pv->prompter_registered) gcr_system_prompter_unregister (self, FALSE); @@ -332,7 +330,7 @@ gcr_system_prompter_finalize (GObject *obj) { GcrSystemPrompter *self = GCR_SYSTEM_PROMPTER (obj); - _gcr_debug ("finalizing prompter"); + g_debug ("finalizing prompter"); g_assert (self->pv->connection == NULL); g_assert (self->pv->prompter_registered == 0); @@ -348,7 +346,7 @@ gcr_system_prompter_new_prompt (GcrSystemPrompter *self) { g_return_val_if_fail (self->pv->prompt_type != 0, NULL); - _gcr_debug ("creating new %s prompt", g_type_name (self->pv->prompt_type)); + g_debug ("creating new %s prompt", g_type_name (self->pv->prompt_type)); return g_object_new (self->pv->prompt_type, NULL); } @@ -494,14 +492,14 @@ prompt_stop_prompting (GcrSystemPrompter *self, GVariant *retval; gpointer watch; - _gcr_debug ("stopping prompting for operation %s@%s", - callback->path, callback->name); + g_debug ("stopping prompting for operation %s@%s", + callback->path, callback->name); /* Get a pointer to our actual callback */ if (!g_hash_table_lookup_extended (self->pv->callbacks, callback, (gpointer *)&callback, &watch)) { - _gcr_debug ("couldn't find the callback for prompting operation %s@%s", - callback->path, callback->name); + g_debug ("couldn't find the callback for prompting operation %s@%s", + callback->path, callback->name); return; } @@ -523,12 +521,12 @@ prompt_stop_prompting (GcrSystemPrompter *self, g_hash_table_remove (self->pv->active, callback); if (!active->ready) { - _gcr_debug ("cancelling active prompting operation for %s@%s", - callback->path, callback->name); + g_debug ("cancelling active prompting operation for %s@%s", + callback->path, callback->name); g_cancellable_cancel (active->cancellable); } - _gcr_debug ("closing the prompt"); + g_debug ("closing the prompt"); gcr_prompt_close (active->prompt); g_object_run_dispose (G_OBJECT (active->prompt)); active_prompt_unref (active); @@ -536,8 +534,8 @@ prompt_stop_prompting (GcrSystemPrompter *self, /* Notify the caller */ if (send_done_message && wait_for_reply) { - _gcr_debug ("calling the %s on %s@%s, and waiting for reply", - GCR_DBUS_CALLBACK_METHOD_DONE, callback->path, callback->name); + g_debug ("calling the %s on %s@%s, and waiting for reply", + GCR_DBUS_CALLBACK_METHOD_DONE, callback->path, callback->name); retval = g_dbus_connection_call_sync (self->pv->connection, callback->name, @@ -551,12 +549,12 @@ prompt_stop_prompting (GcrSystemPrompter *self, if (retval) g_variant_unref (retval); - _gcr_debug ("returned from %s on %s@%s", - GCR_DBUS_CALLBACK_METHOD_DONE, callback->path, callback->name); + g_debug ("returned from %s on %s@%s", + GCR_DBUS_CALLBACK_METHOD_DONE, callback->path, callback->name); } else if (send_done_message) { - _gcr_debug ("calling the %s on %s@%s, and ignoring reply", - GCR_DBUS_CALLBACK_METHOD_DONE, callback->path, callback->name); + g_debug ("calling the %s on %s@%s, and ignoring reply", + GCR_DBUS_CALLBACK_METHOD_DONE, callback->path, callback->name); g_dbus_connection_call (self->pv->connection, callback->name, @@ -592,8 +590,8 @@ on_prompt_ready_complete (GObject *source, g_assert (active->ready == FALSE); - _gcr_debug ("returned from the %s method on %s@%s", - GCR_DBUS_CALLBACK_METHOD_READY, active->callback->path, active->callback->name); + g_debug ("returned from the %s method on %s@%s", + GCR_DBUS_CALLBACK_METHOD_READY, active->callback->path, active->callback->name); active->ready = TRUE; retval = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), result, &error); @@ -606,8 +604,8 @@ on_prompt_ready_complete (GObject *source, /* The ready call failed, */ } else if (error != NULL) { if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD)) - _gcr_debug ("prompt %s@%s disappeared or does not exist", - active->callback->path, active->callback->name); + g_debug ("prompt %s@%s disappeared or does not exist", + active->callback->path, active->callback->name); else g_message ("received an error from the prompt callback: %s", error->message); g_error_free (error); @@ -648,8 +646,8 @@ prompt_send_ready (ActivePrompt *active, self = active->prompter; builder = prompt_build_properties (active->prompt, active->changed); - _gcr_debug ("calling the %s method on %s@%s", - GCR_DBUS_CALLBACK_METHOD_READY, active->callback->path, active->callback->name); + g_debug ("calling the %s method on %s@%s", + GCR_DBUS_CALLBACK_METHOD_READY, active->callback->path, active->callback->name); g_dbus_connection_call (self->pv->connection, active->callback->name, @@ -681,8 +679,8 @@ prompt_next_ready (GcrSystemPrompter *self) if (callback == NULL) return; - _gcr_debug ("preparing a prompt for callback %s@%s", - callback->path, callback->name); + g_debug ("preparing a prompt for callback %s@%s", + callback->path, callback->name); active = g_hash_table_lookup (self->pv->active, callback); g_assert (active == NULL); @@ -754,8 +752,8 @@ on_caller_vanished (GDBusConnection *connection, } while ((callback = g_queue_pop_head (&queue)) != NULL) { - _gcr_debug ("caller vanished for callback %s@%s", - callback->path, callback->name); + g_debug ("caller vanished for callback %s@%s", + callback->path, callback->name); prompt_stop_prompting (self, callback, FALSE, FALSE); } } @@ -773,13 +771,13 @@ prompter_method_begin_prompting (GcrSystemPrompter *self, lookup.name = caller = g_dbus_method_invocation_get_sender (invocation); g_variant_get (parameters, "(&o)", &lookup.path); - _gcr_debug ("received %s call from callback %s@%s", - GCR_DBUS_PROMPTER_METHOD_BEGIN, - lookup.path, lookup.name); + g_debug ("received %s call from callback %s@%s", + GCR_DBUS_PROMPTER_METHOD_BEGIN, + lookup.path, lookup.name); if (g_hash_table_lookup (self->pv->callbacks, &lookup)) { - _gcr_debug ("already begun prompting for callback %s@%s", - lookup.path, lookup.name); + g_debug ("already begun prompting for callback %s@%s", + lookup.path, lookup.name); g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Already begun prompting for this prompt callback"); return; @@ -813,8 +811,8 @@ on_prompt_password (GObject *source, g_assert (active->ready == FALSE); g_assert (active->callback != NULL); - _gcr_debug ("completed password prompt for callback %s@%s", - active->callback->name, active->callback->path); + g_debug ("completed password prompt for callback %s@%s", + active->callback->name, active->callback->path); reply = gcr_prompt_password_finish (GCR_PROMPT (source), result, &error); if (error != NULL) { @@ -845,8 +843,8 @@ on_prompt_confirm (GObject *source, g_assert (active->ready == FALSE); g_assert (active->callback != NULL); - _gcr_debug ("completed confirm prompt for callback %s@%s", - active->callback->name, active->callback->path); + g_debug ("completed confirm prompt for callback %s@%s", + active->callback->name, active->callback->path); reply = gcr_prompt_confirm_finish (GCR_PROMPT (source), result, &error); if (error != NULL) { @@ -889,20 +887,20 @@ prompter_method_perform_prompt (GcrSystemPrompter *self, g_variant_get (parameters, "(&o&sa{sv}&s)", &lookup.path, &type, &iter, &received); - _gcr_debug ("received %s call from callback %s@%s", - GCR_DBUS_PROMPTER_METHOD_PERFORM, - lookup.path, lookup.name); + g_debug ("received %s call from callback %s@%s", + GCR_DBUS_PROMPTER_METHOD_PERFORM, + lookup.path, lookup.name); active = g_hash_table_lookup (self->pv->active, &lookup); if (active == NULL) { - _gcr_debug ("not begun prompting for this callback %s@%s", - lookup.path, lookup.name); + g_debug ("not begun prompting for this callback %s@%s", + lookup.path, lookup.name); error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Not begun prompting for this prompt callback"); } else if (!active->ready) { - _gcr_debug ("already performing prompt for this callback %s@%s", - lookup.path, lookup.name); + g_debug ("already performing prompt for this callback %s@%s", + lookup.path, lookup.name); error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Already performing a prompt for this prompt callback"); } @@ -919,8 +917,8 @@ prompter_method_perform_prompt (GcrSystemPrompter *self, exchange = active_prompt_get_secret_exchange (active); if (!gcr_secret_exchange_receive (exchange, received)) { - _gcr_debug ("received invalid secret exchange from callback %s@%s", - lookup.path, lookup.name); + g_debug ("received invalid secret exchange from callback %s@%s", + lookup.path, lookup.name); g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid secret exchange received"); return; @@ -930,21 +928,21 @@ prompter_method_perform_prompt (GcrSystemPrompter *self, if (g_strcmp0 (type, GCR_DBUS_PROMPT_TYPE_CONFIRM) == 0) { active->ready = FALSE; - _gcr_debug ("starting confirm prompt for callback %s@%s", - lookup.path, lookup.name); + g_debug ("starting confirm prompt for callback %s@%s", + lookup.path, lookup.name); gcr_prompt_confirm_async (active->prompt, active->cancellable, on_prompt_confirm, active_prompt_ref (active)); } else if (g_strcmp0 (type, GCR_DBUS_PROMPT_TYPE_PASSWORD) == 0) { active->ready = FALSE; - _gcr_debug ("starting password prompt for callback %s@%s", - lookup.path, lookup.name); + g_debug ("starting password prompt for callback %s@%s", + lookup.path, lookup.name); gcr_prompt_password_async (active->prompt, active->cancellable, on_prompt_password, active_prompt_ref (active)); } else { - _gcr_debug ("invalid type of prompt from callback %s@%s", - lookup.path, lookup.name); + g_debug ("invalid type of prompt from callback %s@%s", + lookup.path, lookup.name); g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid type argument"); return; @@ -963,9 +961,9 @@ prompter_method_stop_prompting (GcrSystemPrompter *self, lookup.name = g_dbus_method_invocation_get_sender (invocation); g_variant_get (parameters, "(&o)", &lookup.path); - _gcr_debug ("received %s call from callback %s@%s", - GCR_DBUS_PROMPTER_METHOD_PERFORM, - lookup.path, lookup.name); + g_debug ("received %s call from callback %s@%s", + GCR_DBUS_PROMPTER_METHOD_PERFORM, + lookup.path, lookup.name); prompt_stop_prompting (self, &lookup, TRUE, FALSE); @@ -1029,7 +1027,7 @@ gcr_system_prompter_register (GcrSystemPrompter *self, g_return_if_fail (self->pv->prompter_registered == 0); g_return_if_fail (self->pv->connection == NULL); - _gcr_debug ("registering prompter"); + g_debug ("registering prompter"); self->pv->connection = g_object_ref (connection); @@ -1066,7 +1064,7 @@ gcr_system_prompter_unregister (GcrSystemPrompter *self, g_return_if_fail (GCR_IS_SYSTEM_PROMPTER (self)); g_return_if_fail (self->pv->prompter_registered != 0); - _gcr_debug ("unregistering prompter"); + g_debug ("unregistering prompter"); callbacks = g_hash_table_get_keys (self->pv->callbacks); for (l = callbacks; l != NULL; l = g_list_next (l)) diff --git a/gcr/gcr-trust.c b/gcr/gcr-trust.c index bc96428..71f5e22 100644 --- a/gcr/gcr-trust.c +++ b/gcr/gcr-trust.c @@ -21,8 +21,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_TRUST -#include "gcr-debug.h" #include "gcr-types.h" #include "gcr-internal.h" #include "gcr-library.h" @@ -158,8 +156,8 @@ perform_is_certificate_pinned (GckAttributes *search, return FALSE; slots = gcr_pkcs11_get_trust_lookup_slots (); - _gcr_debug ("searching for pinned certificate in %d slots", - g_list_length (slots)); + g_debug ("searching for pinned certificate in %d slots", + g_list_length (slots)); en = gck_slots_enumerate_objects (slots, search, 0); gck_list_unref_free (slots); @@ -169,7 +167,7 @@ perform_is_certificate_pinned (GckAttributes *search, if (object) g_object_unref (object); - _gcr_debug ("%s certificate anchor", object ? "found" : "did not find"); + g_debug ("%s certificate anchor", object ? "found" : "did not find"); return (object != NULL); } @@ -725,8 +723,8 @@ perform_is_certificate_anchored (GckAttributes *attrs, return FALSE; slots = gcr_pkcs11_get_trust_lookup_slots (); - _gcr_debug ("searching for certificate anchor in %d slots", - g_list_length (slots)); + g_debug ("searching for certificate anchor in %d slots", + g_list_length (slots)); en = gck_slots_enumerate_objects (slots, attrs, 0); gck_list_unref_free (slots); @@ -736,7 +734,7 @@ perform_is_certificate_anchored (GckAttributes *attrs, if (object != NULL) g_object_unref (object); - _gcr_debug ("%s certificate anchor", object ? "found" : "did not find"); + g_debug ("%s certificate anchor", object ? "found" : "did not find"); return (object != NULL); } diff --git a/ui/gcr-prompt-dialog.c b/ui/gcr-prompt-dialog.c index 839d701..48088d7 100644 --- a/ui/gcr-prompt-dialog.c +++ b/ui/gcr-prompt-dialog.c @@ -21,8 +21,6 @@ #include "config.h" -#define DEBUG_FLAG GCR_DEBUG_PROMPT -#include "gcr/gcr-debug.h" #include "gcr/gcr-prompt.h" #include "gcr-prompt-dialog.h" diff --git a/ui/gcr-prompter-tool.c b/ui/gcr-prompter-tool.c index f0cb0e8..0a22238 100644 --- a/ui/gcr-prompter-tool.c +++ b/ui/gcr-prompter-tool.c @@ -24,8 +24,6 @@ #include "gcr/gcr.h" #include "gcr/gcr-dbus-constants.h" -#define DEBUG_FLAG GCR_DEBUG_PROMPT -#include "gcr/gcr-debug.h" #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -48,7 +46,7 @@ static guint timeout_source = 0; static gboolean on_timeout_quit (gpointer unused) { - _gcr_debug ("%d second inactivity timeout, quitting", QUIT_TIMEOUT); + g_debug ("%d second inactivity timeout, quitting", QUIT_TIMEOUT); gtk_main_quit (); return FALSE; /* Don't run again */ @@ -88,7 +86,7 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { - _gcr_debug ("bus acquired: %s", name); + g_debug ("bus acquired: %s", name); if (!registered_prompter) gcr_system_prompter_register (the_prompter, connection); @@ -101,7 +99,7 @@ on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { - _gcr_debug ("acquired name: %s", name); + g_debug ("acquired name: %s", name); if (g_strcmp0 (name, GCR_DBUS_PROMPTER_SYSTEM_BUS_NAME) == 0) acquired_system_prompter = TRUE; @@ -115,7 +113,7 @@ on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { - _gcr_debug ("lost name: %s", name); + g_debug ("lost name: %s", name); /* Called like so when no connection can be made */ if (connection == NULL) { |