From 54a0aee65b3d8129a55ece62ab8540f1cac3e929 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 22 Jan 2024 21:17:35 +0100 Subject: libpam_internal: supply debug functionality Move function bodies from headers into dedicated object files stored in libpam_internal. This library won't be installed. Keep the debug function body in header, even though disabled when building Linux-PAM, to stay API compatible with previous versions. Signed-off-by: Tobias Stoeckmann --- libpam/Makefile.am | 4 +++- libpam/include/security/_pam_macros.h | 22 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'libpam') diff --git a/libpam/Makefile.am b/libpam/Makefile.am index 5ed045a6..e3f4a3bc 100644 --- a/libpam/Makefile.am +++ b/libpam/Makefile.am @@ -23,7 +23,9 @@ noinst_HEADERS = pam_prelude.h pam_private.h pam_tokens.h \ include/test_assert.h libpam_la_LDFLAGS = -no-undefined -version-info 85:1:85 -libpam_la_LIBADD = @LIBAUDIT@ $(LIBPRELUDE_LIBS) $(ECONF_LIBS) @LIBDL@ @LTLIBINTL@ +libpam_la_LIBADD = $(top_builddir)/libpam_internal/libpam_internal.la \ + @LIBAUDIT@ $(LIBPRELUDE_LIBS) $(ECONF_LIBS) @LIBDL@ \ + @LTLIBINTL@ if HAVE_VERSIONING libpam_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libpam.map diff --git a/libpam/include/security/_pam_macros.h b/libpam/include/security/_pam_macros.h index 01274428..cd42bf72 100644 --- a/libpam/include/security/_pam_macros.h +++ b/libpam/include/security/_pam_macros.h @@ -94,11 +94,25 @@ do { \ #define _PAM_LOGFILE "/var/run/pam-debug.log" #endif +#ifdef PAM_NO_HEADER_FUNCTIONS +UNUSED +extern void _pam_output_debug_info(const char *file, const char *fn + , const int line); +UNUSED +PAM_FORMAT((printf, 1, 2)) +extern void _pam_output_debug(const char *format, ...); +#else +#ifdef PAM_DEBUG_C +#define PAM_DEBUG_SCOPE +#else +#define PAM_DEBUG_SCOPE static +#endif + #ifdef UNUSED UNUSED #endif -static void _pam_output_debug_info(const char *file, const char *fn - , const int line) +PAM_DEBUG_SCOPE void _pam_output_debug_info(const char *file, const char *fn + , const int line) { FILE *logfile; int must_close = 1, fd; @@ -127,7 +141,7 @@ static void _pam_output_debug_info(const char *file, const char *fn UNUSED #endif PAM_FORMAT((printf, 1, 2)) -static void _pam_output_debug(const char *format, ...) +PAM_DEBUG_SCOPE void _pam_output_debug(const char *format, ...) { va_list args; FILE *logfile; @@ -157,6 +171,8 @@ static void _pam_output_debug(const char *format, ...) va_end(args); } +#undef PAM_DEBUG_SCOPE +#endif #define D(x) do { \ _pam_output_debug_info(__FILE__, __FUNCTION__, __LINE__); \ -- cgit v1.2.3