2 * Copyright (c) 2004-2008 Apple Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
29 * $P4: //depot/projects/trustedbsd/openbsm/bsm/libbsm.h#40 $
36 * NB: definitions, etc., marked with "OpenSSH compatibility" were introduced
37 * solely to allow OpenSSH to compile; Darwin/Apple code should not use them.
40 #include <sys/types.h>
41 #include <sys/cdefs.h>
43 #include <inttypes.h> /* Required for audit.h. */
44 #include <time.h> /* Required for clock_t on Linux. */
46 #include <bsm/audit.h>
47 #include <bsm/audit_record.h>
52 #include <mach/mach.h> /* audit_token_t */
56 * Size parsed token vectors for execve(2) arguments and environmental
57 * variables. Note: changing these sizes affects the ABI of the token
58 * structure, and as the token structure is often placed in the caller stack,
59 * this is undesirable.
61 #define AUDIT_MAX_ARGS 128
62 #define AUDIT_MAX_ENV 128
65 * Arguments to au_preselect(3).
67 #define AU_PRS_USECACHE 0
68 #define AU_PRS_REREAD 1
70 #define AU_PRS_SUCCESS 1
71 #define AU_PRS_FAILURE 2
72 #define AU_PRS_BOTH (AU_PRS_SUCCESS|AU_PRS_FAILURE)
74 #define AUDIT_EVENT_FILE "/etc/security/audit_event"
75 #define AUDIT_CLASS_FILE "/etc/security/audit_class"
76 #define AUDIT_CONTROL_FILE "/etc/security/audit_control"
77 #define AUDIT_USER_FILE "/etc/security/audit_user"
79 #define DIR_CONTROL_ENTRY "dir"
80 #define MINFREE_CONTROL_ENTRY "minfree"
81 #define FILESZ_CONTROL_ENTRY "filesz"
82 #define FLAGS_CONTROL_ENTRY "flags"
83 #define NA_CONTROL_ENTRY "naflags"
84 #define POLICY_CONTROL_ENTRY "policy"
85 #define AUDIT_HOST_CONTROL_ENTRY "host"
87 #define AU_CLASS_NAME_MAX 8
88 #define AU_CLASS_DESC_MAX 72
89 #define AU_EVENT_NAME_MAX 30
90 #define AU_EVENT_DESC_MAX 50
91 #define AU_USER_NAME_MAX 50
92 #define AU_LINE_MAX 256
93 #define MAX_AUDITSTRING_LEN 256
94 #define BSM_TEXTBUFSZ MAX_AUDITSTRING_LEN /* OpenSSH compatibility */
97 * Arguments to au_close(3).
99 #define AU_TO_NO_WRITE 0 /* Abandon audit record. */
100 #define AU_TO_WRITE 1 /* Commit audit record. */
103 struct au_event_ent {
104 au_event_t ae_number;
109 typedef struct au_event_ent au_event_ent_t;
111 struct au_class_ent {
116 typedef struct au_class_ent au_class_ent_t;
123 typedef struct au_user_ent au_user_ent_t;
126 #define ADD_TO_MASK(m, c, sel) do { \
127 if (sel & AU_PRS_SUCCESS) \
128 (m)->am_success |= c; \
129 if (sel & AU_PRS_FAILURE) \
130 (m)->am_failure |= c; \
133 #define SUB_FROM_MASK(m, c, sel) do { \
134 if (sel & AU_PRS_SUCCESS) \
135 (m)->am_success &= ((m)->am_success ^ c); \
136 if (sel & AU_PRS_FAILURE) \
137 (m)->am_failure &= ((m)->am_failure ^ c); \
140 #define ADDMASK(m, v) do { \
141 (m)->am_success |= (v)->am_success; \
142 (m)->am_failure |= (v)->am_failure; \
145 #define SUBMASK(m, v) do { \
146 (m)->am_success &= ((m)->am_success ^ (v)->am_success); \
147 (m)->am_failure &= ((m)->am_failure ^ (v)->am_failure); \
152 typedef struct au_tid32 {
157 typedef struct au_tid64 {
162 typedef struct au_tidaddr32 {
168 typedef struct au_tidaddr64 {
176 * argument value 4 bytes/8 bytes (32-bit/64-bit value)
177 * text length 2 bytes
178 * text N bytes + 1 terminating NULL byte
195 * how to print 1 byte
198 * data items (depends on basic unit)
208 * file access mode 4 bytes
209 * owner user ID 4 bytes
210 * owner group ID 4 bytes
211 * file system ID 4 bytes
213 * device 4 bytes/8 bytes (32-bit/64-bit)
235 * text count null-terminated string(s)
239 char *text[AUDIT_MAX_ARGS];
244 * text count null-terminated string(s)
248 char *text[AUDIT_MAX_ENV];
253 * return value 4 bytes
261 * seconds of time 4 bytes
262 * milliseconds of time 4 bytes
263 * file name length 2 bytes
264 * file pathname N bytes + 1 terminating NULL byte
275 * number groups 2 bytes
276 * group list N * 4 bytes
280 u_int32_t list[AUDIT_MAX_GROUPS];
284 * record byte count 4 bytes
285 * version # 1 byte [2]
287 * event modifier 2 bytes
288 * seconds of time 4 bytes/8 bytes (32-bit/64-bit value)
289 * milliseconds of time 4 bytes/8 bytes (32-bit/64-bit value)
301 * record byte count 4 bytes
302 * version # 1 byte [2]
304 * event modifier 2 bytes
305 * address type/length 1 byte (XXX: actually, 4 bytes)
306 * machine address 4 bytes/16 bytes (IPv4/IPv6 address)
307 * seconds of time 4 bytes/8 bytes (32/64-bits)
308 * nanoseconds of time 4 bytes/8 bytes (32/64-bits)
342 * internet address 4 bytes
350 * internet address 16 bytes
358 * version and ihl 1 byte
359 * type of service 1 byte
366 * source address 4 bytes
367 * destination address 4 bytes
383 * object ID type 1 byte
392 * owner user ID 4 bytes
393 * owner group ID 4 bytes
394 * creator user ID 4 bytes
395 * creator group ID 4 bytes
396 * access mode 4 bytes
397 * slot sequence # 4 bytes
411 * port IP address 2 bytes
427 * path length 2 bytes
428 * path N bytes + 1 terminating NULL byte
437 * effective user ID 4 bytes
438 * effective group ID 4 bytes
439 * real user ID 4 bytes
440 * real group ID 4 bytes
444 * port ID 4 bytes/8 bytes (32-bit/64-bit value)
445 * machine address 4 bytes
471 * effective user ID 4 bytes
472 * effective group ID 4 bytes
473 * real user ID 4 bytes
474 * real group ID 4 bytes
478 * port ID 4 bytes/8 bytes (32-bit/64-bit value)
480 * machine address 16 bytes
505 * error status 1 byte
506 * return value 4 bytes/8 bytes (32-bit/64-bit value)
519 * sequence number 4 bytes
526 * socket type 2 bytes
528 * local Internet address 4 bytes
529 * remote port 2 bytes
530 * remote Internet address 4 bytes
541 * socket type 2 bytes
543 * address type/length 4 bytes
544 * local Internet address 4 bytes/16 bytes (IPv4/IPv6 address)
545 * remote port 4 bytes
546 * address type/length 4 bytes
547 * remote Internet address 4 bytes/16 bytes (IPv4/IPv6 address)
560 * socket family 2 bytes
562 * socket address 4 bytes/16 bytes (IPv4/IPv6 address)
571 * socket family 2 bytes
581 * effective user ID 4 bytes
582 * effective group ID 4 bytes
583 * real user ID 4 bytes
584 * real group ID 4 bytes
588 * port ID 4 bytes/8 bytes (32-bit/64-bit value)
589 * machine address 4 bytes
615 * effective user ID 4 bytes
616 * effective group ID 4 bytes
617 * real user ID 4 bytes
618 * real group ID 4 bytes
622 * port ID 4 bytes/8 bytes (32-bit/64-bit value)
624 * machine address 16 bytes
649 * text length 2 bytes
650 * text N bytes + 1 terminating NULL byte
658 * zonename length 2 bytes
659 * zonename text N bytes + 1 NULL terminator
680 * trailer magic number 2 bytes
681 * record byte count 4 bytes
698 au_execarg_t execarg;
699 au_execenv_t execenv;
704 au_header32_ex_t hdr32_ex;
706 au_header64_ex_t hdr64_ex;
708 au_inaddr_ex_t inaddr_ex;
711 au_ipcperm_t ipcperm;
716 au_proc32ex_t proc32_ex;
718 au_proc64ex_t proc64_ex;
723 au_socket_ex32_t socket_ex32;
724 au_socketinet32_t sockinet32;
725 au_socketunix_t sockunix;
726 au_subject32_t subj32;
727 au_subject32ex_t subj32_ex;
728 au_subject64_t subj64;
729 au_subject64ex_t subj64_ex;
732 au_invalid_t invalid;
734 au_zonename_t zonename;
735 } tt; /* The token is one of the above types */
738 typedef struct tokenstr tokenstr_t;
740 int audit_submit(short au_event, au_id_t auid,
741 char status, int reterr, const char *fmt, ...);
744 * Functions relating to querying audit class information.
746 void setauclass(void);
747 void endauclass(void);
748 struct au_class_ent *getauclassent(void);
749 struct au_class_ent *getauclassent_r(au_class_ent_t *class_int);
750 struct au_class_ent *getauclassnam(const char *name);
751 struct au_class_ent *getauclassnam_r(au_class_ent_t *class_int,
753 struct au_class_ent *getauclassnum(au_class_t class_number);
754 struct au_class_ent *getauclassnum_r(au_class_ent_t *class_int,
755 au_class_t class_number);
758 * Functions relating to querying audit control information.
762 int getacdir(char *name, int len);
763 int getacmin(int *min_val);
764 int getacfilesz(size_t *size_val);
765 int getacflg(char *auditstr, int len);
766 int getacna(char *auditstr, int len);
767 int getacpol(char *auditstr, size_t len);
768 int getachost(char *auditstr, size_t len);
769 int getauditflagsbin(char *auditstr, au_mask_t *masks);
770 int getauditflagschar(char *auditstr, au_mask_t *masks,
772 int au_preselect(au_event_t event, au_mask_t *mask_p,
774 ssize_t au_poltostr(long policy, size_t maxsize, char *buf);
775 int au_strtopol(const char *polstr, long *policy);
778 * Functions relating to querying audit event information.
780 void setauevent(void);
781 void endauevent(void);
782 struct au_event_ent *getauevent(void);
783 struct au_event_ent *getauevent_r(struct au_event_ent *e);
784 struct au_event_ent *getauevnam(const char *name);
785 struct au_event_ent *getauevnam_r(struct au_event_ent *e,
787 struct au_event_ent *getauevnum(au_event_t event_number);
788 struct au_event_ent *getauevnum_r(struct au_event_ent *e,
789 au_event_t event_number);
790 au_event_t *getauevnonam(const char *event_name);
791 au_event_t *getauevnonam_r(au_event_t *ev,
792 const char *event_name);
795 * Functions relating to querying audit user information.
797 void setauuser(void);
798 void endauuser(void);
799 struct au_user_ent *getauuserent(void);
800 struct au_user_ent *getauuserent_r(struct au_user_ent *u);
801 struct au_user_ent *getauusernam(const char *name);
802 struct au_user_ent *getauusernam_r(struct au_user_ent *u,
804 int au_user_mask(char *username, au_mask_t *mask_p);
805 int getfauditflags(au_mask_t *usremask,
806 au_mask_t *usrdmask, au_mask_t *lastmask);
809 * Functions for reading and printing records and tokens from audit trails.
811 int au_read_rec(FILE *fp, u_char **buf);
812 int au_fetch_tok(tokenstr_t *tok, u_char *buf, int len);
813 //XXX The following interface has different prototype from BSM
814 void au_print_tok(FILE *outfp, tokenstr_t *tok,
815 char *del, char raw, char sfrm);
816 void au_print_tok_xml(FILE *outfp, tokenstr_t *tok,
817 char *del, char raw, char sfrm);
820 * Functions relating to XML output.
822 void au_print_xml_header(FILE *outfp);
823 void au_print_xml_footer(FILE *outfp);
827 * Functions relating to BSM<->errno conversion.
829 int au_bsm_to_errno(u_char bsm_error, int *errorp);
830 u_char au_errno_to_bsm(int error);
831 const char *au_strerror(u_char bsm_error);
834 * The remaining APIs are associated with Apple's BSM implementation, in
835 * particular as relates to Mach IPC auditing and triggers passed via Mach
839 #include <sys/appleapiopts.h>
841 /**************************************************************************
842 **************************************************************************
843 ** The following definitions, functions, etc., are NOT officially
844 ** supported: they may be changed or removed in the future. Do not use
845 ** them unless you are prepared to cope with that eventuality.
846 **************************************************************************
847 **************************************************************************/
849 #ifdef __APPLE_API_PRIVATE
850 #define __BSM_INTERNAL_NOTIFY_KEY "com.apple.audit.change"
851 #endif /* __APPLE_API_PRIVATE */
854 * au_get_state() return values
855 * XXX use AUC_* values directly instead (<bsm/audit.h>); AUDIT_OFF and
856 * AUDIT_ON are deprecated and WILL be removed.
858 #ifdef __APPLE_API_PRIVATE
859 #define AUDIT_OFF AUC_NOAUDIT
860 #define AUDIT_ON AUC_AUDITING
861 #endif /* __APPLE_API_PRIVATE */
862 #endif /* !__APPLE__ */
865 * Error return codes for audit_set_terminal_id(), audit_write() and its
866 * brethren. We have 255 (not including kAUNoErr) to play with.
868 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
872 kAUBadParamErr = -66049,
876 kAUMakeSubjectTokErr,
877 kAUWriteSubjectTokErr,
878 kAUWriteCallerTokErr,
880 kAUWriteReturnTokErr,
888 * Error return codes for au_get_state() and/or its private support
889 * functions. These codes are designed to be compatible with the
890 * NOTIFY_STATUS_* codes defined in <notify.h> but non-overlapping.
891 * Any changes to notify(3) may cause these values to change in future.
893 * AU_UNIMPL should never happen unless you've changed your system software
894 * without rebooting. Shame on you.
896 #ifdef __APPLE_API_PRIVATE
897 #define AU_UNIMPL NOTIFY_STATUS_FAILED + 1 /* audit unimplemented */
898 #endif /* __APPLE_API_PRIVATE */
899 #endif /* !__APPLE__ */
903 * XXX This prototype should be in audit_record.h
907 * @summary - au_free_token() deallocates a token_t created by any of
908 * the au_to_*() BSM API functions.
910 * The BSM API generally manages deallocation of token_t objects. However,
911 * if au_write() is passed a bad audit descriptor, the token_t * parameter
912 * will be left untouched. In that case, the caller can deallocate the
913 * token_t using au_free_token() if desired. This is, in fact, what
914 * audit_write() does, in keeping with the existing memory management model
917 * @param tok - A token_t * generated by one of the au_to_*() BSM API
918 * calls. For convenience, tok may be NULL, in which case
919 * au_free_token() returns immediately.
921 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
923 void au_free_token(token_t *tok);
926 * Lightweight check to determine if auditing is enabled. If a client
927 * wants to use this to govern whether an entire series of audit calls
928 * should be made--as in the common case of a caller building a set of
929 * tokens, then writing them--it should cache the audit status in a local
930 * variable. This call always returns the current state of auditing.
932 * @return - AUC_AUDITING or AUC_NOAUDIT if no error occurred.
933 * Otherwise the function can return any of the errno values defined for
934 * setaudit(2), or AU_UNIMPL if audit does not appear to be supported by
937 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
939 int au_get_state(void);
942 * Initialize the audit notification. If it has not already been initialized
943 * it will automatically on the first call of au_get_state().
945 uint32_t au_notify_initialize(void);
948 * Cancel audit notification and free the resources associated with it.
949 * Responsible code that no longer needs to use au_get_state() should call
952 int au_notify_terminate(void);
955 /* OpenSSH compatibility */
956 int cannot_audit(int);
960 * audit_set_terminal_id()
962 * @summary - audit_set_terminal_id() fills in an au_tid_t struct, which is
963 * used in audit session initialization by processes like /usr/bin/login.
965 * @param tid - A pointer to an au_tid_t struct.
967 * @return - kAUNoErr on success; kAUBadParamErr if tid is NULL, kAUStatErr
968 * or kAUSysctlErr if one of the underlying system calls fails (a message
969 * is sent to the system log in those cases).
971 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
973 int audit_set_terminal_id(au_tid_t *tid);
976 * BEGIN au_write() WRAPPERS
978 * The following calls all wrap the existing BSM API. They use the
979 * provided subject information, if any, to construct the subject token
980 * required for every log message. They use the provided return/error
981 * value(s), if any, to construct the success/failure indication required
982 * for every log message. They only permit one "miscellaneous" token,
983 * which should contain the event-specific logging information mandated by
986 * All these calls assume the caller has previously determined that
987 * auditing is enabled by calling au_get_state().
993 * @summary - audit_write() is the basis for the other audit_write_*()
994 * calls. Performs a basic write of an audit record (subject, additional
995 * info, success/failure). Note that this call only permits logging one
996 * caller-specified token; clients needing to log more flexibly must use
997 * the existing BSM API (au_open(), et al.) directly.
999 * Note on memory management: audit_write() guarantees that the token_t *s
1000 * passed to it will be deallocated whether or not the underlying write to
1001 * the audit log succeeded. This addresses an inconsistency in the
1002 * underlying BSM API in which token_t *s are usually but not always
1005 * @param event_code - The code for the event being logged. This should
1006 * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h.
1008 * @param subject - A token_t * generated by au_to_subject(),
1009 * au_to_subject32(), au_to_subject64(), or au_to_me(). If no subject is
1010 * required, subject should be NULL.
1012 * @param misctok - A token_t * generated by one of the au_to_*() BSM API
1013 * calls. This should correspond to the additional information required by
1014 * CAPP for the event being audited. If no additional information is
1015 * required, misctok should be NULL.
1017 * @param retval - The return value to be logged for this event. This
1018 * should be 0 (zero) for success, otherwise the value is event-specific.
1020 * @param errcode - Any error code associated with the return value (e.g.,
1021 * errno or h_errno). If there was no error, errcode should be 0 (zero).
1023 * @return - The status of the call: 0 (zero) on success, else one of the
1024 * kAU*Err values defined above.
1026 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
1028 int audit_write(short event_code, token_t *subject, token_t *misctok,
1029 char retval, int errcode);
1032 * audit_write_success()
1034 * @summary - audit_write_success() records an auditable event that did not
1035 * encounter an error. The interface is designed to require as little
1036 * direct use of the au_to_*() API as possible. It builds a subject token
1037 * from the information passed in and uses that to invoke audit_write().
1038 * A subject, as defined by CAPP, is a process acting on the user's behalf.
1040 * If the subject information is the same as the current process, use
1041 * au_write_success_self().
1043 * @param event_code - The code for the event being logged. This should
1044 * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h.
1046 * @param misctok - A token_t * generated by one of the au_to_*() BSM API
1047 * calls. This should correspond to the additional information required by
1048 * CAPP for the event being audited. If no additional information is
1049 * required, misctok should be NULL.
1051 * @param auid - The subject's audit ID.
1053 * @param euid - The subject's effective user ID.
1055 * @param egid - The subject's effective group ID.
1057 * @param ruid - The subject's real user ID.
1059 * @param rgid - The subject's real group ID.
1061 * @param pid - The subject's process ID.
1063 * @param sid - The subject's session ID.
1065 * @param tid - The subject's terminal ID.
1067 * @return - The status of the call: 0 (zero) on success, else one of the
1068 * kAU*Err values defined above.
1070 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
1072 int audit_write_success(short event_code, token_t *misctok, au_id_t auid,
1073 uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid,
1074 au_asid_t sid, au_tid_t *tid);
1077 * audit_write_success_self()
1079 * @summary - Similar to audit_write_success(), but used when the subject
1080 * (process) is owned and operated by the auditable user him/herself.
1082 * @param event_code - The code for the event being logged. This should
1083 * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h.
1085 * @param misctok - A token_t * generated by one of the au_to_*() BSM API
1086 * calls. This should correspond to the additional information required by
1087 * CAPP for the event being audited. If no additional information is
1088 * required, misctok should be NULL.
1090 * @return - The status of the call: 0 (zero) on success, else one of the
1091 * kAU*Err values defined above.
1093 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
1095 int audit_write_success_self(short event_code, token_t *misctok);
1098 * audit_write_failure()
1100 * @summary - audit_write_failure() records an auditable event that
1101 * encountered an error. The interface is designed to require as little
1102 * direct use of the au_to_*() API as possible. It builds a subject token
1103 * from the information passed in and uses that to invoke audit_write().
1104 * A subject, as defined by CAPP, is a process acting on the user's behalf.
1106 * If the subject information is the same as the current process, use
1107 * au_write_failure_self().
1109 * @param event_code - The code for the event being logged. This should
1110 * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h.
1112 * @param errmsg - A text message providing additional information about
1113 * the event being audited.
1115 * @param errret - A numerical value providing additional information about
1116 * the error. This is intended to store the value of errno or h_errno if
1117 * it's relevant. This can be 0 (zero) if no additional information is
1120 * @param auid - The subject's audit ID.
1122 * @param euid - The subject's effective user ID.
1124 * @param egid - The subject's effective group ID.
1126 * @param ruid - The subject's real user ID.
1128 * @param rgid - The subject's real group ID.
1130 * @param pid - The subject's process ID.
1132 * @param sid - The subject's session ID.
1134 * @param tid - The subject's terminal ID.
1136 * @return - The status of the call: 0 (zero) on success, else one of the
1137 * kAU*Err values defined above.
1139 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
1141 int audit_write_failure(short event_code, char *errmsg, int errret,
1142 au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid,
1143 pid_t pid, au_asid_t sid, au_tid_t *tid);
1146 * audit_write_failure_self()
1148 * @summary - Similar to audit_write_failure(), but used when the subject
1149 * (process) is owned and operated by the auditable user him/herself.
1151 * @param event_code - The code for the event being logged. This should
1152 * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h.
1154 * @param errmsg - A text message providing additional information about
1155 * the event being audited.
1157 * @param errret - A numerical value providing additional information about
1158 * the error. This is intended to store the value of errno or h_errno if
1159 * it's relevant. This can be 0 (zero) if no additional information is
1162 * @return - The status of the call: 0 (zero) on success, else one of the
1163 * kAU*Err values defined above.
1165 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
1167 int audit_write_failure_self(short event_code, char *errmsg, int errret);
1170 * audit_write_failure_na()
1172 * @summary - audit_write_failure_na() records errors during login. Such
1173 * errors are implicitly non-attributable (i.e., not ascribable to any user).
1175 * @param event_code - The code for the event being logged. This should
1176 * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h.
1178 * @param errmsg - A text message providing additional information about
1179 * the event being audited.
1181 * @param errret - A numerical value providing additional information about
1182 * the error. This is intended to store the value of errno or h_errno if
1183 * it's relevant. This can be 0 (zero) if no additional information is
1186 * @param euid - The subject's effective user ID.
1188 * @param egid - The subject's effective group ID.
1190 * @param pid - The subject's process ID.
1192 * @param tid - The subject's terminal ID.
1194 * @return - The status of the call: 0 (zero) on success, else one of the
1195 * kAU*Err values defined above.
1197 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
1199 int audit_write_failure_na(short event_code, char *errmsg, int errret,
1200 uid_t euid, gid_t egid, pid_t pid, au_tid_t *tid);
1202 /* END au_write() WRAPPERS */
1206 * audit_token_to_au32()
1208 * @summary - Extract information from an audit_token_t, used to identify
1209 * Mach tasks and senders of Mach messages as subjects to the audit system.
1210 * audit_tokent_to_au32() is the only method that should be used to parse
1211 * an audit_token_t, since its internal representation may change over
1212 * time. A pointer parameter may be NULL if that information is not
1215 * @param atoken - the audit token containing the desired information
1217 * @param auidp - Pointer to a uid_t; on return will be set to the task or
1218 * sender's audit user ID
1220 * @param euidp - Pointer to a uid_t; on return will be set to the task or
1221 * sender's effective user ID
1223 * @param egidp - Pointer to a gid_t; on return will be set to the task or
1224 * sender's effective group ID
1226 * @param ruidp - Pointer to a uid_t; on return will be set to the task or
1227 * sender's real user ID
1229 * @param rgidp - Pointer to a gid_t; on return will be set to the task or
1230 * sender's real group ID
1232 * @param pidp - Pointer to a pid_t; on return will be set to the task or
1233 * sender's process ID
1235 * @param asidp - Pointer to an au_asid_t; on return will be set to the
1236 * task or sender's audit session ID
1238 * @param tidp - Pointer to an au_tid_t; on return will be set to the task
1239 * or sender's terminal ID
1241 * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
1243 void audit_token_to_au32(
1244 audit_token_t atoken,
1253 #endif /* !__APPLE__ */
1257 #endif /* !_LIBBSM_H_ */