1 .\" Copyright (c) 1997, 2001 - 2006 Kungliga Tekniska Högskolan
2 .\" (Royal Institute of Technology, Stockholm, Sweden).
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the Institute nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 .Nm krb5_clear_error_string ,
43 .Nm krb5_free_error_string ,
44 .Nm krb5_get_err_text ,
45 .Nm krb5_get_error_message ,
46 .Nm krb5_get_error_string ,
47 .Nm krb5_have_error_string ,
48 .Nm krb5_set_error_string ,
49 .Nm krb5_set_warn_dest ,
50 .Nm krb5_get_warn_dest ,
55 .Nm krb5_vset_error_string ,
60 .Nd Heimdal warning and error functions
62 Kerberos 5 Library (libkrb5, -lkrb5)
66 .Fn krb5_abort "krb5_context context" "krb5_error_code code" "const char *fmt" "..."
68 .Fn krb5_abortx "krb5_context context" "krb5_error_code code" "const char *fmt" "..."
70 .Fn krb5_clear_error_string "krb5_context context"
72 .Fn krb5_err "krb5_context context" "int eval" "krb5_error_code code" "const char *format" "..."
74 .Fn krb5_errx "krb5_context context" "int eval" "const char *format" "..."
76 .Fn krb5_free_error_string "krb5_context context" "char *str"
78 .Fn krb5_verr "krb5_context context" "int eval" "krb5_error_code code" "const char *format" "va_list ap"
80 .Fn krb5_verrx "krb5_context context" "int eval" "const char *format" "va_list ap"
82 .Fn krb5_vset_error_string "krb5_context context" "const char *fmt" "va_list args"
84 .Fn krb5_vwarn "krb5_context context" "krb5_error_code code" "const char *format" "va_list ap"
86 .Fn krb5_vwarnx "krb5_context context" "const char *format" "va_list ap"
88 .Fn krb5_warn "krb5_context context" "krb5_error_code code" "const char *format" "..."
90 .Fn krb5_warnx "krb5_context context" "const char *format" "..."
92 .Fn krb5_set_error_string "krb5_context context" "const char *fmt" "..."
94 .Fn krb5_set_warn_dest "krb5_context context" "krb5_log_facility *facility"
96 .Ft krb5_log_facility *
97 .Fo krb5_get_warn_dest
98 .Fa "krb5_context context"
100 .Fn krb5_get_err_text "krb5_context context" "krb5_error_code code"
102 .Fn krb5_get_error_string "krb5_context context"
104 .Fn krb5_get_error_message "krb5_context context, krb5_error_code code"
106 .Fn krb5_have_error_string "krb5_context context"
108 .Fn krb5_vabortx "krb5_context context" "const char *fmt" "va_list ap"
110 .Fn krb5_vabort "krb5_context context" "const char *fmt" "va_list ap"
112 These functions print a warning message to some destination.
114 is a printf style format specifying the message to print. The forms not ending in an
116 print the error string associated with
118 along with the message.
121 functions exit with exit status
123 after printing the message.
125 Applications that want to get the error message to report it to a user
126 or store it in a log want to use
127 .Fn krb5_get_error_message .
130 .Fn krb5_set_warn_func
131 function sets the destination for warning messages to the specified
133 Messages logged with the
135 functions have a log level of 1, while the
137 functions log with level 0.
139 .Fn krb5_get_err_text
140 fetches the human readable strings describing the error-code.
149 but instead of exiting using the
155 .Fn krb5_free_error_string
156 frees the error string
159 .Fn krb5_get_error_string .
161 .Fn krb5_clear_error_string
162 clears the error string from the
165 .Fn krb5_set_error_string
167 .Fn krb5_vset_error_string
168 sets an verbose error string in
171 .Fn krb5_get_error_string
172 fetches the error string from
174 The error message in the context is consumed and must be freed using
175 .Fn krb5_free_error_string
178 .Fn krb5_get_error_message ,
179 what is usually less verbose to use.
181 .Fn krb5_have_error_string
184 if there is a verbose error message in the
187 .Fn krb5_get_error_message
188 fetches the error string from the context, or if there
189 is no customized error string in
193 to return a error string.
194 In either case, the error message in the context is consumed and must
196 .Fn krb5_free_error_string
199 .Fn krb5_set_warn_dest
201 .Fn krb5_get_warn_dest
202 sets and get the log context that is used by
204 and friends. By using this the application can control where the
205 output should go. For example, this is imperative to inetd servers
206 where logging status and error message will end up on the output
207 stream to the client.
209 Below is a simple example how to report error messages from the
210 Kerberos library in an application.
215 function (krb5_context context)
219 ret = krb5_function (context, arg1, arg2);
221 char *s = krb5_get_error_message(context, ret);
223 errx(1, "kerberos error: %d (and out of memory)", ret);
224 application_logger("krb5_function failed: %s", s);
225 krb5_free_error_string(context, s);