Missing the errormessage about "no rights to listing files in a directory"

Aug 31, 2012 at 1:14 PM

Hello,

when i try to listing files from a directory, in which i have absolutely no rights, i expect, that i get the return-code 550 or an other message, which inform me about the missing rights. Unfortunately i get no message about the missing listing-rights. Which other ftp-client i get the message. Is this a bug or a feature for the future  ;-) ?

 

 

With greetings

Coordinator
Aug 31, 2012 at 2:59 PM
What exactly did the server send back? Can you post the transaction log? If a 4xx or 5xx response was given a FtpCommandException should have been thrown. It's hard to say what might have happened without more details.
Aug 31, 2012 at 4:52 PM

Hello,

i use pure ftpd 1.0.35.

I have created a example directory and example user for this posting. In this directory are files and folders. Onyl root has access, not the ftpuser.

The 500 codes meaning Extendet Security is not implemented and unknown command

line 32 means 0 entries (226 0 Einträge gesamt.)

Here is the log :

1 > INFO 220---------- Herzlich willkommen auf Pure-FTPd [privsep] ----------
2 > INFO 220-Sie sind Benutzer 1 von 50 erlaubten.
3 > INFO 220-Lokale Zeit: 18:44. Serverport: 21.
4 > INFO 220-Dies ist ein privates System - Keine anonyme Anmeldung möglich.
5 > INFO 220-Auf diesem Server sind auch IPv6-Verbindungen willkommen
6 > 220 Sie werden nach 15 Minuten Inaktivität getrennt.
7 > 500 Sicherheitserweiterung nicht implementiert.
8 > 500 Sicherheitserweiterung nicht implementiert.
9 > 331 Benutzer Dummy@gmx.de OK. Paßwort erforderlich.
10 > 230 OK. Aktuelles Verzeichnis ist /.
11 > INFO 211-Extensions supported:
12 > INFO  EPRT
13 > INFO  IDLE
14 > INFO  MDTM
15 > INFO  SIZE
16 > INFO  MFMT
17 > INFO  REST STREAM
18 > INFO  MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
19 > INFO  MLSD
20 > INFO  TVFS
21 > INFO  ESTA
22 > INFO  PASV
23 > INFO  EPSV
24 > INFO  SPSV
25 > INFO  ESTP
26 > 211 End.
27 > 200 TYPE ist jetzt ASCII
28 > 500 Unbekannter Befehl.
29 > 227 Entering Passive Mode (192,168,2,203,161,32)
30 > 150 Verbindung akzeptiert.
31 > INFO 226-Options: -a -l
32 > 226 0 Einträge gesamt.
33 > 200 TYPE ist jetzt ASCII
34 > 500 Unbekannter Befehl.
35 > 227 Entering Passive Mode (192,168,2,203,54,209)
36 > 150 Verbindung akzeptiert.
37 > INFO 226-Options: -a -l
38 > 226 0 Einträge gesamt.

Coordinator
Aug 31, 2012 at 5:05 PM
System.Net.FtpClient supports keeping a transaction log of the commands and their responses. I'd like to see exactly what's being executed and the reply, that looks like a like a log from your server and the commands are omitted so I don't really know what was executed where. I see some -a and -l stuff that looks like possible parameters to the LIST command however the default System.Net.FtpClient listing code does not use them. I just double checked the GetRawListing() method in FtpClient and it indeed throws a FtpCommandException() when the command used to get a file listing returns an error response (4xx, 5xx). If you're implemented your own file listing code you need to throw the exception or otherwise handle the error reply yourself. If you're not I need to see some code because I'm at a loss as to why GetRawListing() (which is the base of the GetListing() methods) would not throw an exception when it got a failure reply from the server.
Sep 1, 2012 at 8:04 AM

Good morning.

The linenumbers comes from me. The responsedata is comming from the ResponseReceived Event.

When i use your example-code from the helpfile, i have the same problem .

  try
            {
                using (FtpClient cl = new FtpClient("*****", "*****", "*****"))
                {                
                    cl.FtpLogStream = Console.OpenStandardOutput();
                    cl.FtpLogFlushOnWrite = true;
                    //cl.ResponseReceived += new ResponseReceived(cl_ResponseReceived);
                
                    // example using GetListing()
                    foreach (FtpListItem item in cl.GetListing("/Dummy2/OE220/OE220/Hallo"))
                    {             
                        if (!cl.HasCapability(FtpCapability.MLSD) && cl.HasCapability(FtpCapability.MDTM))
                        {
                            DateTime modify = cl.GetLastWriteTime(string.Format("/Dummy2/OE220/OE220/Hallo{0}", item.Name));

                            if (modify != DateTime.MinValue)
                            {
                                item.Modify = modify;
                            }
                        }
                        Console.WriteLine(item.ToString());
                    }

                    // example using FtpFileSystemObject derivatives
                    using (FtpDirectory dir = new FtpDirectory(cl, "/Dummy2/OE220/OE220/Hallo"))
                    {
                        foreach (FtpDirectory d in dir.Directories)
                        {
                            Console.WriteLine("{0} {1} {2}", d.Name, d.Length, d.LastWriteTime);
                        }

                        foreach (FtpFile f in dir.Files)
                        {
                            Console.WriteLine("{0} {1} {2}", f.Name, f.Length, f.LastWriteTime);
                        }
                    }
                }              
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
            Console.WriteLine("-- PRESS ANY KEY TO CLOSE --");
            Console.ReadKey();
        }

 

