From 3bdc20181a2b3f0ae2f5f7bc9b451c405137b5f5 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Thu, 30 Aug 2007 19:05:11 -0400 Subject: [PATCH] The default pinentry path can be specified by passing --with-pinentry-path=PATH to configure. Added --enable-mem-debug. This disables use of the custom memory allocators. I can't get Valgrind to work properly with the custom (de)allocators. --- Makefile.am | 15 +++++++++++---- configure.ac | 25 ++++++++++++++++++++++++- libpwmd.3.in | 5 +++++ libpwmd.c | 10 +++++++++- pwmc.c | 8 ++++++++ 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index e8a8ff51..f2431cdc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,17 +2,24 @@ EXTRA_DIST = TODO ChangeLog ChangeLog.old INSTALL KnownBugs NEWS debian ABOUT-NL dist_man3_MANS = libpwmd.3 lib_LTLIBRARIES = libpwmd.la libpwmd_ladir = $(includedir) -libpwmd_la_SOURCES = libpwmd.c libpwmd.h mem.c mem.h types.h valgrind.h gettext.h +libpwmd_la_SOURCES = libpwmd.c libpwmd.h types.h valgrind.h gettext.h libpwmd_la_HEADERS = libpwmd.h libpwmd_la_LDFLAGS = -version-info 4:2:0 @LIBASSUAN_LIBS@ @GPG_ERROR_LIBS@ -libpwmd_la_CFLAGS = -DLOCALEDIR=\"@prefix@/share/locale\" @LIBASSUAN_CFLAGS@ @GPG_ERROR_CFLAGS@ +libpwmd_la_CFLAGS = -DLOCALEDIR=\"${prefix}/share/locale\" @LIBASSUAN_CFLAGS@ @GPG_ERROR_CFLAGS@ dist_man1_MANS = pwmc.1 bin_PROGRAMS = pwmc -pwmc_SOURCES = pwmc.c mem.c mem.h valgrind.h -pwmc_CFLAGS = -DLOCALEDIR=\"@prefix@/share/locale\" +pwmc_SOURCES = pwmc.c valgrind.h +pwmc_CFLAGS = -DLOCALEDIR=\"${prefix}/share/locale\" pwmc_LDADD= -lpwmd +if MEM_DEBUG +CPPFLAGS += -DMEM_DEBUG +else +libpwmd_la_SOURCES += mem.c mem.h +pwmc_SOURCES += mem.c mem.h +endif + install-data-hook: install -m 0755 -d $(DESTDIR)${libdir}/pkgconfig chmod u+w $(DESTDIR)${libdir}/pkgconfig diff --git a/configure.ac b/configure.ac index 7c7542d3..c3375b9f 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,22 @@ AC_FUNC_SELECT_ARGTYPES AC_CHECK_FUNCS([memmove select socket strdup strerror setlocale getcwd \ memset stpcpy strchr strrchr]) +AC_DEFUN([AC_MEM_DEBUG], +[ + if test "$1"; then + ac_cv_sys_mem_debug=$1 + fi + + AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug], + [ac_cv_sys_mem_debug=no]) + AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"]) +]) + +AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Enable memory debugging.]), + AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG) + +AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno) + AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], [Disable pinentry(1) support.]), USE_PINENTRY=no, USE_PINENTRY=$enableval) @@ -60,7 +76,14 @@ if test $USE_PINENTRY = "yes"; then fi AM_CONDITIONAL(USE_PINENTRY, [test $USE_PINENTRY = "yes"]) -AC_SUBST(prefix) +pinentry_path="/usr/bin/pinentry" + +AC_ARG_WITH(pinentry_path, AC_HELP_STRING([--with-pinentry-path=PATH], + [Default location of the pinentry binary (/usr/bin/pinentry)]), + pinentry_path="$withval") + +AC_SUBST(pinentry_path) +AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry_path"], [Default location of the pinentry binary.]) AC_CONFIG_FILES([Makefile libpwmd.pc libpwmd.3 po/Makefile.in]) AC_OUTPUT diff --git a/libpwmd.3.in b/libpwmd.3.in index 0fc5c761..e1d6439b 100644 --- a/libpwmd.3.in +++ b/libpwmd.3.in @@ -262,6 +262,11 @@ metadata file. .TP .B @prefix@/include/libpwmd.h Installed location of header file. +.TP +.B @pinentry_path@ +Default location of the +.BR pinentry (1) +binary. .SH AUTHOR Ben Kibbey diff --git a/libpwmd.c b/libpwmd.c index 71130212..e270bd1a 100644 --- a/libpwmd.c +++ b/libpwmd.c @@ -51,11 +51,19 @@ #include "gettext.h" #define N_(msgid) dgettext("libpwmd", msgid) +#ifndef MEM_DEBUG #include "mem.h" +#else +#define xfree free +#define xrealloc realloc +#define xmalloc malloc +#define xstrdup strdup +#define xcalloc calloc +#endif + #include "types.h" #ifdef USE_PINENTRY -#define PINENTRY_PATH "/usr/bin/pinentry" static pwm_t *gpwm; static int gelapsed, gtimeout; static gpg_error_t pinentry_command(pwm_t *pwm, char **result, const char *cmd); diff --git a/pwmc.c b/pwmc.c index b0fc0fec..6c5e7f48 100644 --- a/pwmc.c +++ b/pwmc.c @@ -33,7 +33,15 @@ #include "gettext.h" #define N_(msgid) gettext(msgid) +#ifndef MEM_DEBUG #include "mem.h" +#else +#define xfree free +#define xrealloc realloc +#define xmalloc malloc +#define xstrdup strdup +#define xcalloc calloc +#endif int timeout, elapsed; pwm_t *pwm; -- 2.11.4.GIT