4udak / pyftpdlib

Automatically exported from code.google.com/p/pyftpdlib
Other
1 stars 1 forks source link

file transfer problem #145

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
What is the expected output? What do you see instead?

See script and session information below.

What version of pyftpdlib are you using? The latest; just downloaded.
On what operating system? MacOSX 10.5
Which Python version?  Python 2.5

Please provide any additional information below.

"""

# pyftpd.py

This is a script I'm trying to use run the pyftplib module.  I have included 
information below on the problems I'm having with it.

"""

from pyftpdlib import ftpserver # http://code.google.com/p/pyftpdlib/
homedir = '/Users/sg'
username = 'user'
password = '12345'
port = 2021
ip = "127.0.0.1"

authorizer = ftpserver.DummyAuthorizer()
authorizer.add_user(username, password, homedir, perm="elradfmw")
authorizer.add_anonymous(homedir)

"""
Read permissions:

    "e" = change directory (CWD command)
    "l" = list files (LIST, NLST, STAT, MLSD, MLST commands)
    "r" = retrieve file from the server (RETR command)

Write permissions

    "a" = append data to an existing file (APPE command)
    "d" = delete file or directory (DELE, RMD commands)
    "f" = rename file or directory (RNFR, RNTO commands)
    "m" = create directory (MKD command)
    "w" = store a file to the server (STOR, STOU commands)
"""

handler = ftpserver.FTPHandler
handler.authorizer = authorizer
address = (ip, port)
ftpd = ftpserver.FTPServer(address, handler)

print "Access the server with these commands:"
print
print "telnet " + ip + " "+ str(port)
print "user " + username
print "pass " + password
print
print "Note: Ports under 1024 will require root."

ftpd.serve_forever()

"""

DESCRIPTION OF THE PROBLEM.

While get and put are not available, but these are RETR, STOR and STOU.  
Unfortunately, they do not seem to be working for me.

Meanwhile, I am able to make directories with MKD and change to them with CWD.  
This suggests permissions are working fine.

I noticed some "Connection refused" messages below.  I'm not sure what that 
means, but this may be an indication of the source of the problem.

Here's an example session to demonstrate the frustrations I'm having.

The directories involved:  /tmp/ and ~/

Before telnetting in, let me show which files I'm planning to use:

sg:tmp sg$ ls ./play.py
./play.py
sg:tmp sg$ # next dir is 'server' dir
sg:tmp sg$ ls ~/play.py
ls: /Users/sg/play.py: No such file or directory
sg:tmp sg$ #  so the server doesn't have that file...but it does have spam.log
sg:tmp sg$ ls spam.log
ls: spam.log: No such file or directory
sg:tmp sg$ ls ~/spam.log
/Users/sg/spam.log

Here's the client-side telnet connection:

sg:tmp sg$ # so now we will try to connect to the server
sg:tmp sg$ telnet localhost 2021
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 pyftpdlib 0.5.2 ready.
retr spam.log
530 Log in with USER and PASS first.
user user
331 Username ok, send password.
pass 12345
230 Login successful.
retr spam.log
150 File status okay. About to open data connection.

500 Command "" not understood.
# what happened???
500 Command "#" not understood.
stor play.py
150 File status okay. About to open data connection.

500 Command "" not understood.
# what happened?  Apparently nothing, once again
500 Command "#" not understood.
stou play.py
150 FILE: play.py.i0R4XN
quit
221 Goodbye.
Connection closed by foreign host.
sg:tmp sg$ # play.py and spam.log are both very small text files.  I gave them 
plenty of time to be transferred, but nothing happened.
sg:tmp sg$ #  actually, an empty file named "play.py" was created on the 
'server'
sg:tmp sg$

Here's what I'm seeing on the 'server' side:

[]127.0.0.1:61704 Connected.
127.0.0.1:61704 ==> 220 pyftpdlib 0.5.2 ready.
127.0.0.1:61704 <== retr spam.log
127.0.0.1:61704 ==> 530 Log in with USER and PASS first.
127.0.0.1:61704 <== user user
127.0.0.1:61704 ==> 331 Username ok, send password.
127.0.0.1:61704 <== pass ******
127.0.0.1:61704 ==> 230 Login successful.
[user]@127.0.0.1:61704 User user logged in.
127.0.0.1:61704 <== retr spam.log
[user]@127.0.0.1:61704 OK RETR "/spam.log". Download starting.
127.0.0.1:61704 ==> 150 File status okay. About to open data connection.
127.0.0.1:61704 <==
127.0.0.1:61704 ==> 500 Command "" not understood.
127.0.0.1:61704 <== # what happened???
127.0.0.1:61704 ==> 500 Command "#" not understood.
127.0.0.1:61704 <== stor play.py
[user]@127.0.0.1:61704 OK STOR "/play.py". Upload starting.
127.0.0.1:61704 ==> 150 File status okay. About to open data connection.
127.0.0.1:61704 <==
127.0.0.1:61704 ==> 500 Command "" not understood.
127.0.0.1:61704 <== # what happened?  Apparently nothing, once again
127.0.0.1:61704 ==> 500 Command "#" not understood.
127.0.0.1:61704 <== stou play.py
[user]@127.0.0.1:61704 OK STOU "play.py.i0R4XN". Upload starting.
127.0.0.1:61704 ==> 150 FILE: play.py.i0R4XN
127.0.0.1:61704 <== quit
127.0.0.1:61704 ==> 221 Goodbye.
[user]@127.0.0.1:61704 Disconnected.

"""

Original issue reported on code.google.com by shane.ge...@gmail.com on 12 Nov 2010 at 10:14

GoogleCodeExporter commented 9 years ago
The server log is pretty self explanatory.
You're sending empty strings like "" or "# what happened???" to the server 
which obviously responds with "500 command "" not understood"

That's because you're using telnet and you can't download a file via FTP by 
using telnet client alone. You have to use an FTP client.
Please, next time use the mailing list for these kind of problems.
Issue tracker is for signaling bugs.

Original comment by g.rodola on 12 Nov 2010 at 10:33