Bug 158234

Summary: ftp can't connect to servers in passive mode
Product: [Fedora] Fedora Reporter: Nalin Dahyabhai <nalin>
Component: ftpAssignee: Jiri Ryska <jryska>
Status: CLOSED RAWHIDE QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: jakub, jorton, mitr, roland
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.17-26 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-05-24 20:21:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 136450    
Attachments:
Description Flags
patch to existing patch to call connect() with correct values none

Description Nalin Dahyabhai 2005-05-19 19:26:20 UTC
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.

Comment 1 Nalin Dahyabhai 2005-05-19 19:26:20 UTC
Created attachment 114576 [details]
patch to existing patch to call connect() with correct values

Comment 2 Miloslav Trmač 2005-05-21 10:07:47 UTC
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


Comment 3 Warren Togami 2005-05-23 03:18:25 UTC
ping glibc guys, possible glibc involvement?

Comment 4 Jakub Jelinek 2005-05-23 07:36:06 UTC
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.

Comment 5 Joe Orton 2005-05-23 15:11:15 UTC
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.

Comment 6 Miloslav Trmač 2005-05-24 20:21:30 UTC
Reproduced - this check is only in SELinux (and only for TCP).
Fixed in ftp-0.17-26, thanks!