"在ASCII模式&QUOT接受裸换行符;我的FTP服务器上列出目录时警告 [英] "bare linefeeds received in ASCII mode" warning when listing directory on my FTP server
问题描述
我创建一个FTP服务器作为一个学校项目,大部分的命令正在和我差不多钉 PORT
(用于数据传输主动模式)。
使用FTP等一样启动我的服务器:
FTP本地主机4242 //其中4242是上我的服务器是监听的端口
和使用 LS
登录后,我收到一个工作后跟此消息 LS
输出命令:
警告! ASCII模式得到8裸露换行符
文件可能无法正确传输。
块引用>请注意,
FTP
使用LS
时,使用<$ C之前,会自动切换到Active模式$ C>列表命令。是什么错误意味着什么?
全部输出:
200工作模式下启用。
150目录列表。
共有56
drwxrwxr-X 4 kade_c kade_c 4096麦12 15:24。
drwxr-XR-X 38 kade_c kade_c 4096麦12 14:58 ..
drwxrwxr-X 8 kade_c kade_c 4096麦12 git的15:17
-rw-RW-R-- 1 kade_c kade_c 1726麦11的Makefile 10:35
-rw-RW-R-- 1 kade_c kade_c 161迈11 11:43的README.txt
-rwxrwxr-X 1 kade_c kade_c 29368麦12 15:24服务器
drwxrwxr-X 4 kade_c kade_c 4096麦2 18:40 server_src
警告! ASCII模式得到8裸露换行符
文件可能没有正确传送。
226 LIST完成。最后,这里是code,创建,并连接到插座并执行的部分
LS -la
:server_write(客户端,150目录列表\\ r \\ n);
如果(CONNECT_DATA(客户端)== -1)//创建插座和连接到它
{
server_write(客户端,520不可能到达客户端\\ r \\ n);
返回;
}
OFD = xdup(1);
xdup2(客户端 - &GT; data.socket,1);
系统(LS -la);
xdup2(OFD,1);
server_write(客户端,226 LIST完整\\ r \\ n);
CLOSE_DATA(客户端,-1);
解决方案我猜您发送LF的给客户端,客户端(正确)预计CRLF的,并警告那些失踪CR的。
据FTP规范, RFC 959,3.4节。 ,在ASCII模式下,你需要独占CRLF传输模式:
有关规范转移的目的,在发送主机会
转换线或记录外延月底其内部结束
成传送模式的再presentation prescribed 和文件
结构,以及接收主机将执行逆
翻译其内部外延。 ... 尾线在没有ASCII文件
记录结构应标明&LT;&CRLF GT;
块引用>I am creating an FTP server as a school project, most of the commands are working and I almost nailed
PORT
(active mode for data transfer).Launching my server using ftp like such:
ftp localhost 4242 // where 4242 is the port on which my server is listening
And using the command
ls
after logging in, I receive a workingls
output followed by this message:WARNING! 8 bare linefeeds received in ASCII mode File may not have transferred correctly.
Please note that when using
ls
inftp
, it switches automatically to Active Mode before using theLIST
command.What does this error signify?
Full output:
200 Active Mode Enabled. 150 Directory listing. total 56 drwxrwxr-x 4 kade_c kade_c 4096 mai 12 15:24 . drwxr-xr-x 38 kade_c kade_c 4096 mai 12 14:58 .. drwxrwxr-x 8 kade_c kade_c 4096 mai 12 15:17 .git -rw-rw-r-- 1 kade_c kade_c 1726 mai 11 10:35 Makefile -rw-rw-r-- 1 kade_c kade_c 161 mai 11 11:43 README.txt -rwxrwxr-x 1 kade_c kade_c 29368 mai 12 15:24 server drwxrwxr-x 4 kade_c kade_c 4096 mai 2 18:40 server_src WARNING! 8 bare linefeeds received in ASCII mode File may not have transferred correctly. 226 LIST complete.
And finally, here is the part of the code that creates, and connects to the socket and does the
ls -la
:server_write(client, "150 Directory listing.\r\n"); if (connect_data(client) == -1) // Creates socket and connects to it { server_write(client, "520 Impossible to reach client.\r\n"); return; } ofd = xdup(1); xdup2(client->data.socket, 1); system("ls -la"); xdup2(ofd, 1); server_write(client, "226 LIST complete.\r\n"); close_data(client, -1);
解决方案I'd guess that you send LF's to the client, and the client (rightly) expects CRLF's and warns about those missing CR's.
According to FTP specification, RFC 959, section 3.4. Transmission modes, in the ASCII mode, you need to use CRLF exclusively:
For the purpose of standardized transfer, the sending host will translate its internal end of line or end of record denotation into the representation prescribed by the transfer mode and file structure, and the receiving host will perform the inverse translation to its internal denotation. ... End-of-line in an ASCII file with no record structure should be indicated by
<CRLF>
这篇关于&QUOT;在ASCII模式&QUOT接受裸换行符;我的FTP服务器上列出目录时警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!