From owner-freebsd-bugs@FreeBSD.ORG Sun Aug 3 13:10:14 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AC0A137B401 for ; Sun, 3 Aug 2003 13:10:14 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 226A643FCB for ; Sun, 3 Aug 2003 13:10:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h73KACUp012815 for ; Sun, 3 Aug 2003 13:10:12 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h73KACHg012814; Sun, 3 Aug 2003 13:10:12 -0700 (PDT) Resent-Date: Sun, 3 Aug 2003 13:10:12 -0700 (PDT) Resent-Message-Id: <200308032010.h73KACHg012814@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Lukas Ertl Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8BB2637B401 for ; Sun, 3 Aug 2003 13:05:00 -0700 (PDT) Received: from mailbox.univie.ac.at (mailbox.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F51243F75 for ; Sun, 3 Aug 2003 13:04:59 -0700 (PDT) (envelope-from le@univie.ac.at) Received: from korben.in.tern (adslle.cc.univie.ac.at [131.130.102.11]) by mailbox.univie.ac.at (8.12.2/8.12.2) with ESMTP id h73K4eMP035448 for ; Sun, 3 Aug 2003 22:04:48 +0200 Received: from korben.in.tern (korben.in.tern [127.0.0.1]) by korben.in.tern (8.12.9/8.12.9) with ESMTP id h73K4bPE014106 for ; Sun, 3 Aug 2003 22:04:37 +0200 (CEST) (envelope-from le@korben.in.tern) Received: (from le@localhost) by korben.in.tern (8.12.9/8.12.9/Submit) id h73K4aIC014105; Sun, 3 Aug 2003 22:04:36 +0200 (CEST) (envelope-from le) Message-Id: <200308032004.h73K4aIC014105@korben.in.tern> Date: Sun, 3 Aug 2003 22:04:36 +0200 (CEST) From: Lukas Ertl To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/55215: [PATCH] add wu-ftpd style xferlog format to libexec/ftpd X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Lukas Ertl List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Aug 2003 20:10:15 -0000 >Number: 55215 >Category: bin >Synopsis: [PATCH] add wu-ftpd style xferlog format to libexec/ftpd >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Aug 03 13:10:12 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Lukas Ertl >Release: FreeBSD 5.1-CURRENT i386 >Organization: Vienna University Computer Center >Environment: System: FreeBSD korben 5.1-CURRENT FreeBSD 5.1-CURRENT #22: Sun Aug 3 14:25:10 CEST 2003 le@korben:/usr/obj/usr/src/sys/KORBEN i386 >Description: The -S option to ftpd lets the daemon log all anonymous file transfers to /var/log/ftpd, but in a somewhat antiquated format. The attached patch adds an option -x, which changes this output format to wu-ftpd style "xferlog" format, which can be processed by analysis tools like webalizer et. al. >How-To-Repeat: >Fix: --- ftpd.diff begins here --- Index: libexec/ftpd/ftpd.8 =================================================================== RCS file: /usr/local/bsdcvs/src/libexec/ftpd/ftpd.8,v retrieving revision 1.64 diff -u -u -r1.64 ftpd.8 --- libexec/ftpd/ftpd.8 8 Jun 2003 12:39:17 -0000 1.64 +++ libexec/ftpd/ftpd.8 3 Aug 2003 19:59:19 -0000 @@ -40,7 +40,7 @@ .Nd Internet File Transfer Protocol server .Sh SYNOPSIS .Nm -.Op Fl 46ADdEhMmOoRrSUvW +.Op Fl 46ADdEhMmOoRrSUvWx .Op Fl l Op Fl l .Op Fl a Ar address .Op Fl P Ar port @@ -210,6 +210,13 @@ .It Fl W Do not log FTP sessions to .Pa /var/log/wtmp . +.It Fl x +Like +.Fl S , +but the output has wu-ftpd style +.Dq xferlog +format, which can be processed with logfile analysis programs like +.Pa ports/www/webalizer . .El .Pp The file Index: libexec/ftpd/ftpd.c =================================================================== RCS file: /usr/local/bsdcvs/src/libexec/ftpd/ftpd.c,v retrieving revision 1.145 diff -u -u -r1.145 ftpd.c --- libexec/ftpd/ftpd.c 9 Jul 2003 12:46:24 -0000 1.145 +++ libexec/ftpd/ftpd.c 3 Aug 2003 15:42:50 -0000 @@ -131,6 +131,7 @@ int dochroot; int dowtmp = 1; int stats; +int xferlogstats; int statfd = -1; int type; int form; @@ -301,7 +302,7 @@ while ((ch = getopt(argc, argv, - "46a:AdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) { + "46a:AdDEhlmMoOp:P:rRSt:T:u:UvWx")) != -1) { switch (ch) { case '4': enable_v4 = 1; @@ -412,6 +413,11 @@ dowtmp = 0; break; + case 'x': + stats++; + xferlogstats++; + break; + default: warnx("unknown flag -%c ignored", optopt); break; @@ -3133,10 +3139,19 @@ if (statfd >= 0 && getwd(path) != NULL) { time(&now); - snprintf(buf, sizeof(buf), "%.20s!%s!%s!%s/%s!%qd!%ld\n", - ctime(&now)+4, ident, remotehost, - path, name, (long long)size, - (long)(now - start + (now == start))); + if (xferlogstats > 0) { + snprintf(buf, sizeof(buf), + "%.24s %ld %s %qd %s/%s %s _ o a %s ftp 1 * %s\n", + ctime(&now), (long)(now - start + (now == start)), + remotehost, (long long)byte_count, path, name, + type == TYPE_A ? "a" : "b", ident, + byte_count == size ? "c" : "i"); + } else { + snprintf(buf, sizeof(buf), "%.20s!%s!%s!%s/%s!%qd!%ld\n", + ctime(&now)+4, ident, remotehost, + path, name, (long long)size, + (long)(now - start + (now == start))); + } write(statfd, buf, strlen(buf)); } } --- ftpd.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: