[SCM] pam wrapper repository - branch master updated

Andreas Schneider asn at samba.org
Thu Apr 6 11:44:13 UTC 2017


The branch, master has been updated
       via  bb04070 Bump version to 1.0.3
       via  48c7b4e doc: Document PAM_WRAPPER_USE_SYSLOG variable
       via  9411daf pwrap: Do not log to syslog by default but use our logging
       via  22a4fbf pwrap: Do an early return in pwrap_vlog if log level doesn't match
       via  e7d8276 pwrap: Add pwrap_vlog() functions
       via  09fcd1e pwrap: Remove useless break
      from  91227b3 libpamtest: Do not declare variable in for-loop

https://git.samba.org/?p=pam_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit bb0407078c357cb0476e49b634faf4fd086f1d12
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 09:55:29 2017 +0200

    Bump version to 1.0.3
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 48c7b4e13450930cf479334e0ab6e432fca08a7e
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 11:51:32 2017 +0200

    doc: Document PAM_WRAPPER_USE_SYSLOG variable
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9411daf54d6f2492508fba10e08260779faf1cc9
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 11:47:37 2017 +0200

    pwrap: Do not log to syslog by default but use our logging
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 22a4fbf90a8c9b34b893bec2890c0590ddd4cb61
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 12:08:54 2017 +0200

    pwrap: Do an early return in pwrap_vlog if log level doesn't match
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit e7d8276736f7c45a3734060c5c7242f018bd9028
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 11:41:12 2017 +0200

    pwrap: Add pwrap_vlog() functions
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 09fcd1e8ea1e8e269b2a812dbbb22abafaf17708
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 09:56:15 2017 +0200

    pwrap: Remove useless break
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 CMakeLists.txt        |   2 +-
 ChangeLog             |   4 ++
 doc/pam_wrapper.1     |  13 ++++--
 doc/pam_wrapper.1.txt |   8 +++-
 src/pam_wrapper.c     | 123 ++++++++++++++++++++++++++++++++++----------------
 5 files changed, 106 insertions(+), 44 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0c950f..a929eb2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR "1")
 set(APPLICATION_VERSION_MINOR "0")
-set(APPLICATION_VERSION_PATCH "2")
+set(APPLICATION_VERSION_PATCH "3")
 
 set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
 
diff --git a/ChangeLog b/ChangeLog
index 5af21dd..c2be509 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 ChangeLog
 ==========
 
+version 1.0.3 (released 2017-04-06)
+  * Fixed some build issues with strict compiler flags
+  * Logging to syslog is disabled by default
+
 version 1.0.2 (released 2016-05-24)
   * Fixed pam_wrapper on some BSDs
   * Fixed simple conversation in libpamtest
diff --git a/doc/pam_wrapper.1 b/doc/pam_wrapper.1
index 0d737a9..3536c82 100644
--- a/doc/pam_wrapper.1
+++ b/doc/pam_wrapper.1
@@ -1,13 +1,13 @@
 '\" t
 .\"     Title: pam_wrapper
 .\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
-.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      Date: 2015-11-04
+.\" Generator: DocBook XSL Stylesheets v1.79.0 <http://docbook.sf.net/>
+.\"      Date: 2017-04-06
 .\"    Manual: \ \&
 .\"    Source: \ \&
 .\"  Language: English
 .\"
-.TH "PAM_WRAPPER" "1" "2015\-11\-04" "\ \&" "\ \&"
+.TH "PAM_WRAPPER" "1" "2017\-04\-06" "\ \&" "\ \&"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -100,6 +100,11 @@ If you need to see what is going on in pam_wrapper itself or try to find a bug,
 .RE
 .RE
 .PP
