~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-09-07 14:58:28 UTC
  • mfrom: (2804.1.1 bzr.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070907145828-hjh5941jv7y8d9z8
Fix bug #137044: ftp password handling broken

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
            connection = ftplib.FTP()
131
131
            connection.connect(host=self._host, port=self._port)
132
132
            if self._user and self._user != 'anonymous' and \
133
 
                    password is not None: # '' is a valid password
 
133
                    password is None: # '' is a valid password
134
134
                get_password = bzrlib.ui.ui_factory.get_password
135
135
                password = get_password(prompt='FTP %(user)s@%(host)s password',
136
136
                                        user=self._user, host=self._host)
635
635
 
636
636
        def __init__(self, root):
637
637
            self.root = root
 
638
            # If secured_user is set secured_password will be checked
 
639
            self.secured_user = None
 
640
            self.secured_password = None
638
641
 
639
642
        def authorize(self, channel, username, password):
640
643
            """Return (success, reply_string, filesystem)"""
647
650
            else:
648
651
                channel.read_only = 0
649
652
 
650
 
            return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
 
653
            # Check secured_user if set
 
654
            if (self.secured_user is not None
 
655
                and username == self.secured_user
 
656
                and password != self.secured_password):
 
657
                return 0, 'Password invalid.', None
 
658
            else:
 
659
                return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
651
660
 
652
661
 
653
662
    class ftp_channel(medusa.ftp_server.ftp_channel):