]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/ccaudit.h
2 * Copyright (c) 2004 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.
22 #include <Security/utility_config.h>
23 #include <bsm/audit.h>
28 namespace CommonCriteria
31 // for Tiger, this should be incorporated into Security's OSStatus range
35 errInvalidCredential
= 1111, // try to make easier to find in log
38 errEndOfExternalErrors
// sentry/placeholder
45 AuditMask(const AuditMask
&am
) { set(am
.get()); }
46 AuditMask(const au_mask_t
&am
) { set(am
); }
49 void set(const au_mask_t
&am
) { set(am
.am_success
, am
.am_failure
); }
50 void set(unsigned int s
, unsigned int f
) { mMask
.am_success
= s
; mMask
.am_failure
= f
; }
51 const au_mask_t
&get(void) const { return mMask
; }
57 // For the most part, we won't have a machine ID to initialize the
58 // au_tid_t's machine field. There's no machine ID in the audit token,
59 // for example, since MIG is localhost-only.
64 TerminalId(const TerminalId
&t
) { set(t
.get()); }
65 TerminalId(const au_tid_t
&tid
) { set(tid
); }
66 TerminalId(dev_t p
, u_int32_t m
) { port(p
); machine(m
); }
69 void set(void); // set using localhost
70 void set(const au_tid_t
&tid
) { port(tid
.port
); machine(tid
.machine
); }
71 void port(dev_t p
) { mTid
.port
= p
; }
72 void machine(u_int32_t m
) { mTid
.machine
= m
; }
73 const au_tid_t
&get(void) const { return mTid
; }
79 // audit session state for the current process; only used by Server
84 AuditSession(au_id_t auid
, AuditMask
&mask
, au_asid_t sid
,
86 : mAuditId(auid
), mEventMask(mask
), mTerminalId(tid
),
90 // set audit info for this process in kernel
91 void registerSession(void);
93 void auditId(au_id_t auid
) { mAuditId
= auid
; }
94 void eventMask(AuditMask
&mask
) { mEventMask
= mask
; }
95 void terminalId(TerminalId
&tid
) { mTerminalId
= tid
; }
96 void sessionId(au_asid_t sid
) { mSessionId
= sid
; }
98 au_id_t
auditId(void) { return mAuditId
; }
99 AuditMask
&eventMask(void) { return mEventMask
; }
100 TerminalId
&terminalId(void) { return mTerminalId
; }
101 au_asid_t
sessionId(void) { return mSessionId
; }
105 AuditMask mEventMask
;
106 TerminalId mTerminalId
;
107 au_asid_t mSessionId
;
111 // For submitting audit records. Not general-purpose: no ability to
112 // submit arbitrary BSM tokens, for example. However, the SecurityServer
113 // has only limited auditing requirements under Common Criteria.
118 AuditRecord(const audit_token_t
&auditToken
)
119 : mAuditId(auditToken
.val
[0]),
120 mRUid(auditToken
.val
[3]),
121 mRGid(auditToken
.val
[4]),
122 mEUid(auditToken
.val
[1]),
123 mEGid(auditToken
.val
[2]),
124 mPid(auditToken
.val
[5]),
125 mSessionId(auditToken
.val
[6]),
126 mTerminalId(auditToken
.val
[7], 0) { }
129 // returnCode == 0 --> success; nonzero returnCode --> failure
130 void submit(const short event_code
, const int returnCode
,
131 const char *msg
= NULL
);
140 au_asid_t mSessionId
;
141 TerminalId mTerminalId
;
144 } // end namespace CommonCriteria
146 } // end namespace Security