]> granicus.if.org Git - python/commitdiff
SF patch #497420 (Eduardo Pérez): ftplib: ftp anonymous password
authorGuido van Rossum <guido@python.org>
Fri, 28 Dec 2001 20:54:28 +0000 (20:54 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 28 Dec 2001 20:54:28 +0000 (20:54 +0000)
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.

Doc/lib/libftplib.tex
Lib/ftplib.py
Misc/ACKS

index 0d0d7008420b604a176225b7b8f2cae36d98cbcf..d4851ab2cf5227faed5d2b8a8f24ee40fd00ec6f 100644 (file)
@@ -20,7 +20,7 @@ Here's a sample session using the \module{ftplib} module:
 \begin{verbatim}
 >>> from ftplib import FTP
 >>> ftp = FTP('ftp.cwi.nl')   # connect to host, default port
->>> ftp.login()               # user anonymous, passwd user@hostname
+>>> ftp.login()               # user anonymous, passwd anonymous@
 >>> ftp.retrlines('LIST')     # list directory contents
 total 24418
 drwxrwsr-x   5 ftp-usr  pdmaint     1536 Mar 20 09:48 .
@@ -121,10 +121,7 @@ Log in as the given \var{user}.  The \var{passwd} and \var{acct}
 parameters are optional and default to the empty string.  If no
 \var{user} is specified, it defaults to \code{'anonymous'}.  If
 \var{user} is \code{'anonymous'}, the default \var{passwd} is
-\samp{\var{realuser}@\var{host}} where \var{realuser} is the real user
-name (glanced from the \envvar{LOGNAME} or \envvar{USER} environment
-variable) and \var{host} is the hostname as returned by
-\function{socket.gethostname()}.  This function should be called only
+\code{'anonymous@'}.  This function should be called only
 once for each instance, after a connection has been established; it
 should not be called at all if a host and user were given when the
 instance was created.  Most FTP commands are only allowed after the
index a176a8737036b6278b59ecfbb3b5d082151080a2..cf1f32fe724fa4446e7bbbd11df7f78efc88a6cf 100644 (file)
@@ -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)
index 0d1e2c518bedc655c42d8fe7536609505d726de5..6f647243de13749f146046a906d007fef925ac52 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -330,6 +330,7 @@ Randy Pausch
 Marcel van der Peijl
 Samuele Pedroni
 Steven Pemberton
+Eduardo Pérez
 Tim Peters
 Chris Petrilli
 Geoff Philbrick