PDA

View Full Version : ioftpd LIST output format


Phantazm
10-29-2003, 07:35 PM
I've noticed a lil variation with ioftpd comparing to every other ftpd i've tested. (well real old windows ftpd's doesnt count)

All ftpd's have a certan amount of fields/chars in the dirlist.
So if i use some kinda scripting it's pretty easy for me to determine files and folders.
So far i've tested the following ftpd's


glftpd
proftpd
pure-ftpd
vftpd
G6 (Bulletproof) ftpd
serv-u
raiden ftpd


Everyone of them works the same way

The code i use is the following test string (some more to it but this is the important part.)
it knows that after 55 chars the foldername begins.
It works on all mentioned ftpd's except for ioftpd.
That makes one wonder why ioftpd is breaking a standard or is it just pure luck that the others are simular :)


Snippet of my perl code:

my @test = $ftp_a->dir;
my @dirs;
my @files;

foreach (@test) {
if (substr($_,0,1) eq "d") { push (@dirs,$_); }
else { push (@files,$_); }
}

my @dirnames;
foreach (@dirs) {
push (@dirnames,substr($_,55));
}

my @filnames;
foreach (@files) {
push (@filnames,substr($_,55));
}

YES there are probably ways to get around this with other coding but the thing is that if ioftpd doesnt follow a certain standard/rfc there might come up more problems later on.

Is this a thing thats goin to be changed in ioftpd or am i totally lost here and should shove my code somewhere hehe.

Would be really nice with some comments so that i know if i should go change my entire code or there will be a update on ioftpd :)

Thats about it

Peace!

dasOp
10-29-2003, 08:14 PM
Hate to ruin your fun, but the LIST-parsing code of a graphical ftp client is usually the hairiest part of it.

Reason? The ftp-protocol rfc's do not specify the format. At all.
So servers are free to do exactly what they want. Nonetheless, these things tend to implicitly standardize themselves anyways, and as things are now, they all resemble the output from unix 'ls'.
The key to parsing em is not to rely on specific character positions but to tokenize the fields as they usually are the same.

darkone
10-29-2003, 09:19 PM
Yep.. iis format is completely different :p that's why there is 'SYST' command. You can expect that user & group names never contain spaces... btw, how does your program handle files larger than 1gb? :)

Phantazm
10-30-2003, 03:31 AM
hehe ok. Well to bad that ioftpd is the only one thats differs from all the others.

Dark.. ppl that have files thats over 1 gb in size should be dragged out back and be executed :D But your probably right it would screw things up to.

Well thanx for the info anyhow :)

anyone got any suggestions on how i could parse the list to make it universal :)

darkone
10-30-2003, 03:38 AM
Use -1 parameter, if you do not want anything other than filenames.. (or NLST)

Phantazm
10-30-2003, 03:43 AM
well nlist and the -1 also give me filenames.

But one could change the parse to read everything that is with *.??? should be a file and the rest dirs. but thats prolly not 100% bulletproof hehe


Just change code in ioftpd thats a quick surgery ;) hehe

FTPServerTools
10-30-2003, 03:57 AM
The LIST reply isnt really in the rfc standards.
Why dont you determine the 55 dynamically? It is quite easy to do and apparently you havent tested all that good also. Make very long user and/or groupnames on the ftpserver and you will see that the LIST output changes in some of the cases you tested.
So my advise: use some intelligent parsing.
dr--r--r-- 1 user group 0 Feb 11 15:50 dirname

Phantazm
10-30-2003, 04:35 AM
changed the code tho this.
it should be quite as good


foreach (@test) {
if ($_ =~ /\....$/i) { push (@files,$_); }
else { push (@dirs,$_); }
}


hopefully no filenames ends with .???

So now i'm pretty happy again :D