From c33e077838c8fee729c726f59c441555847b07e6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 28 Dec 2001 20:54:28 +0000 Subject: =?UTF-8?q?SF=20patch=20#497420=20(Eduardo=20P=C3=A9rez):=20ftplib?= =?UTF-8?q?:=20ftp=20anonymous=20password?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- Lib/ftplib.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'Lib/ftplib.py') diff --git a/Lib/ftplib.py b/Lib/ftplib.py index a176a87370..cf1f32fe72 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) -- cgit v1.2.1