pkgsrc/net/proftpd/patches/patch-ac
christos 176608d009 Make it log in wtmpx properly.
XXX: someone should fix the array has type char issues.
2005-06-23 04:49:26 +00:00

60 lines
1.7 KiB
Text

$NetBSD: patch-ac,v 1.1 2005/06/23 04:49:26 christos Exp $
--- src/log.c.orig 2004-08-07 18:22:42.000000000 -0400
+++ src/log.c 2005-06-23 00:42:29.000000000 -0400
@@ -59,7 +59,8 @@
int res = 0;
static int fd = -1;
-#if (defined(SVR4) || defined(__SVR4)) && \
+#if ((defined(SVR4) || defined(__SVR4)) || \
+ (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
!(defined(LINUX) || defined(__hpux) || defined (_AIX))
/* This "auxilliary" utmp doesn't exist under linux. */
#ifdef __sparcv9
@@ -70,6 +71,10 @@
#endif
static int fdx = -1;
+#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
+# define WTMPX_FILE _PATH_WTMPX
+#endif
+
if (fdx < 0 &&
(fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
@@ -89,14 +94,30 @@
sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
- utx.ut_syslen = strlen(utx.ut_host)+1;
utx.ut_pid = getpid();
-#ifdef __sparcv9
+#if defined(__NetBSD__) && defined(HAVE_UTMPX_H)
+ {
+ /* XXX: may return (size_t) -1 */
+ size_t len = pr_netaddr_get_inaddr_len(ip);
+ if (len > sizeof(utx.ut_ss))
+ len = sizeof(utx.ut_ss);
+# ifndef USE_IPV6
+ memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), len);
+# else
+ memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), len);
+# endif /* !USE_IPV6 */
+ }
+ gettimeofday(&utx.ut_tv, NULL);
+#else /* SVR4 */
+ utx.ut_syslen = strlen(utx.ut_host)+1;
+# ifdef __sparcv9
time(&t);
utx.ut_tv.tv_sec = (time32_t)t;
-#else
+# else
time(&utx.ut_tv.tv_sec);
-#endif
+# endif
+#endif /* SVR4 */
+
if (*name)
utx.ut_type = USER_PROCESS;
else