]>
git.saurik.com Git - apple/security.git/blob - SecurityServer/codesigdb.h
2 * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // codesigdb - code-hash equivalence database
25 #include <Security/db++.h>
26 #include <Security/osxsigner.h>
34 // A CodeSignaturse object represents a database of code-signature equivalencies
35 // as (previously) expressed by a user and/or the system.
36 // You'll usually only need one of these.
38 class CodeSignatures
{
41 // Identity is an abstract class modeling a code-identity in the database.
42 // It can represent either an existing or latent code-hash link.
43 // Subclass must provide path and hash source functions.
46 friend class CodeSignatures
;
51 operator bool () const { return mState
== valid
; }
52 std::string
path() { return getPath(); }
53 std::string
name() { return canonicalName(path()); }
54 std::string
trustedName() const { return mName
; }
56 static std::string
canonicalName(const std::string
&path
);
58 IFDUMP(void debugDump(const char *how
= NULL
) const);
60 virtual std::string
getPath() const = 0;
61 virtual const CssmData
getHash(CodeSigning::OSXSigner
&signer
) const = 0;
64 enum { untried
, valid
, invalid
} mState
;
65 std::string mName
; // link db value (canonical name linked to)
69 CodeSignatures(const char *path
);
72 void open(const char *path
);
75 bool find(Identity
&id
, uid_t user
);
77 void makeLink(Identity
&id
, const std::string
&ident
, bool forUser
= false, uid_t user
= 0);
78 void makeApplication(const std::string
&name
, const std::string
&path
);
80 void addLink(const CssmData
&oldHash
, const CssmData
&newHash
,
81 const char *name
, bool forSystem
);
82 void removeLink(const CssmData
&hash
, const char *name
, bool forSystem
);
84 IFDUMP(void debugDump(const char *how
= NULL
) const);
87 bool verify(Process
&process
,
88 const CodeSigning::Signature
*trustedSignature
, const CssmData
*comment
);
91 UnixPlusPlus::UnixDb mDb
;
92 CodeSigning::OSXSigner mSigner
;
94 // lock hierarchy: mUILock first, then mDatabaseLock, no back-off
95 Mutex mDatabaseLock
; // controls mDb access
96 Mutex mUILock
; // serializes user interaction
101 #endif //_H_CODESIGDB