From da109cd27f58bab302d1fe5cc5e722b4b2a0066c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 10 Apr 2008 10:44:14 +0000 Subject: [PATCH] Use asl for logging ftpd wtmp messages. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22951 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftpd/logwtmp.c | 43 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/appl/ftp/ftpd/logwtmp.c b/appl/ftp/ftpd/logwtmp.c index 5a4f0d5a7..f29df2b8f 100644 --- a/appl/ftp/ftpd/logwtmp.c +++ b/appl/ftp/ftpd/logwtmp.c @@ -58,6 +58,9 @@ RCSID("$Id$"); #ifdef HAVE_UTMPX_H #include #endif +#ifdef HAVE_ASL_H +#include +#endif #include #include "extern.h" @@ -69,8 +72,32 @@ RCSID("$Id$"); #endif #endif -void -ftpd_logwtmp(char *line, char *name, char *host) +#ifdef HAVE_ASL_H +static void +ftpd_logwtmp_asl(char *line, char *name, char *host) +{ + static aslmsg m = NULL; + static int init = 0; + + if (!init) { + init = 1; + m = asl_new(ASL_TYPE_MSG); + if (m == NULL) + return; + asl_set(m, ASL_KEY_FACILITY, "org.h5l.ftpd"); + } + if (m) + asl_log(NULL, m, ASL_LEVEL_NOTICE, + "host %s/%s user %s%sconnected pid %d", + host, line, name, name[0] ? " " : "dis", (int)getpid()); +} + +#endif + +#ifndef HAVE_ASL_H + +static void +ftpd_logwtmp_wtmp(char *line, char *name, char *host) { static int init = 0; static int fd; @@ -136,3 +163,15 @@ ftpd_logwtmp(char *line, char *name, char *host) #endif } } + +#endif /* !HAVE_ASL_H */ + +void +ftpd_logwtmp(char *line, char *name, char *host) +{ +#ifdef HAVE_ASL_H + ftpd_logwtmp_asl(line, name, host); +#else + ftpd_logwtmp_wtmp(line, name, host); +#endif +}