summaryrefslogtreecommitdiffstats
path: root/contrib/openbsm/libbsm/bsm_audit.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/openbsm/libbsm/bsm_audit.c')
-rw-r--r--contrib/openbsm/libbsm/bsm_audit.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/contrib/openbsm/libbsm/bsm_audit.c b/contrib/openbsm/libbsm/bsm_audit.c
index 2e07fd8..d959a30 100644
--- a/contrib/openbsm/libbsm/bsm_audit.c
+++ b/contrib/openbsm/libbsm/bsm_audit.c
@@ -30,7 +30,7 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#22 $
+ * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#26 $
*/
#include <sys/types.h>
@@ -280,12 +280,11 @@ au_close(int d, int keep, short event)
return (-1); /* Invalid descriptor */
}
- if (!keep) {
+ if (keep == AU_TO_NO_WRITE) {
retval = 0;
goto cleanup;
}
-
tot_rec_size = rec->len + BSM_HEADER_SIZE + BSM_TRAILER_SIZE;
if (tot_rec_size > MAX_AUDIT_RECORD_SIZE) {
@@ -361,3 +360,24 @@ cleanup:
au_teardown(rec);
return (retval);
}
+
+/*
+ * au_close_token() returns the byte format of a token_t. This won't
+ * generally be used by applications, but is quite useful for writing test
+ * tools. Will free the token on either success or failure.
+ */
+int
+au_close_token(token_t *tok, u_char *buffer, size_t *buflen)
+{
+
+ if (tok->len > *buflen) {
+ au_free_token(tok);
+ errno = ENOMEM;
+ return (EINVAL);
+ }
+
+ memcpy(buffer, tok->t_data, tok->len);
+ *buflen = tok->len;
+ au_free_token(tok);
+ return (0);
+}
OpenPOWER on IntegriCloud