PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_FTP » Bug #263

Net_FTP listing errors

Details

Submitted2003-11-17 03:22 UTC
Frommattias dot guns at student dot kuleuven dot ac dot be
Assignedtoby
StatusClosed
PackageNet_FTP
PHP Version4.3.2
OSLinux
Roadmaps(Not assigned)

Comments

[2003-11-17 03:22 UTC] mattias dot guns at student dot kuleuven dot ac dot be

Description:
------------
When you use the Net_FTP package to connect to an ftp server,
and you ask for a listing [$ftp->ls($dir)]
This will fail with error: Raw directory-list in wrong format.
if one of the directory's in this listing has a 'sticky bit'
Because the defined constant 'NET_FTP_DIR_EREG' is not set up in a way to recognize the letter 's' in the representation of the properties of a dir (dwrxr-s---)
And apparently there can be a 't' in there too...
[that's all i know about]

The following line (line 11 in Net_FTP 1.2):
define("NET_FTP_DIR_EREG", "([-dl])([rwx-]{9})[ ]*([0-9]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([0-9]*)[ ]*([A-Za-z]+ [0-9: ]*) (.+)", true);

should be changed to:
define("NET_FTP_DIR_EREG", "([-dl])([rwxst-]{9})[ ]*([0-9]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([0-9]*)[ ]*([A-Za-z]+ [0-9: ]*) (.+)", true);

(notice the change from [rwx-] to [rwxst-] )

Once this is fixed, it will still fail, because the server first sais 'total <nr>' before it starts listing..
Net_FTP sees this and stops with an error..

If you look at line 926 and following, u see the problem, it is fixed by adding following 3 lines:
//if server prepends with 'total <nr>' shift it of
if (substr($dir_list[0], 0, 6) == 'total ')
array_shift($dir_list);
<after which starts the foreach>
foreach ($dir_list as $entry) {

u can get the 2 in one patch at:
http://xylofaan.studentenweb.org/pear/Net_FTP_1.2_ls_fix.diff

Reproduce code:
---------------
$ftp = new Net_FTP('ftp.belnet.be', '21');
$ftp->connect();
$ftp->login('anon', 'ymous');
print_r($ftp->ls());

Expected result:
----------------
the listing of the ftp server:
(too much to paste)

Actual result:
--------------
's' sticky bit problem:
(from another server:) string(56) "drwxrwsr-x 8 ftpadm ftpadm 280 Aug 24 12:07 ." Raw directory-list in wrong format.

't' bit problem:
string(63) "d-wx-wx-wt 3 BELNET Archive 512 Nov 17 03:13 incoming" Raw directory-list in wrong format.

'total' problem:
string(8) "total 45" Raw directory-list in wrong format.

[2003-11-28 12:51 UTC] bs at hi dot is

The bits 'S' and 'T' are bits that have to be considered too.