2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 #include <sys/appleapiopts.h>
27 #include <sys/cdefs.h>
29 #ifdef __APPLE_API_EVOLVING
35 #define KAUTH_UID_NONE (~(uid_t)0 - 100) /* not a valid UID */
36 #define KAUTH_GID_NONE (~(gid_t)0 - 100) /* not a valid GID */
40 /* Apple-style globally unique identifier */
42 #define KAUTH_GUID_SIZE 16 /* 128-bit identifier */
43 unsigned char g_guid
[KAUTH_GUID_SIZE
];
46 #endif /* _KAUTH_GUID */
48 /* NT Security Identifier, structure as defined by Microsoft */
49 #pragma pack(1) /* push packing of 1 byte */
52 u_int8_t sid_authcount
;
53 u_int8_t sid_authority
[6];
54 #define KAUTH_NTSID_MAX_AUTHORITIES 16
55 u_int32_t sid_authorities
[KAUTH_NTSID_MAX_AUTHORITIES
];
57 #pragma pack() /* pop packing to previous packing level */
60 /* valid byte count inside a SID structure */
61 #define KAUTH_NTSID_HDRSIZE (8)
62 #define KAUTH_NTSID_SIZE(_s) (KAUTH_NTSID_HDRSIZE + ((_s)->sid_authcount * sizeof(u_int32_t)))
65 * External lookup message payload
67 struct kauth_identity_extlookup
{
68 u_int32_t el_seqno
; /* request sequence number */
69 u_int32_t el_result
; /* lookup result */
70 #define KAUTH_EXTLOOKUP_SUCCESS 0 /* results here are good */
71 #define KAUTH_EXTLOOKUP_BADRQ 1 /* request badly formatted */
72 #define KAUTH_EXTLOOKUP_FAILURE 2 /* transient failure during lookup */
73 #define KAUTH_EXTLOOKUP_FATAL 3 /* permanent failure during lookup */
74 #define KAUTH_EXTLOOKUP_INPROG 100 /* request in progress */
76 #define KAUTH_EXTLOOKUP_VALID_UID (1<<0)
77 #define KAUTH_EXTLOOKUP_VALID_UGUID (1<<1)
78 #define KAUTH_EXTLOOKUP_VALID_USID (1<<2)
79 #define KAUTH_EXTLOOKUP_VALID_GID (1<<3)
80 #define KAUTH_EXTLOOKUP_VALID_GGUID (1<<4)
81 #define KAUTH_EXTLOOKUP_VALID_GSID (1<<5)
82 #define KAUTH_EXTLOOKUP_WANT_UID (1<<6)
83 #define KAUTH_EXTLOOKUP_WANT_UGUID (1<<7)
84 #define KAUTH_EXTLOOKUP_WANT_USID (1<<8)
85 #define KAUTH_EXTLOOKUP_WANT_GID (1<<9)
86 #define KAUTH_EXTLOOKUP_WANT_GGUID (1<<10)
87 #define KAUTH_EXTLOOKUP_WANT_GSID (1<<11)
88 #define KAUTH_EXTLOOKUP_WANT_MEMBERSHIP (1<<12)
89 #define KAUTH_EXTLOOKUP_VALID_MEMBERSHIP (1<<13)
90 #define KAUTH_EXTLOOKUP_ISMEMBER (1<<14)
91 uid_t el_uid
; /* user ID */
92 guid_t el_uguid
; /* user GUID */
93 u_int32_t el_uguid_valid
; /* TTL on translation result (seconds) */
94 ntsid_t el_usid
; /* user NT SID */
95 u_int32_t el_usid_valid
; /* TTL on translation result (seconds) */
96 gid_t el_gid
; /* group ID */
97 guid_t el_gguid
; /* group GUID */
98 u_int32_t el_gguid_valid
; /* TTL on translation result (seconds) */
99 ntsid_t el_gsid
; /* group SID */
100 u_int32_t el_gsid_valid
; /* TTL on translation result (seconds) */
101 u_int32_t el_member_valid
; /* TTL on group lookup result */
104 #define KAUTH_EXTLOOKUP_REGISTER (0)
105 #define KAUTH_EXTLOOKUP_RESULT (1<<0)
106 #define KAUTH_EXTLOOKUP_WORKER (1<<1)
116 * Supplemental credential data.
118 * This interface allows us to associate arbitrary data with a credential.
119 * As with the credential, the data is considered immutable.
121 struct kauth_cred_supplement
{
122 TAILQ_ENTRY(kauth_cred_supplement
) kcs_link
;
124 int kcs_ref
; /* reference count */
125 int kcs_id
; /* vended identifier */
126 size_t kcs_size
; /* size of data field */
130 typedef struct kauth_cred_supplement
*kauth_cred_supplement_t
;
133 TAILQ_ENTRY(kauth_cred
) kc_link
;
135 int kc_ref
; /* reference count */
136 uid_t kc_uid
; /* effective user id */
137 uid_t kc_ruid
; /* real user id */
138 uid_t kc_svuid
; /* saved user id */
139 gid_t kc_gid
; /* effective group id */
140 gid_t kc_rgid
; /* real group id */
141 gid_t kc_svgid
; /* saved group id */
144 #define KAUTH_CRED_GRPOVERRIDE (1<<0) /* private group list is authoritative */
146 int kc_npvtgroups
; /* private group list, advisory or authoritative */
147 gid_t kc_pvtgroups
[NGROUPS
]; /* based on KAUTH_CRED_GRPOVERRIDE flag */
149 int kc_nsuppgroups
; /* supplementary group list */
150 gid_t
*kc_suppgroups
;
152 int kc_nwhtgroups
; /* whiteout group list */
155 struct auditinfo cr_au
; /* user auditing data */
157 int kc_nsupplement
; /* entry count in supplemental data pointer array */
158 kauth_cred_supplement_t
*kc_supplement
;
162 /* XXX just for now */
163 #include <sys/ucred.h>
164 // typedef struct ucred *kauth_cred_t;
167 /* Kernel SPI for now */
169 extern uid_t
kauth_getuid(void);
170 extern uid_t
kauth_getruid(void);
171 extern gid_t
kauth_getgid(void);
172 extern gid_t
kauth_getrgid(void);
173 extern kauth_cred_t
kauth_cred_get(void);
174 extern kauth_cred_t
kauth_cred_get_with_ref(void);
175 extern kauth_cred_t
kauth_cred_proc_ref(proc_t procp
);
176 extern kauth_cred_t
kauth_cred_alloc(void);
177 extern kauth_cred_t
kauth_cred_create(kauth_cred_t cred
);
178 extern void kauth_cred_ref(kauth_cred_t _cred
);
179 extern void kauth_cred_rele(kauth_cred_t _cred
);
180 extern kauth_cred_t
kauth_cred_dup(kauth_cred_t cred
);
181 extern kauth_cred_t
kauth_cred_copy_real(kauth_cred_t cred
);
182 extern void kauth_cred_unref(kauth_cred_t _cred
);
183 extern kauth_cred_t
kauth_cred_setuid(kauth_cred_t cred
, uid_t uid
);
184 extern kauth_cred_t
kauth_cred_seteuid(kauth_cred_t cred
, uid_t euid
);
185 extern kauth_cred_t
kauth_cred_setgid(kauth_cred_t cred
, gid_t gid
);
186 extern kauth_cred_t
kauth_cred_setegid(kauth_cred_t cred
, gid_t egid
);
187 extern kauth_cred_t
kauth_cred_setuidgid(kauth_cred_t cred
, uid_t uid
, gid_t gid
);
188 extern kauth_cred_t
kauth_cred_setsvuidgid(kauth_cred_t cred
, uid_t uid
, gid_t gid
);
189 extern kauth_cred_t
kauth_cred_setgroups(kauth_cred_t cred
, gid_t
*groups
, int groupcount
, uid_t gmuid
);
190 extern kauth_cred_t
kauth_cred_find(kauth_cred_t cred
);
191 extern int kauth_cred_getgroups(gid_t
*_groups
, int *_groupcount
);
192 extern int kauth_cred_assume(uid_t _uid
);
193 extern uid_t
kauth_cred_getuid(kauth_cred_t _cred
);
194 extern gid_t
kauth_cred_getgid(kauth_cred_t _cred
);
195 extern int kauth_cred_guid2uid(guid_t
*_guid
, uid_t
*_uidp
);
196 extern int kauth_cred_guid2gid(guid_t
*_guid
, gid_t
*_gidp
);
197 extern int kauth_cred_ntsid2uid(ntsid_t
*_sid
, uid_t
*_uidp
);
198 extern int kauth_cred_ntsid2gid(ntsid_t
*_sid
, gid_t
*_gidp
);
199 extern int kauth_cred_ntsid2guid(ntsid_t
*_sid
, guid_t
*_guidp
);
200 extern int kauth_cred_uid2guid(uid_t _uid
, guid_t
*_guidp
);
201 extern int kauth_cred_getguid(kauth_cred_t _cred
, guid_t
*_guidp
);
202 extern int kauth_cred_gid2guid(gid_t _gid
, guid_t
*_guidp
);
203 extern int kauth_cred_uid2ntsid(uid_t _uid
, ntsid_t
*_sidp
);
204 extern int kauth_cred_getntsid(kauth_cred_t _cred
, ntsid_t
*_sidp
);
205 extern int kauth_cred_gid2ntsid(gid_t _gid
, ntsid_t
*_sidp
);
206 extern int kauth_cred_guid2ntsid(guid_t
*_guid
, ntsid_t
*_sidp
);
207 extern int kauth_cred_ismember_gid(kauth_cred_t _cred
, gid_t _gid
, int *_resultp
);
208 extern int kauth_cred_ismember_guid(kauth_cred_t _cred
, guid_t
*_guidp
, int *_resultp
);
210 extern int kauth_cred_supplementary_register(const char *name
, int *ident
);
211 extern int kauth_cred_supplementary_add(kauth_cred_t cred
, int ident
, const void *data
, size_t datasize
);
212 extern int kauth_cred_supplementary_remove(kauth_cred_t cred
, int ident
);
214 /* NOT KPI - fast path for in-kernel code only */
215 extern int kauth_cred_issuser(kauth_cred_t _cred
);
218 /* GUID, NTSID helpers */
219 extern guid_t kauth_null_guid
;
220 extern int kauth_guid_equal(guid_t
*_guid1
, guid_t
*_guid2
);
221 extern int kauth_ntsid_equal(ntsid_t
*_sid1
, ntsid_t
*_sid2
);
223 extern int kauth_wellknown_guid(guid_t
*_guid
);
224 #define KAUTH_WKG_NOT 0 /* not a well-known GUID */
225 #define KAUTH_WKG_OWNER 1
226 #define KAUTH_WKG_GROUP 2
227 #define KAUTH_WKG_NOBODY 3
228 #define KAUTH_WKG_EVERYBODY 4
230 extern int cantrace(proc_t cur_procp
, kauth_cred_t creds
, proc_t traced_procp
, int *errp
);
237 * Generic Access Control Lists.
239 #if defined(KERNEL) || defined (_SYS_ACL_H)
241 typedef u_int32_t kauth_ace_rights_t
;
243 /* Access Control List Entry (ACE) */
245 guid_t ace_applicable
;
247 #define KAUTH_ACE_KINDMASK 0xf
248 #define KAUTH_ACE_PERMIT 1
249 #define KAUTH_ACE_DENY 2
250 #define KAUTH_ACE_AUDIT 3 /* not implemented */
251 #define KAUTH_ACE_ALARM 4 /* not implemented */
252 #define KAUTH_ACE_INHERITED (1<<4)
253 #define KAUTH_ACE_FILE_INHERIT (1<<5)
254 #define KAUTH_ACE_DIRECTORY_INHERIT (1<<6)
255 #define KAUTH_ACE_LIMIT_INHERIT (1<<7)
256 #define KAUTH_ACE_ONLY_INHERIT (1<<8)
257 #define KAUTH_ACE_SUCCESS (1<<9) /* not implemented (AUDIT/ALARM) */
258 #define KAUTH_ACE_FAILURE (1<<10) /* not implemented (AUDIT/ALARM) */
259 kauth_ace_rights_t ace_rights
; /* scope specific */
260 /* These rights are never tested, but may be present in an ACL */
261 #define KAUTH_ACE_GENERIC_ALL (1<<21)
262 #define KAUTH_ACE_GENERIC_EXECUTE (1<<22)
263 #define KAUTH_ACE_GENERIC_WRITE (1<<23)
264 #define KAUTH_ACE_GENERIC_READ (1<<24)
270 typedef struct kauth_ace
*kauth_ace_t
;
274 /* Access Control List */
276 u_int32_t acl_entrycount
;
279 struct kauth_ace acl_ace
[];
283 * XXX this value needs to be raised - 3893388
285 #define KAUTH_ACL_MAX_ENTRIES 128
288 * The low 16 bits of the flags field are reserved for filesystem
289 * internal use and must be preserved by all APIs. This includes
290 * round-tripping flags through user-space interfaces.
292 #define KAUTH_ACL_FLAGS_PRIVATE (0xffff)
295 * The high 16 bits of the flags are used to store attributes and
296 * to request specific handling of the ACL.
299 /* inheritance will be deferred until the first rename operation */
300 #define KAUTH_ACL_DEFER_INHERIT (1<<16)
301 /* this ACL must not be overwritten as part of an inheritance operation */
302 #define KAUTH_ACL_NO_INHERIT (1<<17)
304 #define KAUTH_ACL_SIZE(c) (sizeof(struct kauth_acl) + (c) * sizeof(struct kauth_ace))
305 #define KAUTH_ACL_COPYSIZE(p) KAUTH_ACL_SIZE((p)->acl_entrycount)
310 typedef struct kauth_acl
*kauth_acl_t
;
315 kauth_acl_t
kauth_acl_alloc(int size
);
316 void kauth_acl_free(kauth_acl_t fsp
);
322 * Extended File Security.
325 /* File Security information */
326 struct kauth_filesec
{
327 u_int32_t fsec_magic
;
328 #define KAUTH_FILESEC_MAGIC 0x012cc16d
332 struct kauth_acl fsec_acl
;
333 /* acl_entrycount that tells us the ACL is not valid */
334 #define KAUTH_FILESEC_NOACL ((u_int32_t)(-1))
337 /* backwards compatibility */
338 #define fsec_entrycount fsec_acl.acl_entrycount
339 #define fsec_flags fsec_acl.acl_flags
340 #define fsec_ace fsec_acl.acl_ace
341 #define KAUTH_FILESEC_FLAGS_PRIVATE KAUTH_ACL_FLAGS_PRIVATE
342 #define KAUTH_FILESEC_DEFER_INHERIT KAUTH_ACL_DEFER_INHERIT
343 #define KAUTH_FILESEC_NO_INHERIT KAUTH_ACL_NO_INHERIT
344 #define KAUTH_FILESEC_NONE ((kauth_filesec_t)0)
345 #define KAUTH_FILESEC_WANTED ((kauth_filesec_t)1)
347 #ifndef _KAUTH_FILESEC
348 #define _KAUTH_FILESEC
349 typedef struct kauth_filesec
*kauth_filesec_t
;
352 #define KAUTH_FILESEC_SIZE(c) (sizeof(struct kauth_filesec) + (c) * sizeof(struct kauth_ace))
353 #define KAUTH_FILESEC_COPYSIZE(p) KAUTH_FILESEC_SIZE(((p)->fsec_entrycount == KAUTH_FILESEC_NOACL) ? 0 : (p)->fsec_entrycount)
354 #define KAUTH_FILESEC_COUNT(s) ((s - sizeof(struct kauth_filesec)) / sizeof(struct kauth_ace))
356 #define KAUTH_FILESEC_XATTR "com.apple.system.Security"
359 kauth_filesec_t
kauth_filesec_alloc(int size
);
360 void kauth_filesec_free(kauth_filesec_t fsp
);
361 int kauth_copyinfilesec(user_addr_t xsecurity
, kauth_filesec_t
*xsecdestpp
);
364 #endif /* KERNEL || <sys/acl.h> */
372 typedef struct kauth_scope
*kauth_scope_t
;
373 struct kauth_listener
;
374 typedef struct kauth_listener
*kauth_listener_t
;
375 #ifndef _KAUTH_ACTION_T
376 typedef int kauth_action_t
;
377 # define _KAUTH_ACTION_T
380 typedef int (* kauth_scope_callback_t
)(kauth_cred_t _credential
,
382 kauth_action_t _action
,
388 #define KAUTH_RESULT_ALLOW (1)
389 #define KAUTH_RESULT_DENY (2)
390 #define KAUTH_RESULT_DEFER (3)
392 struct kauth_acl_eval
{
395 kauth_ace_rights_t ae_requested
;
396 kauth_ace_rights_t ae_residual
;
399 #define KAUTH_AEVAL_IS_OWNER (1<<0) /* authorizing operation for owner */
400 #define KAUTH_AEVAL_IN_GROUP (1<<1) /* authorizing operation for groupmember */
401 /* expansions for 'generic' rights bits */
402 kauth_ace_rights_t ae_exp_gall
;
403 kauth_ace_rights_t ae_exp_gread
;
404 kauth_ace_rights_t ae_exp_gwrite
;
405 kauth_ace_rights_t ae_exp_gexec
;
408 typedef struct kauth_acl_eval
*kauth_acl_eval_t
;
411 extern kauth_scope_t
kauth_register_scope(const char *_identifier
, kauth_scope_callback_t _callback
, void *_idata
);
412 extern void kauth_deregister_scope(kauth_scope_t _scope
);
413 extern kauth_listener_t
kauth_listen_scope(const char *_identifier
, kauth_scope_callback_t _callback
, void *_idata
);
414 extern void kauth_unlisten_scope(kauth_listener_t _scope
);
415 extern int kauth_authorize_action(kauth_scope_t _scope
, kauth_cred_t _credential
, kauth_action_t _action
,
416 uintptr_t _arg0
, uintptr_t _arg1
, uintptr_t _arg2
, uintptr_t _arg3
);
417 extern int kauth_acl_evaluate(kauth_cred_t _credential
, kauth_acl_eval_t _eval
);
418 extern int kauth_acl_inherit(vnode_t _dvp
, kauth_acl_t _initial
, kauth_acl_t
*_product
, int _isdir
, vfs_context_t _ctx
);
420 /* default scope handlers */
421 extern int kauth_authorize_allow(kauth_cred_t _credential
, void *_idata
, kauth_action_t _action
,
422 uintptr_t _arg0
, uintptr_t _arg1
, uintptr_t _arg2
, uintptr_t _arg3
);
428 #define KAUTH_SCOPE_GENERIC "com.apple.kauth.generic"
431 #define KAUTH_GENERIC_ISSUSER 1
434 extern int kauth_authorize_generic(kauth_cred_t credential
, kauth_action_t action
);
438 * Process/task scope.
440 #define KAUTH_SCOPE_PROCESS "com.apple.kauth.process"
443 #define KAUTH_PROCESS_CANSIGNAL 1
444 #define KAUTH_PROCESS_CANTRACE 2
447 extern int kauth_authorize_process(kauth_cred_t _credential
, kauth_action_t _action
,
448 struct proc
*_process
, uintptr_t _arg1
, uintptr_t _arg2
, uintptr_t _arg3
);
452 * Vnode operation scope.
454 * Prototype for vnode_authorize is in vnode.h
456 #define KAUTH_SCOPE_VNODE "com.apple.kauth.vnode"
459 * File system operation scope.
462 #define KAUTH_SCOPE_FILEOP "com.apple.kauth.fileop"
465 #define KAUTH_FILEOP_OPEN 1
466 #define KAUTH_FILEOP_CLOSE 2
467 #define KAUTH_FILEOP_RENAME 3
468 #define KAUTH_FILEOP_EXCHANGE 4
469 #define KAUTH_FILEOP_LINK 5
470 #define KAUTH_FILEOP_EXEC 6
473 * arguments passed to KAUTH_FILEOP_OPEN listeners
474 * arg0 is pointer to vnode (vnode *) for given user path.
475 * arg1 is pointer to path (char *) passed in to open.
476 * arguments passed to KAUTH_FILEOP_CLOSE listeners
477 * arg0 is pointer to vnode (vnode *) for file to be closed.
478 * arg1 is pointer to path (char *) of file to be closed.
479 * arg2 is close flags.
480 * arguments passed to KAUTH_FILEOP_RENAME listeners
481 * arg0 is pointer to "from" path (char *).
482 * arg1 is pointer to "to" path (char *).
483 * arguments passed to KAUTH_FILEOP_EXCHANGE listeners
484 * arg0 is pointer to file 1 path (char *).
485 * arg1 is pointer to file 2 path (char *).
486 * arguments passed to KAUTH_FILEOP_LINK listeners
487 * arg0 is pointer to path to file we are linking to (char *).
488 * arg1 is pointer to path to the new link file (char *).
489 * arguments passed to KAUTH_FILEOP_EXEC listeners
490 * arg0 is pointer to vnode (vnode *) for executable.
491 * arg1 is pointer to path (char *) to executable.
494 /* Flag values returned to close listeners. */
495 #define KAUTH_FILEOP_CLOSE_MODIFIED (1<<1)
498 extern int kauth_authorize_fileop_has_listeners(void);
499 extern int kauth_authorize_fileop(kauth_cred_t _credential
, kauth_action_t _action
,
500 uintptr_t _arg0
, uintptr_t _arg1
);
505 /* Actions, also rights bits in an ACE */
507 #if defined(KERNEL) || defined (_SYS_ACL_H)
508 #define KAUTH_VNODE_READ_DATA (1<<1)
509 #define KAUTH_VNODE_LIST_DIRECTORY KAUTH_VNODE_READ_DATA
510 #define KAUTH_VNODE_WRITE_DATA (1<<2)
511 #define KAUTH_VNODE_ADD_FILE KAUTH_VNODE_WRITE_DATA
512 #define KAUTH_VNODE_EXECUTE (1<<3)
513 #define KAUTH_VNODE_SEARCH KAUTH_VNODE_EXECUTE
514 #define KAUTH_VNODE_DELETE (1<<4)
515 #define KAUTH_VNODE_APPEND_DATA (1<<5)
516 #define KAUTH_VNODE_ADD_SUBDIRECTORY KAUTH_VNODE_APPEND_DATA
517 #define KAUTH_VNODE_DELETE_CHILD (1<<6)
518 #define KAUTH_VNODE_READ_ATTRIBUTES (1<<7)
519 #define KAUTH_VNODE_WRITE_ATTRIBUTES (1<<8)
520 #define KAUTH_VNODE_READ_EXTATTRIBUTES (1<<9)
521 #define KAUTH_VNODE_WRITE_EXTATTRIBUTES (1<<10)
522 #define KAUTH_VNODE_READ_SECURITY (1<<11)
523 #define KAUTH_VNODE_WRITE_SECURITY (1<<12)
524 #define KAUTH_VNODE_TAKE_OWNERSHIP (1<<13)
526 /* backwards compatibility only */
527 #define KAUTH_VNODE_CHANGE_OWNER KAUTH_VNODE_TAKE_OWNERSHIP
529 /* For Windows interoperability only */
530 #define KAUTH_VNODE_SYNCHRONIZE (1<<20)
532 /* (1<<21) - (1<<24) are reserved for generic rights bits */
534 /* Actions not expressed as rights bits */
536 * Authorizes the vnode as the target of a hard link.
538 #define KAUTH_VNODE_LINKTARGET (1<<25)
541 * Indicates that other steps have been taken to authorise the action,
542 * but authorisation should be denied for immutable objects.
544 #define KAUTH_VNODE_CHECKIMMUTABLE (1<<26)
546 /* Action modifiers */
548 * The KAUTH_VNODE_ACCESS bit is passed to the callback if the authorisation
549 * request in progress is advisory, rather than authoritative. Listeners
550 * performing consequential work (i.e. not strictly checking authorisation)
551 * may test this flag to avoid performing unnecessary work.
553 * This bit will never be present in an ACE.
555 #define KAUTH_VNODE_ACCESS (1<<31)
558 * The KAUTH_VNODE_NOIMMUTABLE bit is passed to the callback along with the
559 * KAUTH_VNODE_WRITE_SECURITY bit (and no others) to indicate that the
560 * caller wishes to change one or more of the immutable flags, and the
561 * state of these flags should not be considered when authorizing the request.
562 * The system immutable flags are only ignored when the system securelevel
563 * is low enough to allow their removal.
565 #define KAUTH_VNODE_NOIMMUTABLE (1<<30)
567 /* The expansions of the GENERIC bits at evaluation time */
568 #define KAUTH_VNODE_GENERIC_READ_BITS (KAUTH_VNODE_READ_DATA | \
569 KAUTH_VNODE_READ_ATTRIBUTES | \
570 KAUTH_VNODE_READ_EXTATTRIBUTES | \
571 KAUTH_VNODE_READ_SECURITY)
573 #define KAUTH_VNODE_GENERIC_WRITE_BITS (KAUTH_VNODE_WRITE_DATA | \
574 KAUTH_VNODE_APPEND_DATA | \
575 KAUTH_VNODE_DELETE | \
576 KAUTH_VNODE_DELETE_CHILD | \
577 KAUTH_VNODE_WRITE_ATTRIBUTES | \
578 KAUTH_VNODE_WRITE_EXTATTRIBUTES | \
579 KAUTH_VNODE_WRITE_SECURITY)
581 #define KAUTH_VNODE_GENERIC_EXECUTE_BITS (KAUTH_VNODE_EXECUTE)
583 #define KAUTH_VNODE_GENERIC_ALL_BITS (KAUTH_VNODE_GENERIC_READ_BITS | \
584 KAUTH_VNODE_GENERIC_WRITE_BITS | \
585 KAUTH_VNODE_GENERIC_EXECUTE_BITS)
588 * Some sets of bits, defined here for convenience.
590 #define KAUTH_VNODE_WRITE_RIGHTS (KAUTH_VNODE_ADD_FILE | \
591 KAUTH_VNODE_ADD_SUBDIRECTORY | \
592 KAUTH_VNODE_DELETE_CHILD | \
593 KAUTH_VNODE_WRITE_DATA | \
594 KAUTH_VNODE_APPEND_DATA | \
595 KAUTH_VNODE_DELETE | \
596 KAUTH_VNODE_WRITE_ATTRIBUTES | \
597 KAUTH_VNODE_WRITE_EXTATTRIBUTES | \
598 KAUTH_VNODE_WRITE_SECURITY | \
599 KAUTH_VNODE_TAKE_OWNERSHIP | \
600 KAUTH_VNODE_LINKTARGET | \
601 KAUTH_VNODE_CHECKIMMUTABLE)
604 #endif /* KERNEL || <sys/acl.h> */
607 #include <sys/lock.h> /* lck_grp_t */
612 * XXX this wouldn't be necessary if we had a *real* debug-logging system.
617 void kprintf(const char *fmt
, ...);
619 # define KAUTH_DEBUG_ENABLE
620 # define K_UUID_FMT "%08x:%08x:%08x:%08x"
621 # define K_UUID_ARG(_u) *(int *)&_u.g_guid[0],*(int *)&_u.g_guid[4],*(int *)&_u.g_guid[8],*(int *)&_u.g_guid[12]
622 # define KAUTH_DEBUG(fmt, args...) do { kprintf("%s:%d: " fmt "\n", __PRETTY_FUNCTION__, __LINE__ , ##args); } while (0)
623 # define KAUTH_DEBUG_CTX(_c) KAUTH_DEBUG("p = %p c = %p", _c->vc_proc, _c->vc_ucred)
624 # define VFS_DEBUG(_ctx, _vp, fmt, args...) \
626 kprintf("%p '%s' %s:%d " fmt "\n", \
628 (_vp != NULL && _vp->v_name != NULL) ? _vp->v_name : "????", \
629 __PRETTY_FUNCTION__, __LINE__ , \
633 # define KAUTH_DEBUG(fmt, args...) do { } while (0)
634 # define VFS_DEBUG(ctx, vp, fmt, args...) do { } while(0)
640 extern lck_grp_t
*kauth_lck_grp
;
642 extern void kauth_init(void);
643 extern void kauth_identity_init(void);
644 extern void kauth_groups_init(void);
645 extern void kauth_cred_init(void);
646 extern void kauth_resolver_init(void);
650 #endif /* __APPLE_API_EVOLVING */
651 #endif /* _SYS_KAUTH_H */