From: Operating system: Ubuntu 10.04 PHP version: 5.3.2 Package: FTP related Bug Type: Bug Bug description:ftp_connect only uses DNS hostnames
Description: ------------ If "localhost" is present in /etc/hosts but does not resolve via DNS then ftp_c\ onnect will not connect to it. Most well setup DNS systems will have a "localhost." zone that resolves to 127.\ 0.0.1, but this is not compulsory and some ISPs do not do this. It is traditional for UNIX systems to be able to use local names as defined in \ /etc/hosts for basic names resolution before DNS. This bug does not appear to occur in other PHP network functions such as IMAP o\ r SMTP, and did not appear in PHP 5.2.4 on Ubuntu 8.04 (and earlier). I first noticed this bug when I upgrade a mail server from Ubuntu 8.04 to Ubunt\ u 10.04 and the Squirrelmail autorespond plugin (which uses ftp_connect) report\ ed a "failed to connect" error. To replicate this problem you will have to test on a system that does not resol\ ve "localhost" via DNS. Use the "host" command to check you can not do this: -------- $ host -v localhost Trying "localhost.uk.fabit.net" Trying "localhost" Host localhost not found: 3(NXDOMAIN) -------- Test script: --------------- <?php $ftp = ftp_connect($ftphost); if (!$ftp) { print "FTP connection failed"; } ?> Expected result: ---------------- An ftp connection with no error message. Actual result: -------------- No ftp connection attempt and my error message "FTP connection failed". -- Edit bug report at http://bugs.php.net/bug.php?id=52395&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52395&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52395&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52395&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52395&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52395&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52395&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52395&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52395&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52395&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52395&r=support Expected behavior: http://bugs.php.net/fix.php?id=52395&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52395&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52395&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52395&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52395&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52395&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52395&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52395&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52395&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52395&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52395&r=mysqlcfg