Ticket #3984: 3984-sshpublickeydatabase-userdir-lookup.patch

File 3984-sshpublickeydatabase-userdir-lookup.patch, 3.5 KB (added by esteve, 8 years ago)
  • twisted/conch/checkers.py

    # Bazaar merge directive format 2 (Bazaar 0.90)
    # revision_id: esteve@fluidinfo.com-20090827160102-bjc0vdguiw0uddms
    # target_branch: file:///home/esteve/bzr-projects/twisted/trunk/
    # testament_sha1: 73eecdcfb955d6b16c7bc5ad0bca872b483d4010
    # timestamp: 2009-08-27 18:05:36 +0200
    # base_revision_id: svn-v4:bbbe8e31-12d6-0310-92fd-\
    #   ac37d47ddeeb:trunk:27242
    # 
    # Begin patch
    === modified file 'twisted/conch/checkers.py'
     
    132132        Retrieve the keys of the user specified by the credentials, and check
    133133        if one matches the blob in the credentials.
    134134        """
    135         sshDir = os.path.expanduser(
    136             os.path.join("~", credentials.username, ".ssh"))
     135        sshDir = os.path.join(
     136            os.path.expanduser("~" + credentials.username), ".ssh")
     137
    137138        if sshDir.startswith('~'): # didn't expand
    138139            return False
    139140        uid, gid = os.geteuid(), os.getegid()
  • twisted/conch/test/test_checkers.py

    === modified file 'twisted/conch/test/test_checkers.py'
     
    4444
    4545    def setUp(self):
    4646        self.checker = SSHPublicKeyDatabase()
    47         self.sshDir = FilePath(self.mktemp())
     47        self.sshDir = FilePath(os.path.join(self.mktemp(), ".ssh"))
    4848        self.sshDir.makedirs()
    4949
    5050        self.key1 = base64.encodestring("foobar")
     
    5252        self.content = "t1 %s foo\nt2 %s egg\n" % (self.key1, self.key2)
    5353
    5454        self.mockos = MockOS()
    55         self.mockos.path = self.sshDir.path
     55        self.mockos.path = self.sshDir.parent().path
    5656        self.patch(os.path, "expanduser", self.mockos.expanduser)
    5757        self.patch(pwd, "getpwnam", self.mockos.getpwnam)
    5858        self.patch(os, "seteuid", self.mockos.seteuid)