---
name: "bsm"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/au_fcntl_cmd_to_bsm"
---

# bsm(3)

Basic Security Module (BSM) Audit API

Part of [au\_fcntl\_cmd\_to\_bsm(3)](/au_fcntl_cmd_to_bsm/3.md).

## NAME

**libbsm** – Basic Security Module (BSM) Audit API

## LIBRARY

library “libbsm”

## SYNOPSIS

**#include \<bsm/libbsm.h\>**

## DESCRIPTION

The **libbsm** library routines provide an interface to BSM audit record streams, allowing both the parsing of existing audit streams, as well as the creation of new audit records and streams.

## INTERFACES

The **libbsm** library provides a large number of Audit programming interfaces in several classes: event stream interfaces, class interfaces, control interfaces, event interfaces, I/O interfaces, mask interfaces, notification interfaces, token interfaces, and user interfaces. These are described respectively in the [au\_class(3)](/au_class/3.md), [au\_control(3)](/au_control/3.md), [au\_event(3)](/au_event/3.md), [au\_mask(3)](/au_mask/3.md), [au\_notify(3)](/au_notify/3.md), au\_stream(3), [au\_token(3)](/au_token/3.md), and [au\_user(3)](/au_user/3.md) manual pages.

### Audit Event Stream Interfaces

Audit event stream interfaces support interaction with file-backed audit event streams: [au\_close(3)](/au_close/3.md), [au\_close\_buffer(3)](/au_close_buffer/3.md), [au\_free\_token(3)](/au_free_token/3.md), [au\_open(3)](/au_open/3.md), [au\_write(3)](/au_write/3.md), [audit\_submit(3)](/audit_submit/3.md).

### Audit Class Interfaces

Audit class interfaces support the look up of information from the [audit\_class(5)](/audit_class/5.md) database: [endauclass(3)](/endauclass/3.md), [getauclassent(3)](/getauclassent/3.md), [getauclassent\_r(3)](/getauclassent_r/3.md), [getauclassnam(3)](/getauclassnam/3.md), [getauclassnam\_r(3)](/getauclassnam_r/3.md), [setauclass(3)](/setauclass/3.md).

### Audit Control Interfaces

Audit control interfaces support the look up of information from the [audit\_control(5)](/audit_control/5.md) database: [endac(3)](/endac/3.md), [setac(3)](/setac/3.md), [getacdir(3)](/getacdir/3.md), [getacfilesz(3)](/getacfilesz/3.md), [getacflg(3)](/getacflg/3.md), [getacmin(3)](/getacmin/3.md), [getacna(3)](/getacna/3.md), [getacpol(3)](/getacpol/3.md), [au\_poltostr(3)](/au_poltostr/3.md), [au\_strtopol(3)](/au_strtopol/3.md).

### Audit Event Interfaces

Audit event interfaces support the look up of information from the [audit\_event(5)](/audit_event/5.md) database: [endauevent(3)](/endauevent/3.md), [setauevent(3)](/setauevent/3.md), [getauevent(3)](/getauevent/3.md), [getauevent\_r(3)](/getauevent_r/3.md), [getauevnam(3)](/getauevnam/3.md), [getauevnam\_r(3)](/getauevnam_r/3.md), [getauevnonam(3)](/getauevnonam/3.md), [getauevnonam\_r(3)](/getauevnonam_r/3.md), [getauevnum(3)](/getauevnum/3.md), [getauevnum\_r(3)](/getauevnum_r/3.md).

### Audit I/O Interfaces

Audit I/O interfaces support the processing and printing of tokens, as well as the reading of audit records: [au\_fetch\_tok(3)](/au_fetch_tok/3.md), [au\_print\_tok(3)](/au_print_tok/3.md), [au\_read\_rec(3)](/au_read_rec/3.md).

### Audit Mask Interfaces

Audit mask interfaces convert support the conversion between strings and *au\_mask\_t* values. They may also be used to determine if a particular audit event is matched by a mask: [au\_preselect(3)](/au_preselect/3.md), [getauditflagsbin(3)](/getauditflagsbin/3.md), [getauditflagschar(3)](/getauditflagschar/3.md).

### Audit Notification Interfaces

Audit notification routines track audit state in a form permitting efficient update, avoiding frequent system calls to check the kernel audit state: [au\_get\_state(3)](/au_get_state/3.md), [au\_notify\_initialize(3)](/au_notify_initialize/3.md), [au\_notify\_terminate(3)](/au_notify_terminate/3.md). These interfaces are implemented only for Darwin/Mac OS X.

### Audit Token Interface