+\fBPAM_WRAPPER_USE_SYSLOG\fR
+.RS 4
+By default pam logs will go to the pam_wrapper DEBUG log level and will not be sent to the syslog\&. If you want to log to the syslog to you can set this variable to 1\&.
+.RE
+.PP
 \fBPAM_WRAPPER_KEEP_DIR\fR
 .RS 4
 If this option is set to 1, then pam_wrapper won\(cqt delete its temporary directories\&. Mostly useful for pam_wrapper development\&.
@@ -123,7 +128,7 @@ session         required        /usr/lib/pam_wrapper/pam_matrix\&.so passdb=/pat
 .sp
 The name of the file should represent the service name used by your PAM application\&.
 .sp
-LD_PRELOAD=\&./libpam_wrapper\&.so PAM_WRAPPER=1 PAM_WRAPPER_SERVICE_DIR=pam_services/ \&./my_pam_app
+LD_PRELOAD=\&./libpam_wrapper\&.so PAM_WRAPPER=1 PAM_WRAPPER_SERVICE_DIR=\&./pam_services \&./my_pam_app
 .SH "PAM_MATRIX"
 .sp
 We offer a module to make testing of PAM applications easier\&. You find more information in the pam_matrix(8) manpage\&.
diff --git a/doc/pam_wrapper.1.txt b/doc/pam_wrapper.1.txt
index 0a8ba51..1e93fba 100644
--- a/doc/pam_wrapper.1.txt
+++ b/doc/pam_wrapper.1.txt
@@ -1,6 +1,6 @@
 pam_wrapper(1)
 ==============
-:revdate: 2015-11-04
+:revdate: 2017-04-06
 
 NAME
 ----
@@ -52,6 +52,12 @@ debug symbols.
 - 2 = DEBUG
 - 3 = TRACE
 
+*PAM_WRAPPER_USE_SYSLOG*::
+
+By default pam logs will go to the pam_wrapper DEBUG log level and will not
+be sent to the syslog. If you want to log to the syslog to you can set this
+variable to 1.
+
 *PAM_WRAPPER_KEEP_DIR*::
 
 If this option is set to 1, then pam_wrapper won't delete its temporary
diff --git a/src/pam_wrapper.c b/src/pam_wrapper.c
index 168020b..d1ae075 100644
--- a/src/pam_wrapper.c
+++ b/src/pam_wrapper.c
@@ -103,58 +103,70 @@ enum pwrap_dbglvl_e {
 	PWRAP_LOG_TRACE
 };
 
-#ifdef NDEBUG
-# define PWRAP_LOG(...)
-#else /* NDEBUG */
 static void pwrap_log(enum pwrap_dbglvl_e dbglvl,
 		      const char *function,
 		      const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
 # define PWRAP_LOG(dbglvl, ...) pwrap_log((dbglvl), __func__, __VA_ARGS__)
 
-static void pwrap_log(enum pwrap_dbglvl_e dbglvl,
-		      const char *function,
-		      const char *format, ...)
+static void pwrap_vlog(enum pwrap_dbglvl_e dbglvl,
+		       const char *function,
+		       const char *format,
+		       va_list args) PRINTF_ATTRIBUTE(3, 0);
+
+static void pwrap_vlog(enum pwrap_dbglvl_e dbglvl,
+		       const char *function,
+		       const char *format,
+		       va_list args)
 {
 	char buffer[1024];
-	va_list va;
 	const char *d;
 	unsigned int lvl = 0;
+	const char *prefix = "PWRAP";
 
 	d = getenv("PAM_WRAPPER_DEBUGLEVEL");
 	if (d != NULL) {
 		lvl = atoi(d);
 	}
 
-	va_start(va, format);
-	vsnprintf(buffer, sizeof(buffer), format, va);
-	va_end(va);
+	if (lvl < dbglvl) {
+		return;
+	}
 
-	if (lvl >= dbglvl) {
-		const char *prefix = "PWRAP";
-		switch (dbglvl) {
-			case PWRAP_LOG_ERROR:
-				prefix = "PWRAP_ERROR";
-				break;
-			case PWRAP_LOG_WARN:
-				prefix = "PWRAP_WARN";
-				break;
-			case PWRAP_LOG_DEBUG:
-				prefix = "PWRAP_DEBUG";
-				break;
-			case PWRAP_LOG_TRACE:
-				prefix = "PWRAP_TRACE";
-				break;
-		}
+	vsnprintf(buffer, sizeof(buffer), format, args);
 
-		fprintf(stderr,
-			"%s(%d) - %s: %s\n",
-			prefix,
-			(int)getpid(),
-			function,
-			buffer);
+	switch (dbglvl) {
+	case PWRAP_LOG_ERROR:
+		prefix = "PWRAP_ERROR";
+		break;
+	case PWRAP_LOG_WARN:
+		prefix = "PWRAP_WARN";
+		break;
+	case PWRAP_LOG_DEBUG:
+		prefix = "PWRAP_DEBUG";
+		break;
+	case PWRAP_LOG_TRACE:
+		prefix = "PWRAP_TRACE";
+		break;
 	}
+
+	fprintf(stderr,
+		"%s(%d) - %s: %s\n",
+		prefix,
+		(int)getpid(),
+		function,
+		buffer);
+}
+
+static void pwrap_log(enum pwrap_dbglvl_e dbglvl,
+		      const char *function,
+		      const char *format, ...)
+{
+	va_list va;
+
+	va_start(va, format);
+	pwrap_vlog(dbglvl, function, format, va);
+	va_end(va);
 }
-#endif /* NDEBUG */
 
 /*****************
  * LIBC
@@ -496,7 +508,6 @@ static const char *libpam_pam_strerror(pam_handle_t *pamh, int errnum)
 	return pwrap.libpam.symbols._libpam_pam_strerror.f(discard_const_p(pam_handle_t, pamh), errnum);
 }
 
-#ifdef HAVE_PAM_VSYSLOG
 static void libpam_pam_vsyslog(const pam_handle_t *pamh,
 			       int priority,
 			       const char *fmt,
@@ -509,7 +520,6 @@ static void libpam_pam_vsyslog(const pam_handle_t *pamh,
 						   fmt,
 						   args);
 }
-#endif
 
 /*********************************************************
  * PWRAP INIT
@@ -1253,7 +1263,6 @@ static int pwrap_pam_get_item(const pam_handle_t *pamh,
 				  "pwrap_get_item item_type=%d item=%p",
 				  item_type, (const void *)*item);
 			break;
-			break;
 		}
 	} else {
 		PWRAP_LOG(PWRAP_LOG_TRACE, "pwrap_get_item failed rc=%d", rc);
@@ -1475,16 +1484,54 @@ const char *pam_strerror(pam_handle_t *pamh, int errnum)
 				  errnum);
 }
 
-#ifdef HAVE_PAM_VSYSLOG
+static void pwrap_pam_vsyslog(const pam_handle_t *pamh,
+			      int priority,
+			      const char *fmt,
+			      va_list args) PRINTF_ATTRIBUTE(3, 0);
+
 static void pwrap_pam_vsyslog(const pam_handle_t *pamh,
 			      int priority,
 			      const char *fmt,
 			      va_list args)
 {
+	const char *d;
+	char syslog_str[32] = {0};
+	enum pwrap_dbglvl_e dbglvl = PWRAP_LOG_TRACE;
+
 	PWRAP_LOG(PWRAP_LOG_TRACE, "pwrap_pam_vsyslog called");
-	libpam_pam_vsyslog(pamh, priority, fmt, args);
+
+	d = getenv("PAM_WRAPPER_USE_SYSLOG");
+	if (d != NULL && d[0] == '1') {
+		libpam_pam_vsyslog(pamh, priority, fmt, args);
+		return;
+	}
+
+	switch(priority) {
+	case 0: /* LOG_EMERG */
+	case 1: /* LOG_ALERT */
+	case 2: /* LOG_CRIT */
+	case 3: /* LOG_ERR */
+		dbglvl = PWRAP_LOG_ERROR;
+		break;
+	case 4: /* LOG_WARN */
+		dbglvl = PWRAP_LOG_WARN;
+		break;
+	case 5: /* LOG_NOTICE */
+	case 6: /* LOG_INFO */
+	case 7: /* LOG_DEBUG */
+		dbglvl = PWRAP_LOG_DEBUG;
+		break;
+	default:
+		dbglvl = PWRAP_LOG_TRACE;
+		break;
+	}
+
+	snprintf(syslog_str, sizeof(syslog_str), "SYSLOG(%d)", priority);
+
+	pwrap_vlog(dbglvl, syslog_str, fmt, args);
 }
 
+#ifdef HAVE_PAM_VSYSLOG
 void pam_vsyslog(const pam_handle_t *pamh,
 		 int priority,
 		 const char *fmt,


-- 
pam wrapper repository



More information about the samba-cvs mailing list