Bug 158234 - ftp can't connect to servers in passive mode
ftp can't connect to servers in passive mode
Product: Fedora
Classification: Fedora
Component: ftp (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jiri Ryska
Ben Levenson
Depends On:
Blocks: FC4Blocker
  Show dependency treegraph
Reported: 2005-05-19 15:26 EDT by Nalin Dahyabhai
Modified: 2007-11-30 17:11 EST (History)
4 users (show)

See Also:
Fixed In Version: 0.17-26
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-05-24 16:21:30 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patch to existing patch to call connect() with correct values (2.30 KB, patch)
2005-05-19 15:26 EDT, Nalin Dahyabhai
no flags Details | Diff

  None (edit)
Description Nalin Dahyabhai 2005-05-19 15:26:20 EDT
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):

How reproducible:

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 15:26:20 EDT
Created attachment 114576 [details]
patch to existing patch to call connect() with correct values
Comment 2 Miloslav Trmač 2005-05-21 06:07:47 EDT
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).

kernel-2.6.11-1.1276_FC4 and kernel-2.6.11-1.1323_FC4
Comment 3 Warren Togami 2005-05-22 23:18:25 EDT
ping glibc guys, possible glibc involvement?
Comment 4 Jakub Jelinek 2005-05-23 03:36:06 EDT
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 11:11:15 EDT
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 16:21:30 EDT
Reproduced - this check is only in SELinux (and only for TCP).
Fixed in ftp-0.17-26, thanks!

Note You need to log in before you can comment on or make changes to this bug.