Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: third_party/twisted_8_1/twisted/conch/openssh_compat/factory.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 from twisted.conch.ssh import keys, factory, common
2 from twisted.python import log
3 import primes
4 import os
5
6 class OpenSSHFactory(factory.SSHFactory):
7 dataRoot = '/usr/local/etc'
8 moduliRoot = '/usr/local/etc' # for openbsd which puts moduli in a different
9 # directory from keys
10 def getPublicKeys(self):
11 ks = {}
12 for file in os.listdir(self.dataRoot):
13 if file[:9] == 'ssh_host_' and file[-8:]=='_key.pub':
14 try:
15 k = keys.getPublicKeyString(self.dataRoot+'/'+file)
16 t = common.getNS(k)[0]
17 ks[t] = k
18 except Exception, e:
19 log.msg('bad public key file %s: %s' % (file,e))
20 return ks
21 def getPrivateKeys(self):
22 ks = {}
23 euid,egid = os.geteuid(), os.getegid()
24 os.setegid(0) # gain priviledges
25 os.seteuid(0)
26 for file in os.listdir(self.dataRoot):
27 if file[:9] == 'ssh_host_' and file[-4:]=='_key':
28 try:
29 k = keys.getPrivateKeyObject(self.dataRoot+'/'+file)
30 t = keys.objectType(k)
31 ks[t] = k
32 except Exception, e:
33 log.msg('bad private key file %s: %s' % (file, e))
34 os.setegid(egid) # drop them just as quickily
35 os.seteuid(euid)
36 return ks
37
38 def getPrimes(self):
39 try:
40 return primes.parseModuliFile(self.moduliRoot+'/moduli')
41 except IOError:
42 return None
43
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698