1*d3273b5bSchristos.\" $NetBSD: krb5_openlog.3,v 1.2 2017/01/28 21:31:49 christos Exp $ 2ca1c9b0cSelric.\" 3ca1c9b0cSelric.\" Copyright (c) 1997, 1999, 2001 - 2002 Kungliga Tekniska Högskolan 4ca1c9b0cSelric.\" (Royal Institute of Technology, Stockholm, Sweden). 5ca1c9b0cSelric.\" All rights reserved. 6ca1c9b0cSelric.\" 7ca1c9b0cSelric.\" Redistribution and use in source and binary forms, with or without 8ca1c9b0cSelric.\" modification, are permitted provided that the following conditions 9ca1c9b0cSelric.\" are met: 10ca1c9b0cSelric.\" 11ca1c9b0cSelric.\" 1. Redistributions of source code must retain the above copyright 12ca1c9b0cSelric.\" notice, this list of conditions and the following disclaimer. 13ca1c9b0cSelric.\" 14ca1c9b0cSelric.\" 2. Redistributions in binary form must reproduce the above copyright 15ca1c9b0cSelric.\" notice, this list of conditions and the following disclaimer in the 16ca1c9b0cSelric.\" documentation and/or other materials provided with the distribution. 17ca1c9b0cSelric.\" 18ca1c9b0cSelric.\" 3. Neither the name of the Institute nor the names of its contributors 19ca1c9b0cSelric.\" may be used to endorse or promote products derived from this software 20ca1c9b0cSelric.\" without specific prior written permission. 21ca1c9b0cSelric.\" 22ca1c9b0cSelric.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23ca1c9b0cSelric.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24ca1c9b0cSelric.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25ca1c9b0cSelric.\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26ca1c9b0cSelric.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27ca1c9b0cSelric.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28ca1c9b0cSelric.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29ca1c9b0cSelric.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30ca1c9b0cSelric.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31ca1c9b0cSelric.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32ca1c9b0cSelric.\" SUCH DAMAGE. 33ca1c9b0cSelric.\" 34b40995a4Selric.\" Id 35ca1c9b0cSelric.Dd August 6, 1997 36ca1c9b0cSelric.Dt KRB5_OPENLOG 3 37ca1c9b0cSelric.Os 38ca1c9b0cSelric.Sh NAME 39ca1c9b0cSelric.Nm krb5_initlog , 40ca1c9b0cSelric.Nm krb5_openlog , 41ca1c9b0cSelric.Nm krb5_closelog , 42ca1c9b0cSelric.Nm krb5_addlog_dest , 43ca1c9b0cSelric.Nm krb5_addlog_func , 44ca1c9b0cSelric.Nm krb5_log , 45ca1c9b0cSelric.Nm krb5_vlog , 46ca1c9b0cSelric.Nm krb5_log_msg , 47ca1c9b0cSelric.Nm krb5_vlog_msg 48ca1c9b0cSelric.Nd Heimdal logging functions 49ca1c9b0cSelric.Sh LIBRARY 50ca1c9b0cSelricKerberos 5 Library (libkrb5, -lkrb5) 51ca1c9b0cSelric.Sh SYNOPSIS 52ca1c9b0cSelric.In krb5/krb5.h 53ca1c9b0cSelric.Ft "typedef void" 54ca1c9b0cSelric.Fn "\*(lp*krb5_log_log_func_t\*(rp" "const char *time" "const char *message" "void *data" 55ca1c9b0cSelric.Ft "typedef void" 56ca1c9b0cSelric.Fn "\*(lp*krb5_log_close_func_t\*(rp" "void *data" 57ca1c9b0cSelric.Ft krb5_error_code 58ca1c9b0cSelric.Fn krb5_addlog_dest "krb5_context context" "krb5_log_facility *facility" "const char *destination" 59ca1c9b0cSelric.Ft krb5_error_code 60ca1c9b0cSelric.Fn krb5_addlog_func "krb5_context context" "krb5_log_facility *facility" "int min" "int max" "krb5_log_log_func_t log" "krb5_log_close_func_t close" "void *data" 61ca1c9b0cSelric.Ft krb5_error_code 62ca1c9b0cSelric.Fn krb5_closelog "krb5_context context" "krb5_log_facility *facility" 63ca1c9b0cSelric.Ft krb5_error_code 64ca1c9b0cSelric.Fn krb5_initlog "krb5_context context" "const char *program" "krb5_log_facility **facility" 65ca1c9b0cSelric.Ft krb5_error_code 66ca1c9b0cSelric.Fn krb5_log "krb5_context context" "krb5_log_facility *facility" "int level" "const char *format" "..." 67ca1c9b0cSelric.Ft krb5_error_code 68ca1c9b0cSelric.Fn krb5_log_msg "krb5_context context" "krb5_log_facility *facility" "char **reply" "int level" "const char *format" "..." 69ca1c9b0cSelric.Ft krb5_error_code 70ca1c9b0cSelric.Fn krb5_openlog "krb5_context context" "const char *program" "krb5_log_facility **facility" 71ca1c9b0cSelric.Ft krb5_error_code 72ca1c9b0cSelric.Fn krb5_vlog "krb5_context context" "krb5_log_facility *facility" "int level" "const char *format" "va_list arglist" 73ca1c9b0cSelric.Ft krb5_error_code 74ca1c9b0cSelric.Fn krb5_vlog_msg "krb5_context context" "krb5_log_facility *facility" "char **reply" "int level" "const char *format" "va_list arglist" 75ca1c9b0cSelric.Sh DESCRIPTION 76ca1c9b0cSelricThese functions logs messages to one or more destinations. 77ca1c9b0cSelric.Pp 78ca1c9b0cSelricThe 79ca1c9b0cSelric.Fn krb5_openlog 80ca1c9b0cSelricfunction creates a logging 81ca1c9b0cSelric.Fa facility , 82ca1c9b0cSelricthat is used to log messages. A facility consists of one or more 83ca1c9b0cSelricdestinations (which can be files or syslog or some other device). The 84ca1c9b0cSelric.Fa program 85ca1c9b0cSelricparameter should be the generic name of the program that is doing the 86ca1c9b0cSelriclogging. This name is used to lookup which destinations to use. This 87ca1c9b0cSelricinformation is contained in the 88ca1c9b0cSelric.Li logging 89ca1c9b0cSelricsection of the 90ca1c9b0cSelric.Pa krb5.conf 91ca1c9b0cSelricconfiguration file. If no entry is found for 92ca1c9b0cSelric.Fa program , 93ca1c9b0cSelricthe entry for 94ca1c9b0cSelric.Li default 95ca1c9b0cSelricis used, or if that is missing too, 96ca1c9b0cSelric.Li SYSLOG 97ca1c9b0cSelricwill be used as destination. 98ca1c9b0cSelric.Pp 99ca1c9b0cSelricTo close a logging facility, use the 100ca1c9b0cSelric.Fn krb5_closelog 101ca1c9b0cSelricfunction. 102ca1c9b0cSelric.Pp 103ca1c9b0cSelricTo log a message to a facility use one of the functions 104ca1c9b0cSelric.Fn krb5_log , 105ca1c9b0cSelric.Fn krb5_log_msg , 106ca1c9b0cSelric.Fn krb5_vlog , 107ca1c9b0cSelricor 108ca1c9b0cSelric.Fn krb5_vlog_msg . 109ca1c9b0cSelricThe functions ending in 110ca1c9b0cSelric.Li _msg 111ca1c9b0cSelricreturn in 112ca1c9b0cSelric.Fa reply 113ca1c9b0cSelrica pointer to the message that just got logged. This string is allocated, 114ca1c9b0cSelricand should be freed with 115ca1c9b0cSelric.Fn free . 116ca1c9b0cSelricThe 117ca1c9b0cSelric.Fa format 118ca1c9b0cSelricis a standard 119ca1c9b0cSelric.Fn printf 120ca1c9b0cSelricstyle format string (but see the BUGS section). 121ca1c9b0cSelric.Pp 122ca1c9b0cSelricIf you want better control of where things gets logged, you can instead of using 123ca1c9b0cSelric.Fn krb5_openlog 124ca1c9b0cSelriccall 125ca1c9b0cSelric.Fn krb5_initlog , 126ca1c9b0cSelricwhich just initializes a facility, but doesn't define any actual logging 127ca1c9b0cSelricdestinations. You can then add destinations with the 128ca1c9b0cSelric.Fn krb5_addlog_dest 129ca1c9b0cSelricand 130ca1c9b0cSelric.Fn krb5_addlog_func 131ca1c9b0cSelricfunctions. The first of these takes a string specifying a logging 132ca1c9b0cSelricdestination, and adds this to the facility. If you want to do some 133ca1c9b0cSelricnon-standard logging you can use the 134ca1c9b0cSelric.Fn krb5_addlog_func 135ca1c9b0cSelricfunction, which takes a function to use when logging. 136ca1c9b0cSelricThe 137ca1c9b0cSelric.Fa log 138ca1c9b0cSelricfunction is called for each message with 139ca1c9b0cSelric.Fa time 140ca1c9b0cSelricbeing a string specifying the current time, and 141ca1c9b0cSelric.Fa message 142ca1c9b0cSelricthe message to log. 143ca1c9b0cSelric.Fa close 144ca1c9b0cSelricis called when the facility is closed. You can pass application specific data in the 145ca1c9b0cSelric.Fa data 146ca1c9b0cSelricparameter. The 147ca1c9b0cSelric.Fa min 148ca1c9b0cSelricand 149ca1c9b0cSelric.Fa max 150ca1c9b0cSelricparameter are the same as in a destination (defined below). To specify a 151ca1c9b0cSelricmax of infinity, pass -1. 152ca1c9b0cSelric.Pp 153ca1c9b0cSelric.Fn krb5_openlog 154ca1c9b0cSelriccalls 155ca1c9b0cSelric.Fn krb5_initlog 156ca1c9b0cSelricand then calls 157ca1c9b0cSelric.Fn krb5_addlog_dest 158ca1c9b0cSelricfor each destination found. 159ca1c9b0cSelric.Ss Destinations 160ca1c9b0cSelricThe defined destinations (as specified in 161ca1c9b0cSelric.Pa krb5.conf ) 162ca1c9b0cSelricfollows: 163ca1c9b0cSelric.Bl -tag -width "xxx" -offset indent 164ca1c9b0cSelric.It Li STDERR 165ca1c9b0cSelricThis logs to the program's stderr. 166ca1c9b0cSelric.It Li FILE: Ns Pa /file 167ca1c9b0cSelric.It Li FILE= Ns Pa /file 168ca1c9b0cSelricLog to the specified file. The form using a colon appends to the file, the 169ca1c9b0cSelricform with an equal truncates the file. The truncating form keeps the file 170ca1c9b0cSelricopen, while the appending form closes it after each log message (which 171ca1c9b0cSelricmakes it possible to rotate logs). The truncating form is mainly for 172ca1c9b0cSelriccompatibility with the MIT libkrb5. 173ca1c9b0cSelric.It Li DEVICE= Ns Pa /device 174ca1c9b0cSelricThis logs to the specified device, at present this is the same as 175ca1c9b0cSelric.Li FILE:/device . 176ca1c9b0cSelric.It Li CONSOLE 177ca1c9b0cSelricLog to the console, this is the same as 178ca1c9b0cSelric.Li DEVICE=/dev/console . 179ca1c9b0cSelric.It Li SYSLOG Ns Op :priority Ns Op :facility 180ca1c9b0cSelricSend messages to the syslog system, using priority, and facility. To 181ca1c9b0cSelricget the name for one of these, you take the name of the macro passed 182ca1c9b0cSelricto 183ca1c9b0cSelric.Xr syslog 3 , 184ca1c9b0cSelricand remove the leading 185ca1c9b0cSelric.Li LOG_ 186ca1c9b0cSelric.No ( Li LOG_NOTICE 187ca1c9b0cSelricbecomes 188ca1c9b0cSelric.Li NOTICE ) . 189ca1c9b0cSelricThe default values (as well as the values used for unrecognised 190ca1c9b0cSelricvalues), are 191ca1c9b0cSelric.Li ERR , 192ca1c9b0cSelricand 193ca1c9b0cSelric.Li AUTH , 194ca1c9b0cSelricrespectively. See 195ca1c9b0cSelric.Xr syslog 3 196ca1c9b0cSelricfor a list of priorities and facilities. 197ca1c9b0cSelric.El 198ca1c9b0cSelric.Pp 199ca1c9b0cSelricEach destination may optionally be prepended with a range of logging 200ca1c9b0cSelriclevels, specified as 201ca1c9b0cSelric.Li min-max/ . 202ca1c9b0cSelricIf the 203ca1c9b0cSelric.Fa level 204ca1c9b0cSelricparameter to 205ca1c9b0cSelric.Fn krb5_log 206ca1c9b0cSelricis within this range (inclusive) the message gets logged to this 207ca1c9b0cSelricdestination, otherwise not. Either of the min and max valued may be 208ca1c9b0cSelricomitted, in this case min is assumed to be zero, and max is assumed to be 209ca1c9b0cSelricinfinity. If you don't include a dash, both min and max gets set to the 210ca1c9b0cSelricspecified value. If no range is specified, all messages gets logged. 211ca1c9b0cSelric.Sh EXAMPLES 212ca1c9b0cSelric.Bd -literal -offset indent 213ca1c9b0cSelric[logging] 214ca1c9b0cSelric kdc = 0/FILE:/var/log/kdc.log 215ca1c9b0cSelric kdc = 1-/SYSLOG:INFO:USER 216ca1c9b0cSelric default = STDERR 217ca1c9b0cSelric.Ed 218ca1c9b0cSelric.Pp 219ca1c9b0cSelricThis will log all messages from the 220ca1c9b0cSelric.Nm kdc 221ca1c9b0cSelricprogram with level 0 to 222ca1c9b0cSelric.Pa /var/log/kdc.log , 223ca1c9b0cSelricother messages will be logged to syslog with priority 224ca1c9b0cSelric.Li LOG_INFO , 225ca1c9b0cSelricand facility 226ca1c9b0cSelric.Li LOG_USER . 227ca1c9b0cSelricAll other programs will log all messages to their stderr. 228ca1c9b0cSelric.Sh SEE ALSO 229ca1c9b0cSelric.Xr syslog 3 , 230ca1c9b0cSelric.Xr krb5.conf 5 231ca1c9b0cSelric.Sh BUGS 232ca1c9b0cSelricThese functions use 233ca1c9b0cSelric.Fn asprintf 234ca1c9b0cSelricto format the message. If your operating system does not have a working 235ca1c9b0cSelric.Fn asprintf , 236ca1c9b0cSelrica replacement will be used. At present this replacement does not handle 237ca1c9b0cSelricsome correct conversion specifications (like floating point numbers). Until 238ca1c9b0cSelricthis is fixed, the use of these conversions should be avoided. 239ca1c9b0cSelric.Pp 240ca1c9b0cSelricIf logging is done to the syslog facility, these functions might not be 241ca1c9b0cSelricthread-safe, depending on the implementation of 242ca1c9b0cSelric.Fn openlog , 243ca1c9b0cSelricand 244ca1c9b0cSelric.Fn syslog . 245