Audit token interfaces permit the creation of tokens for use in creating audit records for submission to event streams. Each interface converts a C type to its *token\_t* representation: [au\_to\_arg(3)](/au_to_arg/3.md), [au\_to\_arg32(3)](/au_to_arg32/3.md), [au\_to\_arg64(3)](/au_to_arg64/3.md), [au\_to\_attr64(3)](/au_to_attr64/3.md), [au\_to\_data(3)](/au_to_data/3.md), [au\_to\_exec\_args(3)](/au_to_exec_args/3.md), [au\_to\_exec\_env(3)](/au_to_exec_env/3.md), [au\_to\_exit(3)](/au_to_exit/3.md), [au\_to\_file(3)](/au_to_file/3.md), [au\_to\_groups(3)](/au_to_groups/3.md), [au\_to\_header32(3)](/au_to_header32/3.md), [au\_to\_header64(3)](/au_to_header64/3.md), [au\_to\_in\_addr(3)](/au_to_in_addr/3.md), [au\_to\_in\_addr\_ex(3)](/au_to_in_addr_ex/3.md), [au\_to\_ip(3)](/au_to_ip/3.md), [au\_to\_ipc(3)](/au_to_ipc/3.md), [au\_to\_ipc\_perm(3)](/au_to_ipc_perm/3.md), [au\_to\_iport(3)](/au_to_iport/3.md), [au\_to\_me(3)](/au_to_me/3.md), [au\_to\_newgroups(3)](/au_to_newgroups/3.md), [au\_to\_opaque(3)](/au_to_opaque/3.md), [au\_to\_path(3)](/au_to_path/3.md), [au\_to\_process(3)](/au_to_process/3.md), [au\_to\_process32(3)](/au_to_process32/3.md), [au\_to\_process64(3)](/au_to_process64/3.md), [au\_to\_process\_ex(3)](/au_to_process_ex/3.md), [au\_to\_process32\_ex(3)](/au_to_process32_ex/3.md), [au\_to\_process64\_ex(3)](/au_to_process64_ex/3.md), [au\_to\_return(3)](/au_to_return/3.md), [au\_to\_return32(3)](/au_to_return32/3.md), [au\_to\_return64(3)](/au_to_return64/3.md), [au\_to\_seq(3)](/au_to_seq/3.md), [au\_to\_sock\_inet(3)](/au_to_sock_inet/3.md), [au\_to\_sock\_inet32(3)](/au_to_sock_inet32/3.md), [au\_to\_sock\_inet128(3)](/au_to_sock_inet128/3.md), [au\_to\_socket\_ex(3)](/au_to_socket_ex/3.md), [au\_to\_subject(3)](/au_to_subject/3.md), [au\_to\_subject32(3)](/au_to_subject32/3.md), [au\_to\_subject64(3)](/au_to_subject64/3.md), [au\_to\_subject\_ex(3)](/au_to_subject_ex/3.md), [au\_to\_subject32\_ex(3)](/au_to_subject32_ex/3.md), [au\_to\_subject64\_ex(3)](/au_to_subject64_ex/3.md), [au\_to\_text(3)](/au_to_text/3.md), [au\_to\_trailer(3)](/au_to_trailer/3.md), [au\_to\_zonename(3)](/au_to_zonename/3.md).

### Audit User Interfaces

Audit user interfaces support the look up of information from the [audit\_user(5)](/audit_user/5.md) database: [au\_user\_mask(3)](/au_user_mask/3.md), [endauuser(3)](/endauuser/3.md), [setauuser(3)](/setauuser/3.md), [getauuserent(3)](/getauuserent/3.md), [getauuserent\_r(3)](/getauuserent_r/3.md), [getauusernam(3)](/getauusernam/3.md), [getauusernam\_r(3)](/getauusernam_r/3.md), [getfauditflags(3)](/getfauditflags/3.md).

### Audit Constant Conversion Interfaces

These functions convert between BSM and local constants, including the [errno(2)](/errno/2.md) number, socket type, and protocol famil spaces, and must be used to generate and interpret BSM return and extended socket tokens: [au\_bsm\_to\_domain(3)](/au_bsm_to_domain/3.md), [au\_bsm\_to\_errno(3)](/au_bsm_to_errno/3.md), [au\_bsm\_to\_fcntl\_cmd(3)](/au_bsm_to_fcntl_cmd/3.md), [au\_bsm\_to\_socket\_type(3)](/au_bsm_to_socket_type/3.md), [au\_domain\_to\_bsm(3)](/au_domain_to_bsm/3.md), [au\_errno\_to\_bsm(3)](/au_errno_to_bsm/3.md), [au\_fcntl\_cmd\_to\_bsm(3)](/au_fcntl_cmd_to_bsm/3.md), [au\_socket\_type\_to\_bsm(3)](/au_socket_type_to_bsm/3.md).

## SEE ALSO

[au\_class(3)](/au_class/3.md), [au\_domain(3)](/au_domain/3.md), [au\_errno(3)](/au_errno/3.md), [au\_mask(3)](/au_mask/3.md), [au\_notify(3)](/au_notify/3.md), [au\_socket\_type(3)](/au_socket_type/3.md), au\_stream(3), [au\_token(3)](/au_token/3.md), [au\_user(3)](/au_user/3.md), [audit\_submit(3)](/audit_submit/3.md), [audit\_class(5)](/audit_class/5.md), [audit\_control(5)](/audit_control/5.md)

## HISTORY

The OpenBSM implementation was created by McAfee Research, the security division of McAfee Inc., under contract to Apple Computer, Inc., in 2004. It was subsequently adopted by the TrustedBSD Project as the foundation for the OpenBSM distribution.

## AUTHORS

This software was created by Robert Watson, Wayne Salamon, and Suresh Krishnaswamy for McAfee Research, the security research division of McAfee, Inc., under contract to Apple Computer, Inc.

The Basic Security Module (BSM) interface to audit records and audit event stream format were defined by Sun Microsystems.

## BUGS

Bugs would not be unlikely.

The **libbsm** library implementations are generally thread-safe, but not reentrant.

The assignment of routines to classes could use some work, as it is decidely ad hoc. For example, **au\_read\_rec**() should probably be considered a stream routine.
