summaryrefslogtreecommitdiffstats
path: root/contrib/openpam/lib/openpam_log.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/openpam/lib/openpam_log.c')
-rw-r--r--contrib/openpam/lib/openpam_log.c66
1 files changed, 40 insertions, 26 deletions
diff --git a/contrib/openpam/lib/openpam_log.c b/contrib/openpam/lib/openpam_log.c
index 0758580..d03ec25 100644
--- a/contrib/openpam/lib/openpam_log.c
+++ b/contrib/openpam/lib/openpam_log.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
* All rights reserved.
*
* This software was developed for the FreeBSD Project by ThinkSec AS and
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/openpam/lib/openpam_log.c#18 $
+ * $P4: //depot/projects/openpam/lib/openpam_log.c#23 $
*/
#include <ctype.h>
@@ -47,20 +47,19 @@
int _openpam_debug = 0;
-#if defined(openpam_log)
+#if !defined(openpam_log)
/*
* OpenPAM extension
*
- * Log a message through syslog(3)
+ * Log a message through syslog
*/
void
-_openpam_log(int level, const char *func, const char *fmt, ...)
+openpam_log(int level, const char *fmt, ...)
{
va_list ap;
- char *format;
- int len, priority;
+ int priority;
switch (level) {
case PAM_LOG_DEBUG:
@@ -80,30 +79,17 @@ _openpam_log(int level, const char *func, const char *fmt, ...)
break;
}
va_start(ap, fmt);
- for (len = strlen(fmt); len > 0 && isspace(fmt[len]); len--)
- /* nothing */;
- if ((format = malloc(strlen(func) + len + 16)) != NULL) {
- sprintf(format, "in %s(): %.*s\n", func, len, fmt);
- vsyslog(priority, format, ap);
- free(format);
- } else {
- vsyslog(priority, fmt, ap);
- }
+ vsyslog(priority, fmt, ap);
va_end(ap);
}
#else
-/*
- * If openpam_log isn't defined as a macro, we're on a platform that
- * doesn't support varadic macros (or it does but we aren't aware of
- * it). Do the next best thing.
- */
-
void
-openpam_log(int level, const char *fmt, ...)
+_openpam_log(int level, const char *func, const char *fmt, ...)
{
va_list ap;
+ char *format;
int priority;
switch (level) {
@@ -124,12 +110,40 @@ openpam_log(int level, const char *fmt, ...)
break;
}
va_start(ap, fmt);
- vsyslog(priority, fmt, ap);
+ if (asprintf(&format, "in %s(): %s", func, fmt) > 0) {
+ vsyslog(priority, format, ap);
+ FREE(format);
+ } else {
+ vsyslog(priority, fmt, ap);
+ }
va_end(ap);
}
#endif
-/*
- * NOLIST
+/**
+ * The =openpam_log function logs messages using =syslog. It is primarily
+ * intended for internal use by the library and modules.
+ *
+ * The =level argument indicates the importance of the message. The
+ * following levels are defined:
+ *
+ * =PAM_LOG_DEBUG:
+ * Debugging messages. These messages are normally not
+ * logged unless the global integer variable :_openpam_debug
+ * is set to a non-zero value, in which case they are logged
+ * with a =syslog priority of =LOG_DEBUG.
+ * =PAM_LOG_VERBOSE:
+ * Information about the progress of the authentication
+ * process, or other non-essential messages. These messages
+ * are logged with a =syslog priority of =LOG_INFO.
+ * =PAM_LOG_NOTICE:
+ * Messages relating to non-fatal errors. These messages are
+ * logged with a =syslog priority of =LOG_NOTICE.
+ * =PAM_LOG_ERROR:
+ * Messages relating to serious errors. These messages are
+ * logged with a =syslog priority of =LOG_ERR.
+ *
+ * The remaining arguments are a =printf format string and the
+ * corresponding arguments.
*/
OpenPOWER on IntegriCloud