CAP_SYSLOG(3)
okay bestie, welcome to CAP_SYSLOG(3) β a Library Functions Manual page, and it's fully about logging with syslog in capability mode. main character security energy, no cap. π β¨
π NAME π
Meet the squad: cap_syslog, cap_vsyslog, cap_openlog, cap_closelog, cap_setlogmask β the library for syslog in capability mode. they're here to help you log safely, and honestly? iconic. π«Ά
π LIBRARY π
This one lives in βlibcap_syslogβ β yes bestie, that's the library. π
β¨ SYNOPSIS β¨
okay, here's the include-and-prototype moment. copy these exactly, i'm not kidding:
#include <libcasper.h>
#include <casper/cap_syslog.h>
void
cap_syslog(cap_channel_t *chan, int pri, const char *fmt, ...);
void
cap_vsyslog(cap_channel_t *chan, int priority, const char *fmt,
va_list ap);
void
cap_openlog(cap_channel_t *chan, const char *ident, int logopt,
int facility);
void
cap_closelog(cap_channel_t *chan);
int
cap_setlogmask(cap_channel_t *chan, int maskpri);
π DESCRIPTION π
So cap_syslog(), cap_vsyslog(), cap_openlog(), cap_closelog(), and cap_setlogmask() are literally the capability-mode besties of the classic syslog crew β respectively:
cap_syslog()is equivalent tosyslog(3)cap_vsyslog()is equivalent tovsyslog(3)cap_openlog()is equivalent toopenlog(3)cap_closelog()is equivalent tocloselog(3)cap_setlogmask()is equivalent tosetlogmask(3)
with one big caveat: the connection to the system.syslog service needs to be provided. that's the whole point, iykyk. π₯
All of these functions are reentrant but not thread-safe. translation: you may call them from separate threads only with different cap_channel_t arguments, or with synchronization. don't play yourself. π
π§ EXAMPLES π§
The following example first opens a capability to casper and then uses this capability to create the system.syslog casper service to log messages. it's giving secure-logging tutorial, watch:
cap_channel_t *capcas, *capsyslog;
/* Open capability to Casper. */
capcas = cap_init();
if (capcas == NULL)
err(1, "Unable to contact Casper");
/* Enter capability mode sandbox. */
if (cap_enter() < 0 && errno != ENOSYS)
err(1, "Unable to enter capability mode");
/* Use Casper capability to create capability to the system.syslog service. */
capsyslog = cap_service_open(capcas, "system.syslog");
if (capsyslog == NULL)
err(1, "Unable to open system.syslog service");
/* Close Casper capability, we don't need it anymore. */
cap_close(capcas);
/* Let's log something. */
cap_syslog(capsyslog, LOG_NOTICE, "System logs from capability mode.");
π SEE ALSO π
go give these pages some love: cap_enter(2), closelog(3), err(3), openlog(3), setlogmask(3), syslog(3), vsyslog(3), capsicum(4), nv(9). bestie behavior. π
π¦ HISTORY π¦
The cap_syslog service first appeared in FreeBSD 10.3. periodt. π¦
πΈ AUTHORS πΈ
Mariusz Zaborski β <oshogbo@FreeBSD.org> β author icon. πΈ
this page comes from Debian, dated December 6, 2023, and the manual name is CAP_SYSLOG(3) β mwah, bye bestie! π π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2018 Mariusz Zaborski <oshogbo@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms