Kaydet (Commit) 40b9835e authored tarafından Jack Jansen's avatar Jack Jansen

Always use 'anonymous' if os.environ doesn't exist

üst c39f4f89
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# (FTP), by J. Postel and J. Reynolds # (FTP), by J. Postel and J. Reynolds
# Changes and improvements suggested by Steve Majewski # Changes and improvements suggested by Steve Majewski
# Modified by Jack to work on the mac.
# Example: # Example:
...@@ -220,11 +221,15 @@ class FTP: ...@@ -220,11 +221,15 @@ class FTP:
if not user: user = 'anonymous' if not user: user = 'anonymous'
if user == 'anonymous' and passwd in ('', '-'): if user == 'anonymous' and passwd in ('', '-'):
thishost = socket.gethostname() thishost = socket.gethostname()
if os.environ.has_key('LOGNAME'): try:
realuser = os.environ['LOGNAME'] if os.environ.has_key('LOGNAME'):
elif os.environ.has_key('USER'): realuser = os.environ['LOGNAME']
realuser = os.environ['USER'] elif os.environ.has_key('USER'):
else: realuser = os.environ['USER']
else:
realuser = 'anonymous'
except AttributeError:
# Not all systems have os.environ....
realuser = 'anonymous' realuser = 'anonymous'
passwd = passwd + realuser + '@' + thishost passwd = passwd + realuser + '@' + thishost
resp = self.sendcmd('USER ' + user) resp = self.sendcmd('USER ' + user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment