xref: /freebsd/contrib/openbsm/libbsm/au_errno.3 (revision 1f4bcc459a76b7aa664f3fd557684cd0ba6da352)
1.\"-
2.\" Copyright (c) 2008 Apple 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
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.
16.\"
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.
28.\"
29.Dd December 8, 2008
30.Dt AU_BSM_TO_ERRNO 3
31.Os
32.Sh NAME
33.Nm au_bsm_to_errno ,
34.Nm au_errno_to_bsm ,
35.Nm au_strerror
36.Nd "convert between BSM and local error numbers"
37.Sh LIBRARY
38.Lb libbsm
39.Sh SYNOPSIS
40.In bsm/libbsm.h
41.Ft int
42.Fn au_bsm_to_errno "u_char bsm_error" "int *errorp"
43.Ft u_char
44.Fn au_errno_to_bsm "int error"
45.Ft const char *
46.Fn au_strerror "int bsm_error"
47.Sh DESCRIPTION
48These interfaces may be used to convert between the local (
49.Xr errno 2 )
50and BSM error number spaces found in BSM return tokens.
51.Pp
52The
53.Fn au_bsm_to_errno
54function accepts a BSM error value,
55.Fa bsm_error ,
56and converts it to an
57.Xr errno 2
58that will be stored in the integer pointed to by
59.Fa errorp
60if successful.
61This call will fail if the BSM error cannot be mapped into a local error
62number, which may occur if the return token was generated on another
63operating system.
64.Pp
65The
66.Fn au_errno_to_bsm
67function accepts a local
68.Xr errno 2
69value, and returns the BSM error number for it.
70This call cannot fail, and instead returns a BSM error number indicating to
71a later decoder that the error could not be encoded.
72.Pp
73The
74.Fn au_strerror
75function converts a BSM error value to a string, generally by converting first to a
76local error number and using the local
77.Xr strerror 3
78function, but will also work for errors that are not locally defined.
79.Sh RETURN VALULES
80On success,
81.Fn au_bsm_to_errno
82returns 0 and a converted error value; on failure, it returns -1 but does not
83set
84.Xr errno 2 .
85.Pp
86On success,
87.Fn au_strerror
88returns a pointer to an error string; on failure it will return
89.Dv NULL .
90.Sh SEE ALSO
91.Xr au_to_return 3 ,
92.Xr au_to_return32 3 ,
93.Xr au_to_return64 3 ,
94.Xr libbsm 3
95.Sh HISTORY
96.Fn au_bsm_to_errno
97and
98.Fn au_errno_to_bsm
99were introduced in OpenBSM 1.1.
100.Sh AUTHORS
101These functions were implemented by
102.An Robert Watson
103under contract to Apple Inc.
104.Pp
105The Basic Security Module (BSM) interface to audit records and audit event
106stream format were defined by Sun Microsystems.
107.Sh BUGS
108.Nm au_strerror
109is unable to provide localized strings for errors not available in the local
110operating system.
111