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
32 .\" $Heimdal: krb5_warn.3 19085 2006-11-21 07:55:20Z lha $
41 .Nm krb5_clear_error_string ,
44 .Nm krb5_free_error_string ,
45 .Nm krb5_get_err_text ,
46 .Nm krb5_get_error_message ,
47 .Nm krb5_get_error_string ,
48 .Nm krb5_have_error_string ,
49 .Nm krb5_set_error_string ,
50 .Nm krb5_set_warn_dest ,
51 .Nm krb5_get_warn_dest ,
56 .Nm krb5_vset_error_string ,
61 .Nd Heimdal warning and error functions
63 Kerberos 5 Library (libkrb5, -lkrb5)
67 .Fn krb5_abort "krb5_context context" "krb5_error_code code" "const char *fmt" "..."
69 .Fn krb5_abortx "krb5_context context" "krb5_error_code code" "const char *fmt" "..."
71 .Fn krb5_clear_error_string "krb5_context context"
73 .Fn krb5_err "krb5_context context" "int eval" "krb5_error_code code" "const char *format" "..."
75 .Fn krb5_errx "krb5_context context" "int eval" "const char *format" "..."
77 .Fn krb5_free_error_string "krb5_context context" "char *str"
79 .Fn krb5_verr "krb5_context context" "int eval" "krb5_error_code code" "const char *format" "va_list ap"
81 .Fn krb5_verrx "krb5_context context" "int eval" "const char *format" "va_list ap"
83 .Fn krb5_vset_error_string "krb5_context context" "const char *fmt" "va_list args"
85 .Fn krb5_vwarn "krb5_context context" "krb5_error_code code" "const char *format" "va_list ap"
87 .Fn krb5_vwarnx "krb5_context context" "const char *format" "va_list ap"
89 .Fn krb5_warn "krb5_context context" "krb5_error_code code" "const char *format" "..."
91 .Fn krb5_warnx "krb5_context context" "const char *format" "..."
93 .Fn krb5_set_error_string "krb5_context context" "const char *fmt" "..."
95 .Fn krb5_set_warn_dest "krb5_context context" "krb5_log_facility *facility"
97 .Ft krb5_log_facility *
98 .Fo krb5_get_warn_dest
99 .Fa "krb5_context context"
101 .Fn krb5_get_err_text "krb5_context context" "krb5_error_code code"
103 .Fn krb5_get_error_string "krb5_context context"
105 .Fn krb5_get_error_message "krb5_context context, krb5_error_code code"
107 .Fn krb5_have_error_string "krb5_context context"
109 .Fn krb5_vabortx "krb5_context context" "const char *fmt" "va_list ap"
111 .Fn krb5_vabort "krb5_context context" "const char *fmt" "va_list ap"
113 These functions print a warning message to some destination.
115 is a printf style format specifying the message to print. The forms not ending in an
117 print the error string associated with
119 along with the message.
122 functions exit with exit status
124 after printing the message.
126 Applications that want to get the error message to report it to a user
127 or store it in a log want to use
128 .Fn krb5_get_error_message .
131 .Fn krb5_set_warn_func
132 function sets the destination for warning messages to the specified
134 Messages logged with the
136 functions have a log level of 1, while the
138 functions log with level 0.
140 .Fn krb5_get_err_text
141 fetches the human readable strings describing the error-code.
150 but instead of exiting using the
156 .Fn krb5_free_error_string
157 frees the error string
160 .Fn krb5_get_error_string .
162 .Fn krb5_clear_error_string
163 clears the error string from the
166 .Fn krb5_set_error_string
168 .Fn krb5_vset_error_string
169 sets an verbose error string in
172 .Fn krb5_get_error_string
173 fetches the error string from
175 The error message in the context is consumed and must be freed using
176 .Fn krb5_free_error_string
179 .Fn krb5_get_error_message ,
180 what is usually less verbose to use.
182 .Fn krb5_have_error_string
185 if there is a verbose error message in the
188 .Fn krb5_get_error_message
189 fetches the error string from the context, or if there
190 is no customized error string in
194 to return a error string.
195 In either case, the error message in the context is consumed and must
197 .Fn krb5_free_error_string
200 .Fn krb5_set_warn_dest
202 .Fn krb5_get_warn_dest
203 sets and get the log context that is used by
205 and friends. By using this the application can control where the
206 output should go. For example, this is imperative to inetd servers
207 where logging status and error message will end up on the output
208 stream to the client.
210 Below is a simple example how to report error messages from the
211 Kerberos library in an application.
213 #include <krb5/krb5.h>
216 function (krb5_context context)
220 ret = krb5_function (context, arg1, arg2);
222 char *s = krb5_get_error_message(context, ret);
224 errx(1, "kerberos error: %d (and out of memory)", ret);
225 application_logger("krb5_function failed: %s", s);
226 krb5_free_error_string(context, s);