head 1.2; access; symbols NetBSD-20031210:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.2 date 2003.12.10.01.53.48; author lukem; state dead; branches; next 1.1; 1.1 date 2003.12.10.01.40.31; author lukem; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2003.12.10.01.40.31; author lukem; state Exp; branches; next ; desc @@ 1.2 log @remove crap that shouldn't have been imported @ text @? difz ? logz Index: Makefile =================================================================== RCS file: /cvsroot/src/libexec/ftpd/Makefile,v retrieving revision 1.50 retrieving revision 1.51 diff -p -p -u -r1.50 -r1.51 --- Makefile 18 Sep 2002 06:24:34 -0000 1.50 +++ Makefile 23 Jul 2003 08:01:27 -0000 1.51 @@@@ -1,4 +1,4 @@@@ -# $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ +# $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ # @@(#)Makefile 8.2 (Berkeley) 4/4/94 .include @@@@ -28,19 +28,24 @@@@ LDADD+= -lskey ftpd.o ftpcmd.o: version.h -# XXX Kerberos support is broken right now. +#.if (${USE_KERBEROS} != "no") +# #.PATH: ${NETBSDSRCDIR}/usr.bin/login - -#.ifdef KERBEROS5 +# #SRCS+= k5login.c #CPPFLAGS+=-DKERBEROS5 -#DPADD+= ${LIBKRB5} ${LIBK5CRYPTO} ${LIBCOM_ERR} -#LDADD+= -lkrb5 -lk5crypto -lcom_err -#.else -#SRCS+= klogin.c -#CPPFLAGS+=-DKERBEROS -#DPADD+= ${LIBKRB} ${LIBDES} ${LIBCOM_ERR} -#LDADD+= -lkrb -kdes -lcom_err +#CPPFLAGS+=-DKERBEROS5 -I${DESTDIR}/usr/include/krb5 +#DPADD+= ${LIBKRB5} ${LIBASN1} +#LDADD+= -lkrb5 -lasn1 +# +#SRCS+= klogin.c +#CPPFLAGS+=-DKERBEROS -I${DESTDIR}/usr/include/kerberosIV +#DPADD+= ${LIBKRB} +#LDADD+= -lkrb +# +#DPADD+= ${LIBCRYPTO} ${LIBROKEN} ${LIBCOM_ERR} +#LDADD+= -lcrypto -lroken -lcom_err +# #.endif .include Index: cmds.c =================================================================== RCS file: /cvsroot/src/libexec/ftpd/cmds.c,v retrieving revision 1.20 retrieving revision 1.22 diff -p -p -u -r1.20 -r1.22 --- cmds.c 8 Jan 2003 18:07:31 -0000 1.20 +++ cmds.c 7 Aug 2003 09:46:38 -0000 1.22 @@@@ -1,4 +1,4 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ /* * Copyright (c) 1999-2001 The NetBSD Foundation, Inc. @@@@ -48,11 +48,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. * @@@@ -101,7 +97,7 @@@@ #include #ifndef lint -__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); +__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); #endif /* not lint */ #include @@@@ -812,7 +808,7 @@@@ static void mlsname(FILE *fp, factelem *fe) { char realfile[MAXPATHLEN]; - int i, userf; + int i, userf = 0; for (i = 0; i < FACTTABSIZE; i++) { if (facttab[i].enabled) Index: extern.h =================================================================== RCS file: /cvsroot/src/libexec/ftpd/extern.h,v retrieving revision 1.47 retrieving revision 1.49 diff -p -p -u -r1.47 -r1.49 --- extern.h 23 Feb 2003 13:04:37 -0000 1.47 +++ extern.h 7 Aug 2003 09:46:38 -0000 1.49 @@@@ -1,4 +1,4 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ /*- * Copyright (c) 1992, 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. * @@@@ -187,6 +183,13 @@@@ struct utmp; void ftpd_logwtmp(const char *, const char *, const char *); void ftpd_login(const struct utmp *ut); int ftpd_logout(const char *line); +#endif + +#ifdef SUPPORT_UTMPX +struct utmpx; + +void ftpd_loginx(const struct utmpx *); +void ftpd_logwtmpx(const char *, const char *, const char *, int, int); #endif #include Index: ftpcmd.y =================================================================== RCS file: /cvsroot/src/libexec/ftpd/ftpcmd.y,v retrieving revision 1.74 retrieving revision 1.77 diff -p -p -u -r1.74 -r1.77 --- ftpcmd.y 24 Feb 2003 12:57:06 -0000 1.74 +++ ftpcmd.y 7 Aug 2003 09:46:39 -0000 1.77 @@@@ -1,4 +1,4 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ /*- * Copyright (c) 1997-2002 The NetBSD Foundation, Inc. @@@@ -48,11 +48,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. * @@@@ -83,7 +79,7 @@@@ #if 0 static char sccsid[] = "@@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; #else -__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); +__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); #endif #endif /* not lint */ @@@@ -987,7 +983,7 @@@@ host_long_port6 memset(&data_dest, 0, sizeof(data_dest)); #endif /* INET6 */ /* reject invalid LPRT command */ - if ($1.i != 6.i || $3.i != 16.i || $37.i != 2) + if ($1.i != 6 || $3.i != 16 || $37.i != 2) memset(&data_dest, 0, sizeof(data_dest)); } ; @@@@ -1303,7 +1299,7 @@@@ static int check_write(const char *, int static void help(struct tab *, const char *); static void port_check(const char *, int); static void toolong(int); -static int yylex(void); + int yylex(void); extern int epsvall; @@@@ -1487,7 +1483,7 @@@@ ftp_loop(void) /*NOTREACHED*/ } -static int +int yylex(void) { static int cpos, state; Index: ftpd.8 =================================================================== RCS file: /cvsroot/src/libexec/ftpd/ftpd.8,v retrieving revision 1.71 retrieving revision 1.74 diff -p -p -u -r1.71 -r1.74 --- ftpd.8 4 Feb 2003 23:07:33 -0000 1.71 +++ ftpd.8 7 Aug 2003 09:46:39 -0000 1.74 @@@@ -1,6 +1,6 @@@@ -.\" $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ +.\" $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ .\" -.\" Copyright (c) 1997-2002 The NetBSD Foundation, Inc. +.\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@@@ -45,11 +45,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. .\" @@@@ -67,7 +63,7 @@@@ .\" .\" @@(#)ftpd.8 8.2 (Berkeley) 4/19/94 .\" -.Dd October 25, 2002 +.Dd February 26, 2003 .Dt FTPD 8 .Os .Sh NAME @@@@ -82,6 +78,7 @@@@ Internet File Transfer Protocol server .Op Fl C Ar user .Op Fl e Ar emailaddr .Op Fl h Ar hostname +.Op Fl L Ar xferlogfile .Op Fl P Ar dataport .Op Fl V Ar version .Sh DESCRIPTION @@@@ -172,6 +169,13 @@@@ session is logged using syslog with a fa If this option is specified more than once, the retrieve (get), store (put), append, delete, make directory, remove directory and rename operations and their file name arguments are also logged. +.It Fl L Ar xferlogfile +Log +.Tn wu-ftpd +style +.Sq xferlog +entries to +.Ar xferlogfile . .It Fl P Ar dataport Use .Ar dataport Index: ftpd.c =================================================================== RCS file: /cvsroot/src/libexec/ftpd/ftpd.c,v retrieving revision 1.152 retrieving revision 1.157 diff -p -p -u -r1.152 -r1.157 --- ftpd.c 23 Feb 2003 13:04:37 -0000 1.152 +++ ftpd.c 10 Dec 2003 01:18:56 -0000 1.157 @@@@ -1,7 +1,7 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ /* - * Copyright (c) 1997-2001 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@@@ -48,11 +48,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. * @@@@ -109,7 +105,7 @@@@ __COPYRIGHT( #if 0 static char sccsid[] = "@@(#)ftpd.c 8.5 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); +__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); #endif #endif /* not lint */ @@@@ -183,7 +179,8 @@@@ int dataport; /* use specific data port int dopidfile; /* maintain pid file */ int doutmp; /* update utmp file */ int dowtmp; /* update wtmp file */ -int doxferlog; /* syslog wu-ftpd style xferlog entries */ +int doxferlog; /* syslog/write wu-ftpd style xferlog entries */ +int xferlogfd; /* fd to write wu-ftpd xferlog entries to */ int dropprivs; /* if privileges should or have been dropped */ int mapped; /* IPv4 connection on AF_INET6 socket */ off_t file_size; @@@@ -199,6 +196,9 @@@@ static struct utmpx utmpx; /* for utmpx static const char *anondir = NULL; static const char *confdir = _DEFAULT_CONFDIR; +static char *curname; /* current USER name */ +static size_t curname_len; /* length of curname (include NUL) */ + #if defined(KERBEROS) || defined(KERBEROS5) int has_ccache = 0; int notickets = 1; @@@@ -269,6 +269,7 @@@@ main(int argc, char *argv[]) krb5_error_code kerror; #endif char *p; + const char *xferlogname = NULL; long l; connections = 1; @@@@ -281,6 +282,7 @@@@ main(int argc, char *argv[]) doutmp = 0; /* default: Do NOT log to utmp */ dowtmp = 1; /* default: DO log to wtmp */ doxferlog = 0; /* default: Do NOT syslog xferlog */ + xferlogfd = -1; /* default: Do NOT write xferlog file */ dropprivs = 0; mapped = 0; usedefault = 1; @@@@ -297,7 +299,7 @@@@ main(int argc, char *argv[]) */ openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); - while ((ch = getopt(argc, argv, "a:c:C:de:h:HlP:qQrst:T:uUvV:wWX")) + while ((ch = getopt(argc, argv, "a:c:C:de:h:HlL:P:qQrst:T:uUvV:wWX")) != -1) { switch (ch) { case 'a': @@@@ -336,6 +338,10 @@@@ main(int argc, char *argv[]) logging++; /* > 1 == extra logging */ break; + case 'L': + xferlogname = optarg; + break; + case 'P': errno = 0; p = NULL; @@@@ -397,7 +403,7 @@@@ main(int argc, char *argv[]) break; case 'X': - doxferlog = 1; + doxferlog |= 1; break; default: @@@@ -410,6 +416,23 @@@@ main(int argc, char *argv[]) if (EMPTYSTR(confdir)) confdir = _DEFAULT_CONFDIR; + errno = 0; + l = sysconf(_SC_LOGIN_NAME_MAX); + if (l == -1 && errno != 0) { + syslog(LOG_ERR, "sysconf _SC_LOGIN_NAME_MAX: %m"); + exit(1); + } else if (l <= 0) { + syslog(LOG_WARNING, "using conservative LOGIN_NAME_MAX value"); + curname_len = _POSIX_LOGIN_NAME_MAX; + } else + curname_len = (size_t)l; + curname = malloc(curname_len); + if (curname == NULL) { + syslog(LOG_ERR, "malloc: %m"); + exit(1); + } + curname[0] = '\0'; + memset((char *)&his_addr, 0, sizeof(his_addr)); addrlen = sizeof(his_addr.si_su); if (getpeername(0, (struct sockaddr *)&his_addr.si_su, &addrlen) < 0) { @@@@ -549,6 +572,16 @@@@ main(int argc, char *argv[]) else reply(220, "%s FTP server (%s) ready.", hostname, version); + if (xferlogname != NULL) { + xferlogfd = open(xferlogname, O_WRONLY | O_APPEND | O_CREAT, + 0660); + if (xferlogfd == -1) + syslog(LOG_WARNING, "open xferlog `%s': %m", + xferlogname); + else + doxferlog |= 2; + } + (void) setjmp(errcatch); ftp_loop(); /* NOTREACHED */ @@@@ -596,7 +629,6 @@@@ sgetpwnam(const char *name) static int login_attempts; /* number of failed login attempts */ static int askpasswd; /* had USER command, ask for PASSwd */ static int permitted; /* USER permitted */ -static char curname[LOGIN_NAME_MAX]; /* current USER name */ /* * USER command. @@@@ -670,7 +702,7 @@@@ user(const char *name) } else pw = sgetpwnam(name); - strlcpy(curname, name, sizeof(curname)); + strlcpy(curname, name, curname_len); /* check user in /etc/ftpusers, and setup class */ permitted = checkuser(_PATH_FTPUSERS, curname, 1, 0, &class); @@@@ -936,10 +968,10 @@@@ login_utmp(const char *line, const char (void)strncpy(utmpx.ut_name, name, sizeof(utmpx.ut_name)); (void)strncpy(utmpx.ut_line, line, sizeof(utmpx.ut_line)); (void)strncpy(utmpx.ut_host, host, sizeof(utmpx.ut_host)); - loginx(&utmpx); + ftpd_loginx(&utmpx); } if (dowtmp) - logwtmpx(line, name, host, 0, USER_PROCESS); + ftpd_logwtmpx(line, name, host, 0, USER_PROCESS); #endif #ifdef SUPPORT_UTMP if (doutmp) { @@@@ -970,7 +1002,7 @@@@ logout_utmp(void) } if (okwtmp) { #ifdef SUPPORT_UTMPX - logwtmpx(ttyline, "", "", 0, DEAD_PROCESS); + ftpd_logwtmpx(ttyline, "", "", 0, DEAD_PROCESS); #endif #ifdef SUPPORT_UTMP ftpd_logwtmp(ttyline, "", ""); @@@@ -2448,6 +2480,8 @@@@ dologout(int status) #endif } /* beware of flushing buffers after a SIGPIPE */ + if (xferlogfd != -1) + close(xferlogfd); _exit(status); } @@@@ -2909,7 +2943,8 @@@@ send_file_list(const char *whichf) DIR *dirp = NULL; struct dirent *dir; FILE *dout = NULL; - char **dirlist, *dirname, *notglob, *p; + char **dirlist, *dirname, *p; + char *notglob = NULL; int simple = 0; int freeglob = 0; glob_t gl; @@@@ -3072,7 +3107,7 @@@@ conffilename(const char *s) * if error != NULL, append ": " + error * * if doxferlog != 0, bytes != -1, and command is "get", "put", - * or "append", syslog a wu-ftpd style xferlog entry + * or "append", syslog and/or write a wu-ftpd style xferlog entry */ void logxfer(const char *command, off_t bytes, const char *file1, const char *file2, @@@@ -3129,21 +3164,15 @@@@ logxfer(const char *command, off_t bytes return; time(&now); - syslog(LOG_INFO, - "xferlog%s: %.24s %ld %s " LLF " %s %c %s %c %c %s FTP 0 * %c", + len = snprintf(buf, sizeof(buf), + "%.24s %ld %s " LLF " %s %c %s %c %c %s FTP 0 * %c\n", /* - * XXX: wu-ftpd puts (send) or (recv) in the syslog message, and removes + * XXX: wu-ftpd puts ' (send)' or ' (recv)' in the syslog message, and removes * the full date. This may be problematic for accurate log parsing, * given that syslog messages don't contain the full date. */ -#if 1 /* lukem's method; easier to convert to actual xferlog file */ - "", ctime(&now), -#else /* wu-ftpd's syslog method, with an extra unneeded space */ - (direction == 'i') ? " (recv)" : " (send)", - "", -#endif elapsed == NULL ? 0 : elapsed->tv_sec + (elapsed->tv_usec > 0), remotehost, (LLT) bytes, @@@@ -3159,6 +3188,13 @@@@ logxfer(const char *command, off_t bytes curclass.type == CLASS_GUEST ? pw->pw_passwd : pw->pw_name, error != NULL ? 'i' : 'c' ); + + if ((doxferlog & 2) && xferlogfd != -1) + write(xferlogfd, buf, len); + if ((doxferlog & 1)) { + buf[len-1] = '\n'; /* strip \n from syslog message */ + syslog(LOG_INFO, "xferlog: %s", buf); + } } /* Index: ftpd.conf.5 =================================================================== RCS file: /cvsroot/src/libexec/ftpd/ftpd.conf.5,v retrieving revision 1.25 retrieving revision 1.28 diff -p -p -u -r1.25 -r1.28 --- ftpd.conf.5 29 Nov 2002 19:22:01 -0000 1.25 +++ ftpd.conf.5 27 Jun 2003 18:59:54 -0000 1.28 @@@@ -1,4 +1,4 @@@@ -.\" $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ +.\" $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ .\" .\" Copyright (c) 1997-2001 The NetBSD Foundation, Inc. .\" All rights reserved. @@@@ -80,7 +80,7 @@@@ is used to determine which .Nm entries apply to the user. The following special classes exist when parsing entries in -.Nm "" : +.Nm : .Bl -tag -width "chroot" -compact -offset indent .It Sy all Matches any class. @@@@ -100,7 +100,7 @@@@ A .Xr chroot 2 is performed after login. .It Sy CHROOT -.Xr chroot 2 ed +.Xr chroot 2 Ns ed users (as per .Xr ftpchroot 5 ) . A @@@@ -114,7 +114,7 @@@@ The .Xr ftpd 8 .Sy STAT command will return the class settings for the current user as defined by -.Nm "" , +.Nm , unless the .Sy private directive is set for the class. @@@@ -170,7 +170,7 @@@@ is not specified or .Ar class is .Dq none , -use the default behaviour (see below). +use the default behavior (see below). Otherwise, .Ar pathformat is parsed to create a directory to create as the root directory with @@@@ -311,7 +311,7 @@@@ is not specified or .Ar class is .Dq none , -use the default behaviour (see below). +use the default behavior (see below). Otherwise, .Ar pathformat is parsed to create a directory to change into upon login, and to use Index: ftpusers.5 =================================================================== RCS file: /cvsroot/src/libexec/ftpd/ftpusers.5,v retrieving revision 1.13 retrieving revision 1.15 diff -p -p -u -r1.13 -r1.15 --- ftpusers.5 1 Dec 2001 16:24:24 -0000 1.13 +++ ftpusers.5 26 Jul 2003 19:32:07 -0000 1.15 @@@@ -1,4 +1,4 @@@@ -.\" $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ +.\" $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ .\" .\" Copyright (c) 1997-2001 The NetBSD Foundation, Inc. .\" All rights reserved. @@@@ -91,7 +91,7 @@@@ or an .Xr fnmatch 3 glob to match against the remote hostname (e.g, -.Sq *.netbsd.org ) . +.Sq *.NetBSD.org ) . .It Sy directive If .Dq allow @@@@ -159,7 +159,7 @@@@ or to the home directory of the user. If the file does not exist, the root directory change is not performed. .Pp The syntax is similar to -.Nm "" , +.Nm , except that the .Sy class argument is ignored. Index: logutmp.c =================================================================== RCS file: /cvsroot/src/libexec/ftpd/logutmp.c,v retrieving revision 1.4 retrieving revision 1.7 diff -p -p -u -r1.4 -r1.7 --- logutmp.c 23 Feb 2003 13:04:37 -0000 1.4 +++ logutmp.c 13 Oct 2003 15:36:33 -0000 1.7 @@@@ -1,7 +1,6 @@@@ /* * Portions Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. - * Portions Copyright (c) 1996, Jason Downs. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@@@ -11,11 +10,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. * @@@@ -32,6 +27,31 @@@@ * SUCH DAMAGE. */ +/* + * Portions Copyright (c) 1996, Jason Downs. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include @@@@ -43,6 +63,9 @@@@ #include #include #include +#ifdef SUPPORT_UTMPX +#include +#endif #include #include "extern.h" @@@@ -122,3 +145,14 @@@@ ftpd_logout(const char *line) } return(rval); } + +#ifdef SUPPORT_UTMPX +/* + * special version of loginx which updates utmpx only. + */ +void +ftpd_loginx(const struct utmpx *ut) +{ + (void)pututxline(ut); +} +#endif Index: logwtmp.c =================================================================== RCS file: /cvsroot/src/libexec/ftpd/logwtmp.c,v retrieving revision 1.19 retrieving revision 1.21 diff -p -p -u -r1.19 -r1.21 --- logwtmp.c 23 Feb 2003 13:04:37 -0000 1.19 +++ logwtmp.c 7 Aug 2003 09:46:40 -0000 1.21 @@@@ -1,4 +1,4 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem 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: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); +__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); #endif #endif /* not lint */ @@@@ -48,6 +44,7 @@@@ __RCSID("$NetBSD: logwtmp.c,v 1.19 2003/ #include #include #include +#include #include #include @@@@ -57,6 +54,9 @@@@ __RCSID("$NetBSD: logwtmp.c,v 1.19 2003/ #include #include #include +#ifdef SUPPORT_UTMPX +#include +#endif #include #ifdef KERBEROS5 @@@@ -66,6 +66,9 @@@@ __RCSID("$NetBSD: logwtmp.c,v 1.19 2003/ #include "extern.h" static int fd = -1; +#ifdef SUPPORT_UTMPX +static int fdx = -1; +#endif /* * Modified version of logwtmp that holds wtmp file open @@@@ -90,3 +93,29 @@@@ ftpd_logwtmp(const char *line, const cha (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 Index: pathnames.h =================================================================== RCS file: /cvsroot/src/libexec/ftpd/pathnames.h,v retrieving revision 1.10 retrieving revision 1.11 diff -p -p -u -r1.10 -r1.11 --- pathnames.h 6 Mar 2000 21:42:26 -0000 1.10 +++ pathnames.h 7 Aug 2003 09:46:40 -0000 1.11 @@@@ -1,4 +1,4 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ /* * Copyright (c) 1989, 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. * Index: popen.c =================================================================== RCS file: /cvsroot/src/libexec/ftpd/popen.c,v retrieving revision 1.28 retrieving revision 1.29 diff -p -p -u -r1.28 -r1.29 --- popen.c 16 Jan 2003 09:41:38 -0000 1.28 +++ popen.c 7 Aug 2003 09:46:40 -0000 1.29 @@@@ -1,4 +1,4 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ /*- * Copyright (c) 1999-2001 The NetBSD Foundation, Inc. @@@@ -51,11 +51,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. * @@@@ -78,7 +74,7 @@@@ #if 0 static char sccsid[] = "@@(#)popen.c 8.3 (Berkeley) 4/6/94"; #else -__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); +__RCSID("$NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $"); #endif #endif /* not lint */ Index: version.h =================================================================== RCS file: /cvsroot/src/libexec/ftpd/version.h,v retrieving revision 1.53 retrieving revision 1.56 diff -p -p -u -r1.53 -r1.56 --- version.h 24 Feb 2003 12:57:06 -0000 1.53 +++ version.h 10 Dec 2003 01:18:56 -0000 1.56 @@@@ -1,6 +1,6 @@@@ -/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ +/* $NetBSD: difz,v 1.1 2003/12/10 01:40:31 lukem Exp $ */ /*- - * Copyright (c) 1999-2002 The NetBSD Foundation, Inc. + * Copyright (c) 1999-2003 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@@@ -36,5 +36,5 @@@@ */ #ifndef FTPD_VERSION -#define FTPD_VERSION "NetBSD-ftpd 20030224" +#define FTPD_VERSION "NetBSD-ftpd 20031210" #endif @ 1.1 log @Initial revision @ text @d12 2 a13 2 -# $NetBSD: Makefile,v 1.50 2002/09/18 06:24:34 lukem Exp $ +# $NetBSD: Makefile,v 1.51 2003/07/23 08:01:27 itojun Exp $ d61 2 a62 2 -/* $NetBSD: cmds.c,v 1.20 2003/01/08 18:07:31 manu Exp $ */ +/* $NetBSD: cmds.c,v 1.22 2003/08/07 09:46:38 agc Exp $ */ d83 2 a84 2 -__RCSID("$NetBSD: cmds.c,v 1.20 2003/01/08 18:07:31 manu Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.22 2003/08/07 09:46:38 agc Exp $"); d106 2 a107 2 -/* $NetBSD: extern.h,v 1.47 2003/02/23 13:04:37 lukem Exp $ */ +/* $NetBSD: extern.h,v 1.49 2003/08/07 09:46:38 agc Exp $ */ d147 2 a148 2 -/* $NetBSD: ftpcmd.y,v 1.74 2003/02/24 12:57:06 lukem Exp $ */ +/* $NetBSD: ftpcmd.y,v 1.77 2003/08/07 09:46:39 agc Exp $ */ d169 2 a170 2 -__RCSID("$NetBSD: ftpcmd.y,v 1.74 2003/02/24 12:57:06 lukem Exp $"); +__RCSID("$NetBSD: ftpcmd.y,v 1.77 2003/08/07 09:46:39 agc Exp $"); d210 2 a211 2 -.\" $NetBSD: ftpd.8,v 1.71 2003/02/04 23:07:33 perry Exp $ +.\" $NetBSD: ftpd.8,v 1.74 2003/08/07 09:46:39 agc Exp $ d271 2 a272 2 -/* $NetBSD: ftpd.c,v 1.152 2003/02/23 13:04:37 lukem Exp $ */ +/* $NetBSD: ftpd.c,v 1.157 2003/12/10 01:18:56 lukem Exp $ */ d297 2 a298 2 -__RCSID("$NetBSD: ftpd.c,v 1.152 2003/02/23 13:04:37 lukem Exp $"); +__RCSID("$NetBSD: ftpd.c,v 1.157 2003/12/10 01:18:56 lukem Exp $"); d523 2 a524 2 -.\" $NetBSD: ftpd.conf.5,v 1.25 2002/11/29 19:22:01 wiz Exp $ +.\" $NetBSD: ftpd.conf.5,v 1.28 2003/06/27 18:59:54 wiz Exp $ d582 2 a583 2 -.\" $NetBSD: ftpusers.5,v 1.13 2001/12/01 16:24:24 wiz Exp $ +.\" $NetBSD: ftpusers.5,v 1.15 2003/07/26 19:32:07 salo Exp $ d700 2 a701 2 -/* $NetBSD: logwtmp.c,v 1.19 2003/02/23 13:04:37 lukem Exp $ */ +/* $NetBSD: logwtmp.c,v 1.21 2003/08/07 09:46:40 agc Exp $ */ d722 2 a723 2 -__RCSID("$NetBSD: logwtmp.c,v 1.19 2003/02/23 13:04:37 lukem Exp $"); +__RCSID("$NetBSD: logwtmp.c,v 1.21 2003/08/07 09:46:40 agc Exp $"); d794 2 a795 2 -/* $NetBSD: pathnames.h,v 1.10 2000/03/06 21:42:26 lukem Exp $ */ +/* $NetBSD: pathnames.h,v 1.11 2003/08/07 09:46:40 agc Exp $ */ d821 2 a822 2 -/* $NetBSD: popen.c,v 1.28 2003/01/16 09:41:38 kleink Exp $ */ +/* $NetBSD: popen.c,v 1.29 2003/08/07 09:46:40 agc Exp $ */ d843 2 a844 2 -__RCSID("$NetBSD: popen.c,v 1.28 2003/01/16 09:41:38 kleink Exp $"); +__RCSID("$NetBSD: popen.c,v 1.29 2003/08/07 09:46:40 agc Exp $"); d857 2 a858 2 -/* $NetBSD: version.h,v 1.53 2003/02/24 12:57:06 lukem Exp $ */ +/* $NetBSD: version.h,v 1.56 2003/12/10 01:18:56 lukem Exp $ */ @ 1.1.1.1 log @Sync to NetBSD ftpd 20031210. Notable changes: * Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22284 * Add ftpd_loginx() and ftpd_logwtmpx() and use them to hold wtmpx file open while a session. Close bin/21692 by bqt@@Krille.Update.UU.SE. * Fix typos accidentally introduced in rev 1.70 as part of the large number support. (NetBSD yacc didn't barf on these, although Solaris and HP/UX's did...) * Don't declare "yylex()" static; AFAICT it shouldn't be, and it causes build problems with the output of some versions of yacc. * Use sysconf(_SC_LOGIN_NAME_MAX) to determine the length of login names, rather than assuming LOGIN_NAME_MAX. Based on patch from Garrett Wollman via David O'Brien (both at FreeBSD.org) * netbsd.org->NetBSD.org * Move Jason Downs's code from a 4-clause to a 3-clause licence by removing the advertising clause. Diffs provided in PR 22410 by Joel Baker, confirmed to the board by Jason Downs. With additional thanks to Jason Thorpe. @ text @@