bin/55215: [PATCH] add wu-ftpd style xferlog format to libexec/ftpd
Lukas Ertl
l.ertl at univie.ac.at
Sun Aug 3 13:10:15 PDT 2003
>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 at 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:
More information about the freebsd-bugs
mailing list