KRB5_OPENLOG(3)
π KRB5_OPENLOG(3) π
okay so bestie, welcome to the Heimdal logging functions page π
this whole thing lives in the Kerberos 5 Library (libkrb5, -lkrb5), and it's basically the group chat where your Kerberos code gets to say stuff out loud β to files, to syslog, wherever. no cap.
β¨ NAME β¨
krb5_initlog, krb5_openlog, krb5_closelog, krb5_addlog_dest, krb5_addlog_func, krb5_log, krb5_vlog, krb5_log_msg, krb5_vlog_msg β the Heimdal logging functions π
π LIBRARY π
Kerberos 5 Library (libkrb5, -lkrb5) π«Ά
πΈ SYNOPSIS πΈ
#include <krb5.h>
typedef void
(*krb5_log_log_func_t)(const char *time, const char *message,
void *data);
typedef void
(*krb5_log_close_func_t)(void *data);
krb5_error_code
krb5_addlog_dest(krb5_context context, krb5_log_facility *facility,
const char *destination);
krb5_error_code
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);
krb5_error_code
krb5_closelog(krb5_context context, krb5_log_facility *facility);
krb5_error_code
krb5_initlog(krb5_context context, const char *program,
krb5_log_facility **facility);
krb5_error_code
krb5_log(krb5_context context, krb5_log_facility *facility, int level,
const char *format, ...);
krb5_error_code
krb5_log_msg(krb5_context context, krb5_log_facility *facility,
char **reply, int level, const char *format, ...);
krb5_error_code
krb5_openlog(krb5_context context, const char *program,
krb5_log_facility **facility);
krb5_error_code
krb5_vlog(krb5_context context, krb5_log_facility *facility, int level,
const char *format, va_list arglist);
krb5_error_code
krb5_vlog_msg(krb5_context context, krb5_log_facility *facility,
char **reply, int level, const char *format, va_list arglist);
π DESCRIPTION π
so these functions log messages to one or more destinations. that's the whole vibe. simple. iconic.
The krb5_openlog() function creates a logging facility, and that facility is the thing you use to log messages. A facility consists of one or more destinations β which can be files or syslog or some other device, you know, options. The program parameter should be the generic name of the program that's doing the logging. This name is used to look up which destinations to use. That info lives in the logging section of the krb5.conf configuration file. If no entry is found for program, the entry for default gets used instead, and if that's missing too? SYSLOG is used as the destination. periodt. π
To close a logging facility, use the krb5_closelog() function. bye bestie π
To log a message to a facility, use one of krb5_log(), krb5_log_msg(), krb5_vlog(), or krb5_vlog_msg(). The functions ending in _msg return in reply a pointer to the message that just got logged. That string is allocated, so you should free it with free(). The format is a standard printf() style format string β but see the BUGS section, iykyk. π
If you want better control of where things get logged, you can β instead of using krb5_openlog() β call krb5_initlog(), which just initializes a facility but doesn't define any actual logging destinations. Then you add destinations yourself with krb5_addlog_dest() and krb5_addlog_func(). Main character energy, honestly.
- The first of those (
krb5_addlog_dest()) takes a string specifying a logging destination and adds it to the facility. - If you want to do some non-standard logging, use
krb5_addlog_func(), which takes a function to use when logging.
The log function is called for each message, with time being a string specifying the current time, and message being the message to log. close is called when the facility is closed. You can pass application specific data in the data parameter. The min and max parameters are the same as in a destination (defined below). To specify a max of infinity, pass -1. β¨
krb5_openlog() calls krb5_initlog() and then calls krb5_addlog_dest() for each destination found. that's it. that's the pipeline. π¦
π Destinations π
The defined destinations (as specified in krb5.conf) go a little something like this:
STDERRβ logs to the program'sstderr.FILE:/fileFILE=/fileβ log to the specified file. The form using a colon appends to the file, the form with an equal sign truncates the file. The truncating form keeps the file open, while the appending form closes it after each log message (which makes it possible to rotate logs β slay for log rotation π). The truncating form is mainly for compatibility with the MIT libkrb5.DEVICE=/deviceβ logs to the specified device, and at present this is the same asFILE:/device.CONSOLEβ log to the console; this is the same asDEVICE=/dev/console.SYSLOG[:priority[:facility]]β send messages to the syslog system, using priority and facility. To get the name for one of these, you take the name of the macro passed tosyslog(3)and remove the leadingLOG_(soLOG_NOTICEbecomesNOTICE). The default values β as well as the values used for unrecognised values β areERRandAUTH, respectively. Seesyslog(3)for a list of priorities and facilities. π
Each destination may optionally be prepended with a range of logging levels, specified as min-max/. If the level parameter to krb5_log() is within this range (inclusive, bestie, don't forget) the message gets logged to this destination β otherwise not. Either of the min and max values may be omitted, and in that case min is assumed to be zero and max is assumed to be infinity. If you don't include a dash, both min and max get set to the specified value. And if no range is specified at all? All messages get logged. everything. all of it. π
π EXAMPLES π
[logging]
kdc = 0/FILE:/var/log/kdc.log
kdc = 1-/SYSLOG:INFO:USER
default = STDERR
This will log all messages from the kdc program with level 0 to /var/log/kdc.log, and other messages will be logged to syslog with priority LOG_INFO and facility LOG_USER. All other programs will log all messages to their stderr. β¨ so organized. so aesthetic. π
π SEE ALSO π
π BUGS π
These functions use asprintf() to format the message. If your operating system does not have a working asprintf(), a replacement will be used. At present this replacement does not handle some correct conversion specifications (like floating point numbers). Until this is fixed, the use of these conversions should be avoided. fr fr, just don't. π
If logging is done to the syslog facility, these functions might not be thread-safe, depending on the implementation ofopenlog()andsyslog(). not me warning you about a race condition π stay safe out there bestie.
and that's the whole page, gorgeous π this was the Heimdal version, dated August 6, 1997, filed under KRB5_OPENLOG(3) β go forth and log responsibly, queen ππΈ
π¦ where this page comes from
- alpine 3.22: heimdal-doc 7.8.0-r4 Β· BSD-3-Clause
- alpine 3.23: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- alpine 3.24: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- debian bookworm: heimdal-dev 7.8.git20221117.28daf24+dfsg-2 Β· BSD-3-Clause
- debian trixie: heimdal-dev 7.8.git20221117.28daf24+dfsg-9+deb13u1 Β· BSD-3-Clause
- epel 10: heimdal-devel 7.8.0-26.el10_2 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- epel 9: heimdal-devel 7.8.0-5.el9 Β· BSD and MIT
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- freebsd 14.5: base 14.5
- ubuntu jammy: heimdal-dev 7.7.0+dfsg-3ubuntu1 Β· BSD-3-Clause
- ubuntu noble: heimdal-dev 7.8.git20221117.28daf24+dfsg-5ubuntu3 Β· BSD-3-Clause
- ubuntu questing: heimdal-dev 7.8.git20221117.28daf24+dfsg-9ubuntu1
- ubuntu resolute: heimdal-dev 7.8.git20221117.28daf24+dfsg-11ubuntu1 Β· BSD-3-Clause
- ubuntu stonking: heimdal-dev 7.8.git20240113.1b4565a+dfsg-2ubuntu1 Β· BSD-3-Clause
- Copyright (c) 1997, 1999, 2001 - 2002 Kungliga Tekniska HΓΆgskolan
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms