]>
git.saurik.com Git - apple/security.git/blob - libsecurity_codesigning/gke/gkgenerate
3 # gkgenerate - produce Gatekeeper explicit allow data
5 # gkgenerate [--output name] files...
6 # will collect GKE data from all files and write two output files (name.auth and name.sigs)
7 # that are ready to drop into a /var/db for pickup.
20 # Parameters and constants
30 print >>sys
.stderr
, "Usage: %s sourcedir" % sys
.argv
[0]
34 print >>sys
.stderr
, "%s: %s" % (sys
.argv
[0], whatever
)
41 parser
= argparse
.ArgumentParser()
42 parser
.add_argument("--output", default
="./gke", help="name of output files")
43 parser
.add_argument("--uuid", default
=uuid
.uuid4(), help="explicitly specify the uuid stamp")
44 parser
.add_argument("--empty", action
='store_true', help="allow empty output sets")
45 parser
.add_argument('source', nargs
='+', help='files generated by the gkrecord command')
46 args
= parser
.parse_args()
48 authfile
= args
.output
+ ".auth"
49 sigsfile
= args
.output
+ ".sigs"
53 # Start by collecting authority evidence from the authority records
57 for source
in args
.source
:
59 data
= plistlib
.readPlist(source
[1:])
60 auth
.update(data
["authority"])
61 sigs
.update(data
["signatures"])
63 data
= plistlib
.readPlist(source
)
64 auth
.update(data
["authority"])
66 if not auth
and not args
.empty
:
67 fail("No authority records (nothing to do)")
71 # Scrub the authority records to remove incriminating evidence
74 for rec
in auth
.values():
78 new_auth
[str(u
)] = rec
83 # The authority file is written as-is, as a plist
89 plistlib
.writePlist(wrap
, authfile
)
90 print "Wrote %d authority record(s) to %s" % (len(auth
), authfile
)
94 # The signatures are written as tightly packed signature blobs
96 sigblobs
= open(sigsfile
, "w")
99 sigblobs
.write(sigdata
["signature"].data
)
101 print "Wrote %d signature record(s) to %s" % (len(sigs
), sigsfile
)