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"
358 /* Allowable first arguments to kauth_filesec_acl_setendian() */
359 #define KAUTH_ENDIAN_HOST 0x00000001 /* set host endianness */
360 #define KAUTH_ENDIAN_DISK 0x00000002 /* set disk endianness */
363 kauth_filesec_t
kauth_filesec_alloc(int size
);
364 void kauth_filesec_free(kauth_filesec_t fsp
);
365 int kauth_copyinfilesec(user_addr_t xsecurity
, kauth_filesec_t
*xsecdestpp
);
366 void kauth_filesec_acl_setendian(int, kauth_filesec_t
, kauth_acl_t
);
369 #endif /* KERNEL || <sys/acl.h> */
377 typedef struct kauth_scope
*kauth_scope_t
;
378 struct kauth_listener
;
379 typedef struct kauth_listener
*kauth_listener_t
;
380 #ifndef _KAUTH_ACTION_T
381 typedef int kauth_action_t
;
382 # define _KAUTH_ACTION_T
385 typedef int (* kauth_scope_callback_t
)(kauth_cred_t _credential
,
387 kauth_action_t _action
,
393 #define KAUTH_RESULT_ALLOW (1)
394 #define KAUTH_RESULT_DENY (2)
395 #define KAUTH_RESULT_DEFER (3)
397 struct kauth_acl_eval
{
400 kauth_ace_rights_t ae_requested
;
401 kauth_ace_rights_t ae_residual
;
404 #define KAUTH_AEVAL_IS_OWNER (1<<0) /* authorizing operation for owner */
405 #define KAUTH_AEVAL_IN_GROUP (1<<1) /* authorizing operation for groupmember */
406 /* expansions for 'generic' rights bits */
407 kauth_ace_rights_t ae_exp_gall
;
408 kauth_ace_rights_t ae_exp_gread
;
409 kauth_ace_rights_t ae_exp_gwrite
;
410 kauth_ace_rights_t ae_exp_gexec
;
413 typedef struct kauth_acl_eval
*kauth_acl_eval_t
;
416 extern kauth_scope_t
kauth_register_scope(const char *_identifier
, kauth_scope_callback_t _callback
, void *_idata
);
417 extern void kauth_deregister_scope(kauth_scope_t _scope
);
418 extern kauth_listener_t
kauth_listen_scope(const char *_identifier
, kauth_scope_callback_t _callback
, void *_idata
);
419 extern void kauth_unlisten_scope(kauth_listener_t _scope
);
420 extern int kauth_authorize_action(kauth_scope_t _scope
, kauth_cred_t _credential
, kauth_action_t _action
,
421 uintptr_t _arg0
, uintptr_t _arg1
, uintptr_t _arg2
, uintptr_t _arg3
);
422 extern int kauth_acl_evaluate(kauth_cred_t _credential
, kauth_acl_eval_t _eval
);
423 extern int kauth_acl_inherit(vnode_t _dvp
, kauth_acl_t _initial
, kauth_acl_t
*_product
, int _isdir
, vfs_context_t _ctx
);
425 /* default scope handlers */
426 extern int kauth_authorize_allow(kauth_cred_t _credential
, void *_idata
, kauth_action_t _action
,
427 uintptr_t _arg0
, uintptr_t _arg1
, uintptr_t _arg2
, uintptr_t _arg3
);
433 #define KAUTH_SCOPE_GENERIC "com.apple.kauth.generic"
436 #define KAUTH_GENERIC_ISSUSER 1
439 extern int kauth_authorize_generic(kauth_cred_t credential
, kauth_action_t action
);
443 * Process/task scope.
445 #define KAUTH_SCOPE_PROCESS "com.apple.kauth.process"
448 #define KAUTH_PROCESS_CANSIGNAL 1
449 #define KAUTH_PROCESS_CANTRACE 2
452 extern int kauth_authorize_process(kauth_cred_t _credential
, kauth_action_t _action
,
453 struct proc
*_process
, uintptr_t _arg1
, uintptr_t _arg2
, uintptr_t _arg3
);
457 * Vnode operation scope.
459 * Prototype for vnode_authorize is in vnode.h
461 #define KAUTH_SCOPE_VNODE "com.apple.kauth.vnode"
464 * File system operation scope.
467 #define KAUTH_SCOPE_FILEOP "com.apple.kauth.fileop"
470 #define KAUTH_FILEOP_OPEN 1
471 #define KAUTH_FILEOP_CLOSE 2
472 #define KAUTH_FILEOP_RENAME 3
473 #define KAUTH_FILEOP_EXCHANGE 4
474 #define KAUTH_FILEOP_LINK 5
475 #define KAUTH_FILEOP_EXEC 6
478 * arguments passed to KAUTH_FILEOP_OPEN listeners
479 * arg0 is pointer to vnode (vnode *) for given user path.
480 * arg1 is pointer to path (char *) passed in to open.
481 * arguments passed to KAUTH_FILEOP_CLOSE listeners
482 * arg0 is pointer to vnode (vnode *) for file to be closed.
483 * arg1 is pointer to path (char *) of file to be closed.
484 * arg2 is close flags.
485 * arguments passed to KAUTH_FILEOP_RENAME listeners
486 * arg0 is pointer to "from" path (char *).
487 * arg1 is pointer to "to" path (char *).
488 * arguments passed to KAUTH_FILEOP_EXCHANGE listeners
489 * arg0 is pointer to file 1 path (char *).
490 * arg1 is pointer to file 2 path (char *).
491 * arguments passed to KAUTH_FILEOP_LINK listeners
492 * arg0 is pointer to path to file we are linking to (char *).
493 * arg1 is pointer to path to the new link file (char *).
494 * arguments passed to KAUTH_FILEOP_EXEC listeners
495 * arg0 is pointer to vnode (vnode *) for executable.
496 * arg1 is pointer to path (char *) to executable.
499 /* Flag values returned to close listeners. */
500 #define KAUTH_FILEOP_CLOSE_MODIFIED (1<<1)
503 extern int kauth_authorize_fileop_has_listeners(void);
504 extern int kauth_authorize_fileop(kauth_cred_t _credential
, kauth_action_t _action
,
505 uintptr_t _arg0
, uintptr_t _arg1
);
510 /* Actions, also rights bits in an ACE */
512 #if defined(KERNEL) || defined (_SYS_ACL_H)
513 #define KAUTH_VNODE_READ_DATA (1<<1)
514 #define KAUTH_VNODE_LIST_DIRECTORY KAUTH_VNODE_READ_DATA
515 #define KAUTH_VNODE_WRITE_DATA (1<<2)
516 #define KAUTH_VNODE_ADD_FILE KAUTH_VNODE_WRITE_DATA
517 #define KAUTH_VNODE_EXECUTE (1<<3)
518 #define KAUTH_VNODE_SEARCH KAUTH_VNODE_EXECUTE
519 #define KAUTH_VNODE_DELETE (1<<4)
520 #define KAUTH_VNODE_APPEND_DATA (1<<5)
521 #define KAUTH_VNODE_ADD_SUBDIRECTORY KAUTH_VNODE_APPEND_DATA
522 #define KAUTH_VNODE_DELETE_CHILD (1<<6)
523 #define KAUTH_VNODE_READ_ATTRIBUTES (1<<7)
524 #define KAUTH_VNODE_WRITE_ATTRIBUTES (1<<8)
525 #define KAUTH_VNODE_READ_EXTATTRIBUTES (1<<9)
526 #define KAUTH_VNODE_WRITE_EXTATTRIBUTES (1<<10)
527 #define KAUTH_VNODE_READ_SECURITY (1<<11)
528 #define KAUTH_VNODE_WRITE_SECURITY (1<<12)
529 #define KAUTH_VNODE_TAKE_OWNERSHIP (1<<13)
531 /* backwards compatibility only */
532 #define KAUTH_VNODE_CHANGE_OWNER KAUTH_VNODE_TAKE_OWNERSHIP
534 /* For Windows interoperability only */
535 #define KAUTH_VNODE_SYNCHRONIZE (1<<20)
537 /* (1<<21) - (1<<24) are reserved for generic rights bits */
539 /* Actions not expressed as rights bits */
541 * Authorizes the vnode as the target of a hard link.
543 #define KAUTH_VNODE_LINKTARGET (1<<25)
546 * Indicates that other steps have been taken to authorise the action,
547 * but authorisation should be denied for immutable objects.
549 #define KAUTH_VNODE_CHECKIMMUTABLE (1<<26)
551 /* Action modifiers */
553 * The KAUTH_VNODE_ACCESS bit is passed to the callback if the authorisation
554 * request in progress is advisory, rather than authoritative. Listeners
555 * performing consequential work (i.e. not strictly checking authorisation)
556 * may test this flag to avoid performing unnecessary work.
558 * This bit will never be present in an ACE.
560 #define KAUTH_VNODE_ACCESS (1<<31)
563 * The KAUTH_VNODE_NOIMMUTABLE bit is passed to the callback along with the
564 * KAUTH_VNODE_WRITE_SECURITY bit (and no others) to indicate that the
565 * caller wishes to change one or more of the immutable flags, and the
566 * state of these flags should not be considered when authorizing the request.
567 * The system immutable flags are only ignored when the system securelevel
568 * is low enough to allow their removal.
570 #define KAUTH_VNODE_NOIMMUTABLE (1<<30)
572 /* The expansions of the GENERIC bits at evaluation time */
573 #define KAUTH_VNODE_GENERIC_READ_BITS (KAUTH_VNODE_READ_DATA | \
574 KAUTH_VNODE_READ_ATTRIBUTES | \
575 KAUTH_VNODE_READ_EXTATTRIBUTES | \
576 KAUTH_VNODE_READ_SECURITY)
578 #define KAUTH_VNODE_GENERIC_WRITE_BITS (KAUTH_VNODE_WRITE_DATA | \
579 KAUTH_VNODE_APPEND_DATA | \
580 KAUTH_VNODE_DELETE | \
581 KAUTH_VNODE_DELETE_CHILD | \
582 KAUTH_VNODE_WRITE_ATTRIBUTES | \
583 KAUTH_VNODE_WRITE_EXTATTRIBUTES | \
584 KAUTH_VNODE_WRITE_SECURITY)
586 #define KAUTH_VNODE_GENERIC_EXECUTE_BITS (KAUTH_VNODE_EXECUTE)
588 #define KAUTH_VNODE_GENERIC_ALL_BITS (KAUTH_VNODE_GENERIC_READ_BITS | \
589 KAUTH_VNODE_GENERIC_WRITE_BITS | \
590 KAUTH_VNODE_GENERIC_EXECUTE_BITS)
593 * Some sets of bits, defined here for convenience.
595 #define KAUTH_VNODE_WRITE_RIGHTS (KAUTH_VNODE_ADD_FILE | \
596 KAUTH_VNODE_ADD_SUBDIRECTORY | \
597 KAUTH_VNODE_DELETE_CHILD | \
598 KAUTH_VNODE_WRITE_DATA | \
599 KAUTH_VNODE_APPEND_DATA | \
600 KAUTH_VNODE_DELETE | \
601 KAUTH_VNODE_WRITE_ATTRIBUTES | \
602 KAUTH_VNODE_WRITE_EXTATTRIBUTES | \
603 KAUTH_VNODE_WRITE_SECURITY | \
604 KAUTH_VNODE_TAKE_OWNERSHIP | \
605 KAUTH_VNODE_LINKTARGET | \
606 KAUTH_VNODE_CHECKIMMUTABLE)
609 #endif /* KERNEL || <sys/acl.h> */
612 #include <sys/lock.h> /* lck_grp_t */
617 * XXX this wouldn't be necessary if we had a *real* debug-logging system.
622 void kprintf(const char *fmt
, ...);
624 # define KAUTH_DEBUG_ENABLE
625 # define K_UUID_FMT "%08x:%08x:%08x:%08x"
626 # 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]
627 # define KAUTH_DEBUG(fmt, args...) do { kprintf("%s:%d: " fmt "\n", __PRETTY_FUNCTION__, __LINE__ , ##args); } while (0)
628 # define KAUTH_DEBUG_CTX(_c) KAUTH_DEBUG("p = %p c = %p", _c->vc_proc, _c->vc_ucred)
629 # define VFS_DEBUG(_ctx, _vp, fmt, args...) \
631 kprintf("%p '%s' %s:%d " fmt "\n", \
633 (_vp != NULL && _vp->v_name != NULL) ? _vp->v_name : "????", \
634 __PRETTY_FUNCTION__, __LINE__ , \
638 # define KAUTH_DEBUG(fmt, args...) do { } while (0)
639 # define VFS_DEBUG(ctx, vp, fmt, args...) do { } while(0)
645 extern lck_grp_t
*kauth_lck_grp
;
647 extern void kauth_init(void);
648 extern void kauth_identity_init(void);
649 extern void kauth_groups_init(void);
650 extern void kauth_cred_init(void);
651 extern void kauth_resolver_init(void);
655 #endif /* __APPLE_API_EVOLVING */
656 #endif /* _SYS_KAUTH_H */