summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac8
-rw-r--r--libtac.pc.in2
-rw-r--r--libtac/include/libtac.h10
-rw-r--r--libtac/lib/authen_r.c2
-rw-r--r--tacc.c15
6 files changed, 32 insertions, 9 deletions
diff --git a/Makefile.am b/Makefile.am
index 93f5b97..7e09e98 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@ if TACC
bin_PROGRAMS = tacc
tacc_SOURCES = tacc.c
tacc_LDADD = libtac.la
-tacc_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/libtac/include
+tacc_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/libtac/include @rt_debug_defines@
endif
libtac_includedir = $(includedir)/libtac
@@ -51,7 +51,7 @@ libtac_la_SOURCES += \
libtac/lib/md5.c \
libtac/lib/md5.h
endif
-libtac_la_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/libtac/include
+libtac_la_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/libtac/include @rt_debug_defines@
libtac_la_LDFLAGS = -version-info 2:0:0 -shared
moduledir = @pamdir@
diff --git a/configure.ac b/configure.ac
index 7b84344..e34c769 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,6 +94,14 @@ AC_ARG_ENABLE(doc, AS_HELP_STRING([--disable-doc], [do not build docs]))
AM_CONDITIONAL(DOC, test "x$enable_doc" != "xno")
dnl --------------------------------------------------------------------
+dnl Switch for run-time debugging
+AC_ARG_ENABLE(runtime-debugging, [AS_HELP_STRING([--enable-runtime-debugging],
+ [Build with run-time debugging])],
+ [rt_debug_defines="-DTACDEBUG_AT_RUNTIME=1"])
+AC_SUBST(rt_debug_defines)
+AM_SUBST_NOTMAKE(rt_debug_defines)
+
+dnl --------------------------------------------------------------------
dnl Generate made files
AC_CONFIG_FILES([Makefile
libtac.pc
diff --git a/libtac.pc.in b/libtac.pc.in
index d538e9f..fc60daf 100644
--- a/libtac.pc.in
+++ b/libtac.pc.in
@@ -8,4 +8,4 @@ Description: A TACACS+ protocol client implementation
URL: https://github.com/jeroennijhof/pam_tacplus
Version: @VERSION@
Libs: -L${libdir} -ltac
-Cflags: -I${includedir}
+Cflags: -I${includedir} @rt_debug_defines@
diff --git a/libtac/include/libtac.h b/libtac/include/libtac.h
index daff851..c872ff7 100644
--- a/libtac/include/libtac.h
+++ b/libtac/include/libtac.h
@@ -64,13 +64,13 @@ extern "C" {
#undef TACDEBUG
#undef TACSYSLOG
# ifdef __GNUC__
-#define TACDEBUG(level, fmt, ...) do { if (tac_debug_enable) (void)logmsg(level, fmt, ## __VA_ARGS__); } while (0)
-#define TACSYSLOG(level, fmt, ...) (void)logmsg(level, fmt, ## __VA_ARGS__)
+#define TACDEBUG(level, fmt, ...) do { if (tac_debug_enable) logmsg(level, fmt, ## __VA_ARGS__); } while (0)
+#define TACSYSLOG(level, fmt, ...) logmsg(level, fmt, ## __VA_ARGS__)
# else
-#define TACDEBUG(level, fmt, ...) do { if (tac_debug_enable) (void)logmsg(level, fmt, __VA_ARGS__); } while (0)
-#define TACSYSLOG(level, fmt, ...) (void)logmsg(level, fmt, __VA_ARGS__)
+#define TACDEBUG(level, fmt, ...) do { if (tac_debug_enable) logmsg(level, fmt, __VA_ARGS__); } while (0)
+#define TACSYSLOG(level, fmt, ...) logmsg(level, fmt, __VA_ARGS__)
# endif
-extern int logmsg __P((int, const char*, ...));
+extern void logmsg __P((int, const char*, ...));
#endif
/* u_int32_t support for sun */
diff --git a/libtac/lib/authen_r.c b/libtac/lib/authen_r.c
index ffc396c..e89faa6 100644
--- a/libtac/lib/authen_r.c
+++ b/libtac/lib/authen_r.c
@@ -161,7 +161,7 @@ int tac_authen_read(int fd, struct areply *re) {
}
TACDEBUG(LOG_DEBUG, "%s: authentication failed, server reply status=%d",
- __FUNCTION__, r);
+ __FUNCTION__, re->status);
free(tb);
return re->status;
diff --git a/tacc.c b/tacc.c
index dc741e7..8069323 100644
--- a/tacc.c
+++ b/tacc.c
@@ -28,6 +28,7 @@
#include <getopt.h>
#include <ctype.h>
#include <openssl/rand.h>
+#include <stdarg.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -569,3 +570,17 @@ void timeout_handler(int signum) {
syslog(LOG_ERR, "timeout reading password from user %s", user);
}
+
+#ifdef TACDEBUG_AT_RUNTIME
+void logmsg(int level, const char *fmt, ...)
+{
+ va_list ap;
+
+ level = level; /* unused */
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+}
+#endif