Description of problem: When connecting to the data port on a server in passive mode, the ftp client can get EINVAL when it calls connect(). Version-Release number of selected component (if applicable): ftp-0.17-25 How reproducible: Always Steps to Reproduce: 1. Connect to an FTP server using its IPv4 address. Anonymous is fine. 2. Attempt to use the "ls" command. Actual results: 227 Entering Passive Mode (172,16,58,2,201,63) ftp: connect: Invalid argument Expected results: Successful data transfer. Additional info: At line 729 of netkit-ftp.usagi-ipv6.patch, ftp passes the size of a union of a struct sockaddr_in and a sockaddr_in6 to the connect() call as the socket address length, and is rejected. I don't know if this is a recent change in either glibc or the kernel, but fwiw I'm using glibc-2.3.5-6 on kernel-2.6.11-1.1315_FC4smp. Attaching a patch for the patch to pass the size of the right address structure.
Created attachment 114576 [details] patch to existing patch to call connect() with correct values
I can't reproduce this, neither using ftp nor with a minimal test program. (looking at strace of ftp, libc uses sizeof(struct sockaddr_in6) when connecting to AF_INET too). glibc-2.3.5-6 kernel-2.6.11-1.1276_FC4 and kernel-2.6.11-1.1323_FC4
ping glibc guys, possible glibc involvement?
There is none. glibc's connect/accept/listen and other socket calls are either straight syscalls, or trivial wrappers around socketcall syscall. So whether connect succeeds or fails is solely kernel's decision.
Confirmed here with current Raw Hide. Simple repro is: # service vsftpd start # /usr/bin/ftp localhost ... ftp> ls 227 Entering Passive Mode (172,16,18,217,117,95) ftp: connect: Invalid argument confirmed also that it works fine after applying Nalin's patch, which is clearly doing the Right Thing.
Reproduced - this check is only in SELinux (and only for TCP). Fixed in ftp-0.17-26, thanks!