/usr/share/pyshared/tryton/fingerprints.py is in tryton-client 2.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import os
from tryton.config import get_config_dir
KNOWN_HOSTS_PATH = os.path.join(get_config_dir(), 'known_hosts')
class Fingerprints(dict):
def __init__(self):
super(Fingerprints, self).__init__()
self.load()
def load(self):
if not os.path.isfile(KNOWN_HOSTS_PATH):
return
with open(KNOWN_HOSTS_PATH) as known_hosts:
for line in known_hosts:
line = line.strip()
try:
host, sha1 = line.split(' ')
except ValueError:
host, sha1 = line, ''
self[host] = sha1
def save(self):
lines = []
with open(KNOWN_HOSTS_PATH, 'w') as known_hosts:
known_hosts.writelines('%s %s' % (host, sha1)
+ os.linesep for host, sha1 in self.iteritems())
def __setitem__(self, key, value):
assert isinstance(key, basestring)
if value:
assert len(value) == 59 # len of formated sha1
else:
value = ''
super(Fingerprints, self).__setitem__(key, value)
self.save()
|