Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/libexec/ftpd Pullup rev 1.17-1.22 (requested by he in t...



details:   https://anonhg.NetBSD.org/src/rev/a930292338f7
branches:  netbsd-1-6
changeset: 531480:a930292338f7
user:      jmc <jmc%NetBSD.org@localhost>
date:      Tue Aug 31 01:35:48 2004 +0000

description:
Pullup rev 1.17-1.22 (requested by he in ticket #1739)

Update to NetBSD ftpd 20040809.  Fixes SA#2004-009.

diffstat:

 libexec/ftpd/logwtmp.c |  46 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 9 deletions(-)

diffs (100 lines):

diff -r d069670f2096 -r a930292338f7 libexec/ftpd/logwtmp.c
--- a/libexec/ftpd/logwtmp.c    Tue Aug 31 01:35:45 2004 +0000
+++ b/libexec/ftpd/logwtmp.c    Tue Aug 31 01:35:48 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: logwtmp.c,v 1.16 2001/02/04 22:04:12 christos Exp $    */
+/*     $NetBSD: logwtmp.c,v 1.16.2.1 2004/08/31 01:35:48 jmc Exp $     */
 
 /*
  * Copyright (c) 1988, 1993
@@ -12,11 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -40,7 +36,7 @@
 #if 0
 static char sccsid[] = "@(#)logwtmp.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: logwtmp.c,v 1.16 2001/02/04 22:04:12 christos Exp $");
+__RCSID("$NetBSD: logwtmp.c,v 1.16.2.1 2004/08/31 01:35:48 jmc Exp $");
 #endif
 #endif /* not lint */
 
@@ -48,15 +44,18 @@
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/stat.h>
+#include <sys/wait.h>
 
 #include <fcntl.h>
-#include <setjmp.h>
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
 #include <utmp.h>
+#ifdef SUPPORT_UTMPX
+#include <utmpx.h>
+#endif
 #include <util.h>
 
 #ifdef KERBEROS5
@@ -66,6 +65,9 @@
 #include "extern.h"
 
 static int fd = -1;
+#ifdef SUPPORT_UTMPX
+static int fdx = -1;
+#endif
 
 /*
  * Modified version of logwtmp that holds wtmp file open
@@ -73,7 +75,7 @@
  * after login, but before logout).
  */
 void
-logwtmp(const char *line, const char *name, const char *host)
+ftpd_logwtmp(const char *line, const char *name, const char *host)
 {
        struct utmp ut;
        struct stat buf;
@@ -90,3 +92,29 @@
                        (void)ftruncate(fd, buf.st_size);
        }
 }
+
+#ifdef SUPPORT_UTMPX
+void
+ftpd_logwtmpx(const char *line, const char *name, const char *host, int status, int utx_type)
+{
+       struct utmpx ut;
+       struct stat buf;
+       
+       if (fdx < 0 && (fdx = open(_PATH_WTMPX, O_WRONLY|O_APPEND, 0)) < 0)
+               return;
+       if (fstat(fdx, &buf) == 0) {
+               (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));
+               (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));
+               (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));
+               ut.ut_type = utx_type;
+               if (WIFEXITED(status))
+                       ut.ut_exit.e_exit = (uint16_t)WEXITSTATUS(status);
+               if (WIFSIGNALED(status))
+               ut.ut_exit.e_termination = (uint16_t)WTERMSIG(status);
+               (void)gettimeofday(&ut.ut_tv, NULL);
+               if(write(fdx, (char *)&ut, sizeof(struct utmpx)) !=
+                   sizeof(struct utmpx))
+                       (void)ftruncate(fdx, buf.st_size);
+       }
+}
+#endif



Home | Main Index | Thread Index | Old Index