summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-28 20:54:28 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-28 20:54:28 (GMT)
commitc33e077838c8fee729c726f59c441555847b07e6 (patch)
tree7ad1855e814fcaa9e7f0a0130680de9f574a5dc4 /Lib
parent556026967563ca59a0531bcb8a510dfc00a86635 (diff)
downloadcpython-c33e077838c8fee729c726f59c441555847b07e6.zip
cpython-c33e077838c8fee729c726f59c441555847b07e6.tar.gz
cpython-c33e077838c8fee729c726f59c441555847b07e6.tar.bz2
SF patch #497420 (Eduardo PĂ©rez): ftplib: ftp anonymous password
Instead of sending the real user and host, use "anonymous@" (i.e. no host name at all!) as the default anonymous FTP password. This avoids privacy violations.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ftplib.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index a176a87..cf1f32f 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -351,19 +351,14 @@ class FTP:
if not passwd: passwd = ''
if not acct: acct = ''
if user == 'anonymous' and passwd in ('', '-'):
- # get fully qualified domain name of local host
- thishost = socket.getfqdn()
- try:
- if os.environ.has_key('LOGNAME'):
- realuser = os.environ['LOGNAME']
- elif os.environ.has_key('USER'):
- realuser = os.environ['USER']
- else:
- realuser = 'anonymous'
- except AttributeError:
- # Not all systems have os.environ....
- realuser = 'anonymous'
- passwd = passwd + realuser + '@' + thishost
+ # If there is no anonymous ftp password specified
+ # then we'll just use anonymous@
+ # We don't send any other thing because:
+ # - We want to remain anonymous
+ # - We want to stop SPAM
+ # - We don't want to let ftp sites to discriminate by the user,
+ # host or country.
+ passwd = passwd + 'anonymous@'
resp = self.sendcmd('USER ' + user)
if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
if resp[0] == '3': resp = self.sendcmd('ACCT ' + acct)