From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 16 18:50:02 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CC27516A407 for ; Mon, 16 Apr 2007 18:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id AC39313C48A for ; Mon, 16 Apr 2007 18:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l3GIo2hC081450 for ; Mon, 16 Apr 2007 18:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l3GIo2VB081449; Mon, 16 Apr 2007 18:50:02 GMT (envelope-from gnats) Resent-Date: Mon, 16 Apr 2007 18:50:02 GMT Resent-Message-Id: <200704161850.l3GIo2VB081449@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, Zhang Weiwu Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 141AD16A400 for ; Mon, 16 Apr 2007 18:48:14 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 0371513C4AD for ; Mon, 16 Apr 2007 18:48:14 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l3GImDl3094629 for ; Mon, 16 Apr 2007 18:48:13 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l3GIhCHr093732; Mon, 16 Apr 2007 18:43:12 GMT (envelope-from nobody) Message-Id: <200704161843.l3GIhCHr093732@www.freebsd.org> Date: Mon, 16 Apr 2007 18:43:12 GMT From: Zhang Weiwu To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: misc/111715: request ftpd conform to RFC 2640 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2007 18:50:02 -0000 >Number: 111715 >Category: misc >Synopsis: request ftpd conform to RFC 2640 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 16 18:50:02 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Zhang Weiwu >Release: FreeBSD 6.1 Stable RELEASE >Organization: Real Softservice >Environment: FreeBSD exupery.realss.com 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Sun Dec 3 00:54:09 CST 2006 root@hatch.realss.com:/usr/obj/usr/src/sys/HATCH i386 >Description: Compare to those who only use English for a life time, probably we Asian users feel much more painful for character-set issue. To Asian users the UTF8 compliance as defined in RFC2640 is very important. As FreeBSD is an international project, UTF8 and related RFC compliance is AFAIK basic requirement. The attached path added an option -8 to ftpd, when used, it indicate the file system on server is using UTF-8 and the FTP client (e.g. smart ftp, filezilla, lftp, gftp ...) should convert the filenames and path names to local character set (which they do fine). FTP server tell client to do character conversion if necessary by including "UTF8" in FEAT. RFC2640 is the only way to make international ftp server: it is the only standard way to deliver non-latin filenames to different OSs. a.k.a. Suppose you set up an FTP server and you want users use the Chinese file names for both Simplified Chinese version of Windows user and Traditional Chinese version of Windows. P.S. RFC 2640 is based on RFC2389 which also gets implemented here. Although I tried my best compare the command-set of FreeBSD ftpd and RFC959 to implementation RFC2389, the implementation of RFC2389 may still be incorrect. >How-To-Repeat: >Fix: See my patch. I don't have FreeBSD 6.2 to try (and upgrade is not easy on my fully loaded server) and hope this patch can be applied to 6.2's ftpd directly. Patch attached with submission follows: diff -u ftpd.FreeBSD-6.1/ftpcmd.y ftpd/ftpcmd.y --- ftpd.FreeBSD-6.1/ftpcmd.y Thu Nov 18 21:46:29 2004 +++ ftpd/ftpcmd.y Mon Apr 16 19:27:31 2007 @@ -95,6 +95,7 @@ extern int usedefault; extern char tmpline[]; extern int readonly; +extern int utf8_mode; extern int noepsv; extern int noretr; extern int noguestretr; @@ -135,7 +136,7 @@ ABOR DELE CWD LIST NLST SITE STAT HELP NOOP MKD RMD PWD CDUP STOU SMNT SYST SIZE MDTM - LPRT LPSV EPRT EPSV + LPRT LPSV EPRT EPSV FEAT UMASK IDLE CHMOD MDFIVE @@ -687,6 +688,16 @@ if ($4 != NULL) free($4); } + | FEAT CRLF + { + lreply(211, "Features:"); + printf(" EPSV\r\n"); + printf(" EPRT\r\n"); + printf(" MDTM\r\n"); + printf(" SIZE\r\n"); + if (utf8_mode) printf(" UTF8\r\n"); + reply(211, "End"); + } | SYST check_login CRLF { if ($2) { @@ -1112,6 +1123,7 @@ { "NLST", NLST, OSTR, 1, "[ path-name ]" }, { "SITE", SITE, SITECMD, 1, "site-cmd [ arguments ]" }, { "SYST", SYST, ARGS, 1, "(get type of operating system)" }, + { "FEAT", FEAT, ARGS, 1, "(get features supported)" }, { "STAT", STAT, OSTR, 1, "[ path-name ]" }, { "HELP", HELP, OSTR, 1, "[ ]" }, { "NOOP", NOOP, ARGS, 1, "" }, diff -u ftpd.FreeBSD-6.1/ftpd.8 ftpd/ftpd.8 --- ftpd.FreeBSD-6.1/ftpd.8 Sun Jan 29 21:21:05 2006 +++ ftpd/ftpd.8 Mon Apr 16 20:03:35 2007 @@ -40,7 +40,7 @@ .Nd Internet File Transfer Protocol server .Sh SYNOPSIS .Nm -.Op Fl 46ADdEhMmOoRrSUvW +.Op Fl 468ADdEhMmOoRrSUvW .Op Fl l Op Fl l .Op Fl a Ar address .Op Fl P Ar port @@ -78,6 +78,11 @@ is specified, accept connections via .Dv AF_INET6 socket. +.It Fl 8 +Server is running in UTF-8 mode, an RFC2640 compliant client should convert +all paths and messages from server from UTF-8 to client's local character-set. +Note enalbing this option does not make server do any filesystem encoding +conversion, it only tell client to do so. .It Fl A Allow only anonymous ftp access. .It Fl a @@ -250,6 +255,7 @@ .It DELE Ta "delete a file [RW]" .It EPRT Ta "specify data connection port, multiprotocol" .It EPSV Ta "prepare for server-to-server transfer, multiprotocol" +.It FEAT Ta "give server feature information" .It HELP Ta "give help information" .It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA" .It LPRT Ta "specify data connection port, multiprotocol" diff -u ftpd.FreeBSD-6.1/ftpd.c ftpd/ftpd.c --- ftpd.FreeBSD-6.1/ftpd.c Thu Mar 9 17:12:44 2006 +++ ftpd/ftpd.c Tue Apr 17 01:26:06 2007 @@ -128,6 +128,7 @@ int restricted_data_ports = 1; int paranoid = 1; /* be extra careful about security */ int anon_only = 0; /* Only anonymous ftp allowed */ +int utf8_mode = 0; /* server file system is in UTF-8 */ int guest; int dochroot; char *chrootdir; @@ -308,7 +309,7 @@ openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); while ((ch = getopt(argc, argv, - "46a:AdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) { + "468a:AdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) { switch (ch) { case '4': family = (family == AF_INET6) ? AF_UNSPEC : AF_INET; @@ -316,6 +317,10 @@ case '6': family = (family == AF_INET) ? AF_UNSPEC : AF_INET6; + break; + + case '8': + utf8_mode = 1; break; case 'a': >Release-Note: >Audit-Trail: >Unformatted: