$NetBSD: patch-ac,v 1.3 2005/11/04 12:36:16 martti Exp $

--- src/log.c	19 Sep 2005 21:35:38 -0000	1.74
+++ src/log.c	3 Nov 2005 19:13:17 -0000
@@ -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,20 @@
     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)
+    memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
+    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
