summaryrefslogtreecommitdiff
path: root/audit-bsm.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2012-02-24 10:40:41 +1100
committerDarren Tucker <dtucker@zip.com.au>2012-02-24 10:40:41 +1100
commit93a2d41505981a9f4fd5f1cffec713622215910e (patch)
tree90334628420d9d4366f804a9bd53717251fd5d68 /audit-bsm.c
parenta3f297de91b58282e16f70efdceab9715f0068fb (diff)
- (dtucker) [audit-bsm.c configure.ac] bug #1968: enable workarounds for BSM
audit breakage in Solaris 11. Patch from Magnus Johansson.
Diffstat (limited to 'audit-bsm.c')
-rw-r--r--audit-bsm.c79
1 files changed, 78 insertions, 1 deletions
diff --git a/audit-bsm.c b/audit-bsm.c
index f196d4f1e..613559140 100644
--- a/audit-bsm.c
+++ b/audit-bsm.c
@@ -1,4 +1,4 @@
1/* $Id: audit-bsm.c,v 1.7 2011/01/17 10:15:29 dtucker Exp $ */ 1/* $Id: audit-bsm.c,v 1.8 2012/02/23 23:40:43 dtucker Exp $ */
2 2
3/* 3/*
4 * TODO 4 * TODO
@@ -45,6 +45,10 @@
45#include <string.h> 45#include <string.h>
46#include <unistd.h> 46#include <unistd.h>
47 47
48#ifdef BROKEN_BSM_API
49#include <libscf.h>
50#endif
51
48#include "ssh.h" 52#include "ssh.h"
49#include "log.h" 53#include "log.h"
50#include "key.h" 54#include "key.h"
@@ -114,6 +118,12 @@ extern int aug_daemon_session(void);
114extern Authctxt *the_authctxt; 118extern Authctxt *the_authctxt;
115static AuditInfoTermID ssh_bsm_tid; 119static AuditInfoTermID ssh_bsm_tid;
116 120
121#ifdef BROKEN_BSM_API
122/* For some reason this constant is no longer defined
123 in Solaris 11. */
124#define BSM_TEXTBUFSZ 256
125#endif
126
117/* Below is the low-level BSM interface code */ 127/* Below is the low-level BSM interface code */
118 128
119/* 129/*
@@ -161,6 +171,65 @@ aug_get_machine(char *host, u_int32_t *addr, u_int32_t *type)
161} 171}
162#endif 172#endif
163 173
174#ifdef BROKEN_BSM_API
175/*
176 In Solaris 11 the audit daemon has been moved to SMF. In the process
177 they simply dropped getacna() from the API, since it read from a now
178 non-existent config file. This function re-implements getacna() to
179 read from the SMF repository instead.
180 */
181int
182getacna(char *auditstring, int len)
183{
184 scf_handle_t *handle = NULL;
185 scf_property_t *property = NULL;
186 scf_value_t *value = NULL;
187 int ret = 0;
188
189 handle = scf_handle_create(SCF_VERSION);
190 if (handle == NULL)
191 return -2; /* The man page for getacna on Solaris 10 states
192 we should return -2 in case of error and set
193 errno to indicate the error. We don't bother
194 with errno here, though, since the only use
195 of this function below doesn't check for errors
196 anyway.
197 */
198
199 ret = scf_handle_bind(handle);
200 if (ret == -1)
201 return -2;
202
203 property = scf_property_create(handle);
204 if (property == NULL)
205 return -2;
206
207 ret = scf_handle_decode_fmri(handle,
208 "svc:/system/auditd:default/:properties/preselection/naflags",
209 NULL, NULL, NULL, NULL, property, 0);
210 if (ret == -1)
211 return -2;
212
213 value = scf_value_create(handle);
214 if (value == NULL)
215 return -2;
216
217 ret = scf_property_get_value(property, value);
218 if (ret == -1)
219 return -2;
220
221 ret = scf_value_get_astring(value, auditstring, len);
222 if (ret == -1)
223 return -2;
224
225 scf_value_destroy(value);
226 scf_property_destroy(property);
227 scf_handle_destroy(handle);
228
229 return 0;
230}
231#endif
232
164/* 233/*
165 * Check if the specified event is selected (enabled) for auditing. 234 * Check if the specified event is selected (enabled) for auditing.
166 * Returns 1 if the event is selected, 0 if not and -1 on failure. 235 * Returns 1 if the event is selected, 0 if not and -1 on failure.
@@ -213,7 +282,15 @@ bsm_audit_record(int typ, char *string, au_event_t event_no)
213 (void) au_write(ad, au_to_text(string)); 282 (void) au_write(ad, au_to_text(string));
214 (void) au_write(ad, AUToReturnFunc(typ, rc)); 283 (void) au_write(ad, AUToReturnFunc(typ, rc));
215 284
285#ifdef BROKEN_BSM_API
286 /* The last argument is the event modifier flags. For
287 some seemingly undocumented reason it was added in
288 Solaris 11. */
289 rc = au_close(ad, AU_TO_WRITE, event_no, 0);
290#else
216 rc = au_close(ad, AU_TO_WRITE, event_no); 291 rc = au_close(ad, AU_TO_WRITE, event_no);
292#endif
293
217 if (rc < 0) 294 if (rc < 0)
218 error("BSM audit: %s failed to write \"%s\" record: %s", 295 error("BSM audit: %s failed to write \"%s\" record: %s",
219 __func__, string, strerror(errno)); 296 __func__, string, strerror(errno));