]> git.decadent.org.uk Git - dak.git/blob - config/debian/extensions.py
extensions.py: update @replace_dak_function decorator to automatically
[dak.git] / config / debian / extensions.py
1 import sys, os
2
3 # This function and its data should move into daklib/extensions.py
4 # or something.
5 replaced_funcs = {}
6 replace_funcs = {}
7 def replace_dak_function(module,name):
8     def x(f):
9         def myfunc(*a,**kw):
10             global replaced_funcs
11             f(replaced_funcs[name], *a, **kw)
12         myfunc.__name__ = f.__name__
13         myfunc.__doc__ = f.__doc__
14         myfunc.__dict__.update(f.__dict__)
15
16         replace_funcs["%s:%s" % (module,name)] = myfunc
17         return f
18     return x
19
20 @replace_dak_function("process-unchecked", "check_signed_by_key")
21 def check_signed_by_key(oldfn):
22     changes = dak_module.changes
23     reject = dak_module.reject
24
25     if changes["source"] == "dpkg":
26         fpr = changes["fingerprint"]
27         (uid, uid_name) = dak_module.lookup_uid_from_fingerprint(fpr)
28         if fpr == "5906F687BD03ACAD0D8E602EFCF37657" or uid == "iwj":
29             reject("Upload blocked due to hijack attempt 2008/03/19")
30
31             # NB: 1.15.0, 1.15.2 signed by this key targetted at unstable
32             #     have been made available in the wild, and should remain
33             #     blocked until Debian's dpkg has revved past those version
34             #     numbers
35
36     oldfn()
37
38 def init(name):
39     global replaced_funcs
40
41     # This bit should be done automatically too
42     replaced_funcs = {}
43     for f,newfunc in replace_funcs.iteritems():
44         m,f = f.split(":",1)
45         if len(f) > 0 and m == name:
46             replaced_funcs[f] = dak_module.__dict__[f]
47             dak_module.__dict__[f] = newfunc
48