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