add functionality to enable debugging flags at runtime
This code permit to set flags, separated by commas, space, tabulations, or colons. This flags activates debug functions like, suppressing validations of signatures or print debugging message about deallocations. The new flags are defined in /lasso/debug.h they can be set using an environment variable named LASSO_FLAG or a function named lasso_set_flag. There are two flags currently: - verify-signature: To deactivate it, pass 'no-verify-signature' inside LASSO_DEBUG. It desactivate signature verification, inside two functions: lasso_query_verify_signature and lasso_provider_verify_signature. - memory-debug: It enabled reporting of memory deallocation inside generic memory dellaocator for LassoNode objects and also in bindings. - lasso/xml/xml.c: do not free a null hash table pointer.
This commit is contained in:
parent
7290225b00
commit
ef42f2cbc8
|
@ -41,9 +41,7 @@ com_entrouvert_lasso_LassoJNI.h: com/entrouvert/lasso/LassoJNI.class $(java_las
|
|||
$(JAVAH) $(JAVAH_FLAGS) -classpath . `echo $< | sed 'su/u.ug;su.classuu'`
|
||||
|
||||
libjnilasso_la_CFLAGS = -fno-strict-aliasing $(LASSO_CORE_CFLAGS) -I$(top_srcdir) -I$(top_builddir) $(AM_CFLAGS) @JAVA_INCLUDE@
|
||||
if DEBUGGING
|
||||
libjnilasso_la_CFLAGS += -Wno-unused-parameter
|
||||
endif
|
||||
|
||||
libjnilasso_la_LDFLAGS = -export-dynamic -prefer-pic -module -avoid-version
|
||||
libjnilasso_la_LIBADD = $(top_builddir)/lasso/liblasso.la $(LASSO_LIBS)
|
||||
|
|
|
@ -16,9 +16,7 @@ php_configdir=@PHP5_CONFIG_DIR@
|
|||
php_config_DATA = lasso.ini
|
||||
|
||||
lasso_la_CFLAGS = -fno-strict-aliasing $(LASSO_CORE_CFLAGS) -I$(top_srcdir) -I$(top_builddir) $(PHP5_INCLUDES) $(AM_CFLAGS)
|
||||
if DEBUGGING
|
||||
lasso_la_CFLAGS += -Wno-unused-parameter
|
||||
endif
|
||||
lasso_la_LDFLAGS = -export-dynamic -prefer-pic -module -avoid-version
|
||||
lasso_la_LIBADD = $(top_builddir)/lasso/liblasso.la $(LASSO_LIBS) $(PHP5_LDFLAGS)
|
||||
nodist_lasso_la_SOURCES = _lasso.c
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <lasso/lasso.h>
|
||||
#include <config.h>
|
||||
#include "../ghashtable.h"
|
||||
#include "../../lasso/debug.h"
|
||||
|
||||
GQuark lasso_wrapper_key;
|
||||
|
||||
|
@ -375,12 +376,12 @@ failure:
|
|||
static void
|
||||
PyGObjectPtr_dealloc(PyGObjectPtr *self)
|
||||
{
|
||||
#ifdef LASSO_DEBUG
|
||||
fprintf(stderr, "dealloc (%p ptr to %p (type:%s, rc:%d))\n",
|
||||
self, self->obj,
|
||||
G_OBJECT_TYPE_NAME(self->obj),
|
||||
self->obj->ref_count);
|
||||
#endif
|
||||
if (lasso_flag_memory_debug) {
|
||||
fprintf(stderr, "dealloc (%p ptr to %p (type:%s, rc:%d))\n",
|
||||
self, self->obj,
|
||||
G_OBJECT_TYPE_NAME(self->obj),
|
||||
self->obj->ref_count);
|
||||
}
|
||||
g_object_set_qdata_full(self->obj, lasso_wrapper_key, NULL, NULL);
|
||||
g_object_unref(self->obj);
|
||||
Py_XDECREF(self->typename);
|
||||
|
|
|
@ -84,6 +84,7 @@ dnl Check for programs
|
|||
dnl
|
||||
AC_PROG_CC
|
||||
CFLAGS=""
|
||||
AM_CFLAGS="-Wall -Wextra -Werror -Wno-missing-field-initializers"
|
||||
AC_HEADER_STDC
|
||||
LT_AC_PROG_RC
|
||||
AC_EXEEXT
|
||||
|
@ -835,14 +836,14 @@ AM_CONDITIONAL(HAVE_INKSCAPE, test -n "$ac_cv_prog_INKSCAPE")
|
|||
|
||||
dnl Debug
|
||||
AC_MSG_CHECKING(for debugging)
|
||||
AC_ARG_ENABLE(debugging, [ --enable-debugging enable debuging messages (no)])
|
||||
AC_ARG_ENABLE(debugging, [ --enable-debugging enable debuging optimization flags (no)])
|
||||
if test "z$enable_debugging" = "zyes" ; then
|
||||
enable_debugging=yes
|
||||
LASSO_DEFINES="$LASSO_DEFINES -DLASSO_DEBUG"
|
||||
AM_CFLAGS="$AM_CFLAGS -O0 -g -Wall -Wextra -Werror -Wno-missing-field-initializers"
|
||||
AM_CFLAGS="$AM_CFLAGS -O0 -g"
|
||||
else
|
||||
enable_debugging=no
|
||||
AM_CFLAGS="$AM_CFLAGS -O2"
|
||||
AM_CFLAGS="$AM_CFLAGS -O2 -g"
|
||||
fi
|
||||
AM_CONDITIONAL([DEBUGGING],[test "x$enable_debugging" = "xyes"])
|
||||
AC_MSG_RESULT($enable_debugging)
|
||||
|
@ -853,7 +854,7 @@ dnl Profiling
|
|||
AC_MSG_CHECKING(for profiling)
|
||||
AC_ARG_ENABLE(profiling, [ --enable-profiling enable profiling compilation flags (no)])
|
||||
if test "z$enable_profiling" = "zyes" ; then
|
||||
CFLAGS="$CFLAGS -pg"
|
||||
AM_CFLAGS="$AM_CFLAGS -pg"
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/* $Id$
|
||||
*
|
||||
* Lasso - A free implementation of the Liberty Alliance specifications.
|
||||
*
|
||||
* Copyright (C) 2004-2007 Entr'ouvert
|
||||
* http://lasso.entrouvert.org
|
||||
*
|
||||
* Authors: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __LASSO_DEBUG_H__
|
||||
#define __LASSO__DEBUGH__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
LASSO_EXPORT extern gboolean lasso_flag_verify_signature;
|
||||
LASSO_EXPORT extern gboolean lasso_flag_memory_debug;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __LASSO_DEBUG_H__ */
|
|
@ -14,7 +14,7 @@ if len(sys.argv) == 2+enable_wsf:
|
|||
else:
|
||||
srcdir = '.'
|
||||
|
||||
regex = re.compile('LASSO_EXPORT.*(lasso_[a-zA-Z0-9_]+).*\(')
|
||||
regex = re.compile('LASSO_EXPORT.*(lasso_[a-zA-Z0-9_]+)[ \t]*[\(;]')
|
||||
|
||||
symbols = []
|
||||
for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*.h' % srcdir) + \
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include <lasso/saml-2.0/providerprivate.h>
|
||||
#include "../utils.h"
|
||||
#include "../debug.h"
|
||||
|
||||
static char *protocol_uris[] = {
|
||||
"http://projectliberty.org/profiles/fedterm",
|
||||
|
@ -1071,6 +1072,9 @@ lasso_provider_verify_signature(LassoProvider *provider,
|
|||
|
||||
g_return_val_if_fail(LASSO_IS_PROVIDER(provider), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
|
||||
|
||||
if (lasso_flag_verify_signature == FALSE)
|
||||
return 0;
|
||||
|
||||
msg = (char*)message;
|
||||
if (message == NULL)
|
||||
return LASSO_PROFILE_ERROR_INVALID_MSG;
|
||||
|
|
|
@ -28,11 +28,24 @@
|
|||
*
|
||||
**/
|
||||
|
||||
#include <stdlib.h> /* getenv */
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/crypto.h>
|
||||
#include <libxslt/xslt.h>
|
||||
#include <config.h>
|
||||
#include "lasso.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* Set to true, it forces lasso_provider_verify_signature and lasso_query_verify_signature to always
|
||||
* return TRUE. */
|
||||
gboolean lasso_flag_verify_signature = TRUE;
|
||||
/* Set to true, it activates debugging code for LassoNode freeing */
|
||||
gboolean lasso_flag_memory_debug = FALSE;
|
||||
static void lasso_flag_parse_environment_variable();
|
||||
|
||||
#ifndef LASSO_FLAG_ENV_VAR
|
||||
#define LASSO_FLAG_ENV_VAR "LASSO_FLAG"
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER
|
||||
HINSTANCE g_hModule = NULL;
|
||||
|
@ -116,6 +129,7 @@ int lasso_init()
|
|||
message(G_LOG_LEVEL_CRITICAL, "xmlsec-crypto initialization failed.");
|
||||
return LASSO_ERROR_UNDEFINED;
|
||||
}
|
||||
lasso_flag_parse_environment_variable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -143,10 +157,10 @@ int lasso_shutdown()
|
|||
#endif /* XMLSEC_NO_XSLT */
|
||||
/* Cleanup function for the XML library */
|
||||
xmlCleanupParser();
|
||||
#ifdef LASSO_DEBUG
|
||||
if (lasso_flag_memory_debug == TRUE) {
|
||||
/* this is to debug memory for regression tests */
|
||||
xmlMemoryDump();
|
||||
#endif
|
||||
xmlMemoryDump();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -206,3 +220,53 @@ lasso_check_version(int major, int minor, int subminor, LassoCheckVersionMode mo
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* lasso_set_flag:
|
||||
* @flag: a string representing a flag name, prefix with 'no-' to disable it.
|
||||
*
|
||||
* Set a debugging flag. You can also use the environment variable named by the #LASSO_FLAG_ENV_VAR
|
||||
* macro to get the same effect. LASSO_DEBUG must contain flag name separated by spaces, commas,
|
||||
* tabulations or colons.
|
||||
*/
|
||||
void lasso_set_flag(char *flag) {
|
||||
gboolean value = TRUE;
|
||||
|
||||
g_return_if_fail(flag);
|
||||
|
||||
/* Handle negative flags */
|
||||
if (flag && strncmp(flag, "no-", 3) == 0) {
|
||||
value = FALSE;
|
||||
flag += 3;
|
||||
}
|
||||
|
||||
do {
|
||||
if (g_strcmp0(flag, "verify-signature") == 0) {
|
||||
lasso_flag_verify_signature = value;
|
||||
continue;
|
||||
}
|
||||
if (g_strcmp0(flag,"memory-debug") == 0) {
|
||||
lasso_flag_memory_debug = value;
|
||||
continue;
|
||||
}
|
||||
} while (FALSE);
|
||||
}
|
||||
|
||||
static void lasso_flag_parse_environment_variable() {
|
||||
char *lasso_flag = getenv(LASSO_FLAG_ENV_VAR);
|
||||
char *save_ptr;
|
||||
char *token;
|
||||
const char delim[] = ", \t:";
|
||||
|
||||
if (lasso_flag) {
|
||||
token = strtok_r(lasso_flag, delim, &save_ptr);
|
||||
do {
|
||||
lasso_set_flag(token);
|
||||
} while ((token = strtok_r(NULL, delim, &save_ptr)) != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ typedef enum {
|
|||
LASSO_EXPORT int lasso_check_version(
|
||||
int major, int minor, int subminor, LassoCheckVersionMode mode);
|
||||
|
||||
LASSO_EXPORT void lasso_set_flag(char *flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <lasso/xml/xml.h>
|
||||
#include <lasso/xml/xml_enc.h>
|
||||
#include <lasso/xml/saml-2.0/saml2_assertion.h>
|
||||
#include "../debug.h"
|
||||
|
||||
LassoNode* lasso_assertion_encrypt(LassoSaml2Assertion *assertion);
|
||||
static xmlSecKeyPtr lasso_get_public_key_from_private_key_file(const char *private_key_file);
|
||||
|
@ -536,6 +537,11 @@ lasso_query_verify_signature(const char *query, const xmlSecKey *sender_public_k
|
|||
char *sig_alg, *usig_alg = NULL;
|
||||
|
||||
g_return_val_if_fail(query != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
|
||||
|
||||
if (lasso_flag_verify_signature == FALSE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_return_val_if_fail(sender_public_key != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
|
||||
g_return_val_if_fail(sender_public_key->value != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <lasso/xml/saml_name_identifier.h>
|
||||
#include "../utils.h"
|
||||
#include "../registry.h"
|
||||
#include "../debug.h"
|
||||
|
||||
|
||||
static char* lasso_node_build_query(LassoNode *node);
|
||||
|
@ -1278,9 +1279,9 @@ lasso_node_dispose(GObject *object)
|
|||
SnippetType type;
|
||||
GList *elem;
|
||||
|
||||
#ifdef LASSO_DEBUG
|
||||
fprintf(stderr, "dispose of %s (at %p)\n", G_OBJECT_TYPE_NAME(object), object);
|
||||
#endif
|
||||
if (lasso_flag_memory_debug == TRUE) {
|
||||
fprintf(stderr, "dispose of %s (at %p)\n", G_OBJECT_TYPE_NAME(object), object);
|
||||
}
|
||||
|
||||
class = LASSO_NODE_GET_CLASS(object);
|
||||
while (class && LASSO_IS_NODE_CLASS(class) && class->node_data) {
|
||||
|
@ -1296,10 +1297,10 @@ lasso_node_dispose(GObject *object)
|
|||
if (*value == NULL)
|
||||
continue;
|
||||
|
||||
#ifdef LASSO_DEBUG
|
||||
fprintf(stderr, " freeing %s/%s (at %p)\n",
|
||||
G_OBJECT_TYPE_NAME(object), snippet->name, *value);
|
||||
#endif
|
||||
if (lasso_flag_memory_debug == TRUE) {
|
||||
fprintf(stderr, " freeing %s/%s (at %p)\n",
|
||||
G_OBJECT_TYPE_NAME(object), snippet->name, *value);
|
||||
}
|
||||
switch (type) {
|
||||
case SNIPPET_NODE:
|
||||
case SNIPPET_NAME_IDENTIFIER:
|
||||
|
@ -1331,7 +1332,9 @@ lasso_node_dispose(GObject *object)
|
|||
case SNIPPET_TEXT_CHILD:
|
||||
case SNIPPET_ATTRIBUTE: {
|
||||
if (snippet->type & SNIPPET_ANY) {
|
||||
g_hash_table_destroy(*value);
|
||||
if (*value) {
|
||||
g_hash_table_destroy(*value);
|
||||
}
|
||||
} else {
|
||||
g_free(*value);
|
||||
}
|
||||
|
|
|
@ -25,9 +25,7 @@ $(PERL_MAKEFILE): lasso.pm lasso_wrap.c
|
|||
test -e lasso.pm || test ! -e $(srcdir)/lasso.pm || $(LN_S) $(srcdir)/lasso.pm .
|
||||
VERSION="$(VERSION)" CC="$(CC)" CFLAGS="$(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(SWIG_OPTS) $(CPPFLAGS) $(AM_STANDARD_CFLAGS)" $(PERL) $(srcdir)/Makefile.PL DESTDIR="$(DESTDIR)" PREFIX="$(prefix)" $(MAKE_PL_OPTS) TOP_SRCDIR="$(top_srcdir)" TOP_BUILDDIR="$(top_builddir)"
|
||||
|
||||
if DEBUGGING
|
||||
AM_CFLAGS+=-Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -Wno-deprecated-declarations
|
||||
endif
|
||||
|
||||
-perl install-perl: $(PERL_MAKEFILE)
|
||||
target=`echo $@ | sed -e 's/-perl//'`; \
|
||||
|
|
Loading…
Reference in New Issue