Bug 60834 - [patch] ftpd(8) send_data()+oldway: anonymous transfer not logged if client drops conn.
Summary: [patch] ftpd(8) send_data()+oldway: anonymous transfer not logged if client d...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.9-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-01-02 20:50 UTC by Alexander Melkov
Modified: 2022-10-17 12:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Melkov 2004-01-02 20:50:07 UTC
Ftpd sends a file using 'oldway' (not sendfile), when sendfile is 
not available, for example, the file is on a mounted nfs or smbfs
filesystem.
If the client ungracefully terminates the connection, ftpd receives a
signal and dies, so the transfer does not appear in /var/log/ftpd.

Fix: 

ftpd.c is 1.62.2.51
melkov:/usr/src/libexec/ftpd# diff ftpd.c.orig ftpd.c
222a223,227
> char *xfer_name;           /* to be able to call logxfer() from dologout() */
> off_t xfer_size;
> time_t xfer_start;
> int xfer_log_progress = 0; /* whether transfer is in progress */
> 
264c269
< static void      logxfer __P((char *, off_t, time_t));
---
> static void      logxfer __P((void));
1655a1661,1664
> 	xfer_name = name;
> 	xfer_size = st.st_size;
> 	xfer_start = start;
> 	xfer_log_progress = cmd == 0 && guest && stats;
1657a1667
> 	xfer_log_progress = 0;
1659c1669
< 		logxfer(name, st.st_size, start);
---
> 		logxfer();
2604a2615,2620
> 
> 	if (statfd >= 0 && xfer_log_progress) {
> 		xfer_log_progress = 0;
> 		logxfer();
> 	}
> 
3140,3143c3156
< logxfer(name, size, start)
< 	char *name;
< 	off_t size;
< 	time_t start;
---
> logxfer()
3153,3154c3166,3167
< 			path, name, (long long)size,
< 			(long)(now - start + (now == start)));
---
> 			path, xfer_name, (long long)xfer_size,
> 			(long)(now - xfer_start + (now == xfer_start)));
How-To-Repeat: (a)
run /usr/libexec/ftpd -ADllS

create /var/log/ftpd file

Mount a NFS or SMBFS filesystem under anonymous ftp root.
Get a file from that filesystem via some ftp client.
While file transfer is in progress, terminate the ftp client.
See tail /var/log/ftpd

(b)
Look into ftpd.c file
- at send_data() function, label oldway:.
- at lostconn(), sigquit() and dologout() functions.
The problem should be apparent :)
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:19 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:36:09 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>