Here the output:

> 220---------- Herzlich willkommen auf Pure-FTPd [privsep] ----------
> 220-Sie sind Benutzer 1 von 50 erlaubten.
> 220-Lokale Zeit: 10:01. Serverport: 21.
> 220-Dies ist ein privates System - Keine anonyme Anmeldung möglich.
> 220-Auf diesem Server sind auch IPv6-Verbindungen willkommen
> 220 Sie werden nach 15 Minuten Inaktivität getrennt.
< AUTH TLS
> 500 Sicherheitserweiterung nicht implementiert.
< AUTH SSL
> 500 Sicherheitserweiterung nicht implementiert.
< USER *****
> 331 Benutzer ***** OK. Paßwort erforderlich.
< PASS [omitted for security]
> 230 OK. Aktuelles Verzeichnis ist /.
< FEAT
> 211-Extensions supported:
>  EPRT
>  IDLE
>  MDTM
>  SIZE
>  MFMT
>  REST STREAM
>  MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
>  MLSD
>  TVFS
>  ESTA
>  PASV
>  EPSV
>  SPSV
>  ESTP
> 211 End.
< TYPE A
> 200 TYPE ist jetzt ASCII
< EPSV
> 500 Unbekannter Befehl.
< PASV
> 227 Entering Passive Mode (****)
< MLSD /Dummy2/OE220/OE220/Hallo
> 150 Verbindung akzeptiert.
> 226-Options: -a -l
> 226 0 Einträge gesamt.
>
< TYPE A
> 200 TYPE ist jetzt ASCII
< EPSV
> 500 Unbekannter Befehl.
< PASV
> 227 Entering Passive Mode (****)
< MLSD /Dummy2/OE220/OE220/Hallo
> 150 Verbindung akzeptiert.
> 226-Options: -a -l
> 226 0 Einträge gesamt.
>
< QUIT
> 221-Tschüß. Transfer: upload 0 und download 0 kbytes.
> 221 Logout.
-- PRESS ANY KEY TO CLOSE --

 

 

 

 

 

Coordinator
Sep 1, 2012 at 11:29 AM
The server replies are 2xx, not 4xx or 5xx. I just tested and this is the same case when using vsFTPd. If the server doesn't send a failure reply code it's outside of my hands. vsFTPd says it failed in the message except it sends a 2xx reply however I will not try to parse the response message to decide if it failed or not, the reply codes are supposed to indicate that.

Coordinator
Sep 1, 2012 at 11:32 AM

Here's an example of what I'm seeing:

< EPSV
> 229 Entering Extended Passive Mode (|||40085|).
< LIST /root/
> 150 Here comes the directory listing.
> 226 Transfer done (but failed to open directory).

Coordinator
Sep 1, 2012 at 11:34 AM

I just tested with transmit (a ftp client on Mac OS X) and it tries to change directory first which fails. Other clients might be doing that. You may want to consider doing that if you want to detect the failure.

Sep 1, 2012 at 2:01 PM

I have loged the transfer with FileZille:

2012-09-01 15:48:53 8016 3 Antwort: 150 Verbindung akzeptiert.
2012-09-01 15:48:53 8016 3 Antwort: 226-Options: -a -l
2012-09-01 15:48:53 8016 3 Antwort: 226 6 Einträge gesamt.
2012-09-01 15:48:53 8016 3 Status: Anzeigen des Verzeichnisinhalts abgeschlossen
2012-09-01 15:48:55 8016 3 Status: Empfange Verzeichnisinhalt...
2012-09-01 15:48:55 8016 3 Befehl: CWD /Dummy2/OE220/3333
2012-09-01 15:48:55 8016 3 Antwort: 550 Kann nicht ins Verzeichnis /Dummy2/OE220/3333 wechseln: Permission denied
2012-09-01 15:48:55 8016 3 Fehler: Verzeichnisinhalt konnte nicht empfangen werden

He get 550 Permission denied ...

Coordinator
Sep 1, 2012 at 2:05 PM
Edited Sep 1, 2012 at 2:11 PM

After filezilla tried to change the directory! Look at the log again, 226 reply form the list command + data connection. The server doesn't error when you try to list a directory you don't have permission to, if you don't like that behavior talk to the author of the server software.

Again, if you want your code to work the same way you need to change the working directory to the directory you want to list first. That is what filezilla does and that makes perfect sense, it's a file manager. When you double click a directory it makes perfect sense for filezilla to change its working directory and then get a file listing. Let me say it one more time so that you understand, if you want your code to work the same then try to change to the directory you're listing first otherwise email the developers of pureftpd and ask them why they don't send a 4xx or 5xx reply when you try to get a file listing of a directory you don't have permission to. There is no bug in System.Net.FtpClient in regards to this issue, it's working exactly the way it was written to work.