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# 8import sys 9import os 10import signal 11import errno 12import subprocess 13import argparse 14import plistlib 15import uuid 16 17 18# 19# Usage and fail 20# 21def fail(whatever): 22 print >>sys.stderr, "%s: %s" % (sys.argv[0], whatever) 23 sys.exit(1) 24 25 26# 27# Argument processing 28# 29parser = argparse.ArgumentParser() 30parser.add_argument("--output", default="./snippet.gke", help="name of output file") 31parser.add_argument('source', nargs='+', help='files generated by the gkrecord command') 32args = parser.parse_args() 33 34 35# 36# Merge all the plist data from the input files, overriding with later files 37# 38gkedict = { } 39for 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# 47plistlib.writePlist(gkedict, args.output) 48print "Wrote %d authority records + %d signatures to %s" % ( 49 len(gkedict["authority"]), len(gkedict["signatures"]), args.output 50) 51