3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published
5 ## by the Free Software Foundation; version 2 and higer.
13 '5a51e4fbb38dac338e4444e6b713e9b3',
14 '44d6b8258fb4fb9c849162704120ba53',
16 '2c2713a25e323670cad57d5f856f0acf'
19 (194380, 'f04f2de920b08de2'),
20 (195340, 'f04f2de920b08de2'),
23 (194380, '0010a0e3001097e5'),
24 (195340, '0010a0e3001097e5'),
33 def __init__(self, config):
34 self.known_md5sums = config['known_md5sums']
35 self.check_ranges = config['check_ranges']
36 self.patch_ranges = config['patch_ranges']
38 def check_md5sum(self, filename):
40 f = open(filename, 'rb')
47 md5sum = md5.hexdigest()
48 for known_sum in self.known_md5sums:
49 if md5sum == known_sum: return True
53 def check_data(self, filename):
54 f = open(filename, 'rb')
56 for seek, hexbytes in self.check_ranges:
57 bytes = hexbytes.decode('hex')
59 actual = f.read(len(bytes))
67 def patch_file(self, filename):
68 f = open(filename, 'r+b')
70 for seek, hexbytes in self.patch_ranges:
71 bytes = hexbytes.decode('hex')
77 if __name__ == '__main__':
78 import sys, os, shutil, subprocess
80 library = '/usr/lib/librtcom-call-ui.so.0.0.0'
82 if os.access(library+'-p1', os.F_OK):
83 print "It looks like %s has already been patched. Aborting." % (library,)
86 patcher = Patcher(patch_config)
88 if not patcher.check_md5sum(library):
89 if not patcher.check_data(library):
90 message = "Your %s is not recognized. So I won't patch it." % (library)
91 subprocess.call(["dbus-send --system --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:\""+message+"\" uint32:0 string:\"OK\""],shell=True)
94 if len(sys.argv) > 1 and sys.argv[1] == '--force':
95 message = "Patching an unrecognized %s. Please test your system before rebooting." % (library)
98 message = "Your %s is not recognized, but it seems to match the patterns.\nRun '%s --force' to try patching anyway, but understand that\nTHIS MAY BREAK YOUR SYSTEM. If you do, test your system thoroughly before rebooting." % (library,sys.argv[0])
99 subprocess.call(["dbus-send --system --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:\""+message+"\" uint32:0 string:\"OK\""],shell=True)
103 shutil.copy2(library, library+'-p1')
104 patcher.patch_file(library+'-p1')