Skip to content

Commit

Permalink
log: Fall back to syslog+vsnprintf if vsyslog is not available
Browse files Browse the repository at this point in the history
On some platforms, like HP-UX, even vsyslog is not available. In this
case, we fall back to printing the message with vsnprintf and then
logging the message with syslog.
  • Loading branch information
johnnys66 authored and jhrozek committed Jan 1, 2017
1 parent 46a53ea commit c5df837
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -109,7 +109,7 @@ save_LIBS="$LIBS"
LIBS="$PAM_LIBS"

dnl Check for optional PAM fnuctions
AC_CHECK_FUNCS(pam_syslog pam_vsyslog)
AC_CHECK_FUNCS(vsyslog pam_syslog pam_vsyslog)

dnl restore LIBS
LIBS="$save_LIBS"
Expand Down
8 changes: 8 additions & 0 deletions src/pam_hbac_compat.h
Expand Up @@ -71,6 +71,14 @@ do { \
# include <security/openpam.h>
#endif /* HAVE_SECURITY_OPENPAM_H */

#ifndef HAVE_VSYSLOG
#define vsyslog(priority, fmt, vargs) do { \
char _vsyslog_msg[1024]; \
vsnprintf(_vsyslog_msg, sizeof(_vsyslog_msg), fmt, vargs); \
syslog(level, "%s", _vsyslog_msg); \
} while(0);
#endif /* HAVE_VSYSLOG */

#ifndef HAVE_PAM_VSYSLOG
#define pam_vsyslog(pamh, priority, fmt, vargs) \
vsyslog((priority), (fmt), (vargs))
Expand Down

0 comments on commit c5df837

Please sign in to comment.