# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: esteve@fluidinfo.com-20090831175331-f1l7cossz2hd0zz0
# target_branch: ../trunk/
# testament_sha1: eb03d0a4355f7c35562be7a51ee6575b5458dbdb
# timestamp: 2009-08-31 20:00:21 +0200
# base_revision_id: svn-v4:bbbe8e31-12d6-0310-92fd-\
# ac37d47ddeeb:trunk:27242
#
# Begin patch
=== modified file 'twisted/conch/checkers.py'
|
|
|
132 | 132 | Retrieve the keys of the user specified by the credentials, and check |
133 | 133 | if one matches the blob in the credentials. |
134 | 134 | """ |
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 | |
137 | 138 | if sshDir.startswith('~'): # didn't expand |
138 | 139 | return False |
139 | 140 | uid, gid = os.geteuid(), os.getegid() |
=== modified file 'twisted/conch/test/test_checkers.py'
|
|
|
37 | 37 | Tests for L{SSHPublicKeyDatabase}. |
38 | 38 | """ |
39 | 39 | |
| 40 | mockuser = "user" |
| 41 | mockhomedir = "home" |
| 42 | |
40 | 43 | if pwd is None: |
41 | 44 | skip = "Cannot run without pwd module" |
42 | 45 | elif SSHPublicKeyDatabase is None: |
… |
… |
|
44 | 47 | |
45 | 48 | def setUp(self): |
46 | 49 | self.checker = SSHPublicKeyDatabase() |
47 | | self.sshDir = FilePath(self.mktemp()) |
| 50 | |
| 51 | self.mockos = MockOS() |
| 52 | self.mockuserhome = FilePath(self.mktemp()).child( |
| 53 | self.mockhomedir).child(self.mockuser) |
| 54 | self.sshDir = self.mockuserhome.child(".ssh") |
48 | 55 | self.sshDir.makedirs() |
49 | 56 | |
50 | 57 | self.key1 = base64.encodestring("foobar") |
51 | 58 | self.key2 = base64.encodestring("eggspam") |
52 | 59 | self.content = "t1 %s foo\nt2 %s egg\n" % (self.key1, self.key2) |
53 | 60 | |
54 | | self.mockos = MockOS() |
55 | | self.mockos.path = self.sshDir.path |
| 61 | self.mockos.path = self.sshDir.parent().parent().parent().path |
| 62 | self.mockos.users[self.mockuser] = self.mockuserhome.path |
| 63 | |
56 | 64 | self.patch(os.path, "expanduser", self.mockos.expanduser) |
57 | 65 | self.patch(pwd, "getpwnam", self.mockos.getpwnam) |
58 | 66 | self.patch(os, "seteuid", self.mockos.seteuid) |
… |
… |
|
61 | 69 | |
62 | 70 | def _testCheckKey(self, filename): |
63 | 71 | self.sshDir.child(filename).setContent(self.content) |
64 | | user = UsernamePassword("user", "password") |
| 72 | user = UsernamePassword(self.mockuser, "password") |
65 | 73 | user.blob = "foobar" |
66 | 74 | self.assertTrue(self.checker.checkKey(user)) |
67 | 75 | user.blob = "eggspam" |
… |
… |
|
106 | 114 | keyFile.chmod(0777) |
107 | 115 | return savedSeteuid(euid) |
108 | 116 | self.patch(os, "seteuid", seteuid) |
109 | | user = UsernamePassword("user", "password") |
| 117 | user = UsernamePassword(self.mockuser, "password") |
110 | 118 | user.blob = "foobar" |
111 | 119 | self.assertTrue(self.checker.checkKey(user)) |
112 | 120 | self.assertEquals(self.mockos.seteuidCalls, [0, 1, 0, os.getuid()]) |
=== modified file 'twisted/test/test_process.py'
|
|
|
1221 | 1221 | waitChild = None |
1222 | 1222 | euid = 0 |
1223 | 1223 | egid = 0 |
| 1224 | uid = 1237 |
| 1225 | gid = 1235 |
1224 | 1226 | path = None |
| 1227 | users = {} |
1225 | 1228 | |
1226 | 1229 | def __init__(self): |
1227 | 1230 | """ |
… |
… |
|
1370 | 1373 | """ |
1371 | 1374 | Override C{os.getgid}. Return a dumb number. |
1372 | 1375 | """ |
1373 | | return 1235 |
| 1376 | return self.gid |
1374 | 1377 | |
1375 | 1378 | |
1376 | 1379 | def getuid(self): |
1377 | 1380 | """ |
1378 | 1381 | Override C{os.getuid}. Return a dumb number. |
1379 | 1382 | """ |
1380 | | return 1237 |
| 1383 | return self.uid |
1381 | 1384 | |
1382 | 1385 | |
1383 | 1386 | def setuid(self, val): |
… |
… |
|
1454 | 1457 | """ |
1455 | 1458 | Mock C{os.path.expanduser}. |
1456 | 1459 | """ |
1457 | | return self.path |
| 1460 | if not path.startswith('~'): |
| 1461 | return path |
| 1462 | i = path.find('/', 1) |
| 1463 | if i < 0: |
| 1464 | i = len(path) |
| 1465 | if i == 1: |
| 1466 | userdir = self.users.get(self.user) |
| 1467 | else: |
| 1468 | userdir = self.users.get(path[1:i]) |
| 1469 | if userdir is None: |
| 1470 | return path |
| 1471 | userhome = os.path.join(self.path, userdir) |
| 1472 | userhome = userhome.rstrip('/') |
| 1473 | if not os.path.exists(userhome): |
| 1474 | return path |
| 1475 | return userhome + path[i:] |
1458 | 1476 | |
1459 | 1477 | |
1460 | 1478 | def getpwnam(self, user): |