Deleted Added
full compact
bsm_notify.c (155131) bsm_notify.c (155518)
1/*
2 * Copyright (c) 2004 Apple Computer, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

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.
28 *
1/*
2 * Copyright (c) 2004 Apple Computer, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

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.
28 *
29 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_notify.c#8 $
29 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_notify.c#9 $
30 */
31
30 */
31
32#ifdef __APPLE__
33
34/*
35 * Based on sample code from Marc Majka.
36 */
32/*
33 * Based on sample code from Marc Majka.
34 */
37#include <notify.h>
38#include <string.h> /* strerror() */
39#include <sys/errno.h> /* errno */
40#include <bsm/libbsm.h>
41#include <stdint.h> /* uint32_t */
42#include <syslog.h> /* syslog() */
43#include <stdarg.h> /* syslog() */
44
35#include <string.h> /* strerror() */
36#include <sys/errno.h> /* errno */
37#include <bsm/libbsm.h>
38#include <stdint.h> /* uint32_t */
39#include <syslog.h> /* syslog() */
40#include <stdarg.h> /* syslog() */
41
42#ifdef __APPLE__
43#include <notify.h>
45/* If 1, assumes a kernel that sends the right notification. */
46#define AUDIT_NOTIFICATION_ENABLED 1
47
48#if AUDIT_NOTIFICATION_ENABLED
49static int token = 0;
50#endif /* AUDIT_NOTIFICATION_ENABLED */
51
52static long au_cond = AUC_UNSET; /* <bsm/audit.h> */

--- 87 unchanged lines hidden (view full) ---

140 return (AUC_NOAUDIT);
141
142 case AUC_UNSET: /* Uninitialized; shouldn't get here. */
143 case AUC_AUDITING: /* Audit on. */
144 default:
145 return (AUC_AUDITING);
146 }
147}
44/* If 1, assumes a kernel that sends the right notification. */
45#define AUDIT_NOTIFICATION_ENABLED 1
46
47#if AUDIT_NOTIFICATION_ENABLED
48static int token = 0;
49#endif /* AUDIT_NOTIFICATION_ENABLED */
50
51static long au_cond = AUC_UNSET; /* <bsm/audit.h> */

--- 87 unchanged lines hidden (view full) ---

139 return (AUC_NOAUDIT);
140
141 case AUC_UNSET: /* Uninitialized; shouldn't get here. */
142 case AUC_AUDITING: /* Audit on. */
143 default:
144 return (AUC_AUDITING);
145 }
146}
147#endif /* !__APPLE__ */
148
148
149#endif /* !__APPLE__ */
149int
150cannot_audit(int val __unused)
151{
152#ifdef __APPLE__
153 return (!(au_get_state() == AUC_AUDITING));
154#else
155 unsigned long au_cond;
156
157 if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) {
158 if (errno != ENOSYS) {
159 syslog(LOG_ERR, "Audit status check failed (%s)",
160 strerror(errno));
161 }
162 return (1);
163 }
164 if (au_cond == AUC_NOAUDIT || au_cond == AUC_DISABLED)
165 return (1);
166 return (0);
167#endif /* !__APPLE__ */
168}