]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/gke/gkmerge
Security-57337.50.23.tar.gz
[apple/security.git] / OSX / libsecurity_codesigning / gke / gkmerge
1 #!/usr/bin/python
2 #
3 # gkmerge - merge Gatekeeper whitelist snippets
4 #
5 # gkmerge [--output name] files...
6 # Takes GKE data from all files, merges it together, and writes it to a new snippet file 'output'.
7 #
8 import sys
9 import os
10 import signal
11 import errno
12 import subprocess
13 import argparse
14 import plistlib
15 import uuid
16
17
18 #
19 # Usage and fail
20 #
21 def fail(whatever):
22 print >>sys.stderr, "%s: %s" % (sys.argv[0], whatever)
23 sys.exit(1)
24
25
26 #
27 # Argument processing
28 #
29 parser = argparse.ArgumentParser()
30 parser.add_argument("--output", default="./snippet.gke", help="name of output file")
31 parser.add_argument('source', nargs='+', help='files generated by the gkrecord command')
32 args = parser.parse_args()
33
34
35 #
36 # Merge all the plist data from the input files, overriding with later files
37 #
38 gkedict = { }
39 for source in args.source:
40 data = plistlib.readPlist(source)
41 gkedict.update(data)
42
43
44 #
45 # Write it back out as a snippet file
46 #
47 plistlib.writePlist(gkedict, args.output)
48 print "Wrote %d authority records + %d signatures to %s" % (
49 len(gkedict["authority"]), len(gkedict["signatures"]), args.output
50 )