2 * Copyright (c) 2000-2001 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 // acls - SecurityServer ACL implementation
25 #include "securityserver.h"
26 #include <Security/cssmacl.h>
27 #include <Security/acl_process.h>
28 #include <Security/acl_codesigning.h>
36 // ACL implementation as used by the SecurityServer
38 class SecurityServerAcl
: public ObjectAcl
{
40 SecurityServerAcl(AclKind k
, CssmAllocator
&alloc
) :ObjectAcl(alloc
), mKind(k
) { }
41 virtual ~SecurityServerAcl();
43 AclKind
kind() const { return mKind
; }
45 // validation calls restated
46 void validate(AclAuthorization auth
, const AccessCredentials
*cred
) const;
47 void validate(AclAuthorization auth
, const Context
&context
) const;
49 void cssmGetAcl(const char *tag
, uint32
&count
, AclEntryInfo
* &acls
);
50 void cssmGetOwner(AclOwnerPrototype
&owner
);
51 void cssmChangeAcl(const AclEdit
&edit
, const AccessCredentials
*cred
);
52 void cssmChangeOwner(const AclOwnerPrototype
&newOwner
, const AccessCredentials
*cred
);
54 virtual void instantiateAcl() = 0;
55 virtual void noticeAclChange() = 0;
56 virtual const Database
*relatedDatabase() const;
59 static bool getBatchPassphrase(const AccessCredentials
*cred
,
60 CSSM_SAMPLE_TYPE neededSampleType
, CssmOwnedData
&passphrase
);
68 // Our implementation of an ACL validation environment uses information
69 // derived from a Connection object. It implements context for
70 // -- ProcessAclSubjects (getuid/getgid)
71 // -- KeychainPromptAclSubjects (connection link)
73 class SecurityServerEnvironment
: public virtual AclValidationEnvironment
,
74 public virtual ProcessAclSubject::Environment
,
75 public virtual CodeSignatureAclSubject::Environment
{
77 SecurityServerEnvironment(const SecurityServerAcl
&baseAcl
)
80 const SecurityServerAcl
&acl
;
82 const Database
*database() const { return acl
.relatedDatabase(); }
86 bool verifyCodeSignature(const CodeSigning::Signature
*signature
);