[Python-checkins] CVS: python/dist/src/Lib ftplib.py,1.61,1.62

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 28 Dec 2001 12:52:55 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv15627

Modified Files:
	ftplib.py 
Log Message:
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.


Index: ftplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** ftplib.py	2001/12/23 13:54:19	1.61
--- ftplib.py	2001/12/28 20:52:52	1.62
***************
*** 352,368 ****
          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
          resp = self.sendcmd('USER ' + user)
          if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
--- 352,363 ----
          if not acct: acct = ''
          if user == 'anonymous' and passwd in ('', '-'):
! 	    # 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)