1.\" Copyright (c) 2018 Mariusz Zaborski <oshogbo@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd May 5, 2020 26.Dt CAP_SYSLOG 3 27.Os 28.Sh NAME 29.Nm cap_syslog , 30.Nm cap_vsyslog , 31.Nm cap_openlog , 32.Nm cap_closelog , 33.Nm cap_setlogmask 34.Nd "library for syslog in capability mode" 35.Sh LIBRARY 36.Lb libcap_syslog 37.Sh SYNOPSIS 38.In libcasper.h 39.In casper/cap_syslog.h 40.Ft void 41.Fn cap_syslog "cap_channel_t *chan" "int pri" "const char *fmt" "..." 42.Ft void 43.Fn cap_vsyslog "cap_channel_t *chan" "int priority" "const char *fmt" "va_list ap" 44.Ft void 45.Fn cap_openlog "cap_channel_t *chan" "const char *ident" "int logopt" "int facility" 46.Ft void 47.Fn cap_closelog "cap_channel_t *chan" 48.Ft int 49.Fn cap_setlogmask "cap_channel_t *chan" "int maskpri" 50.Sh DESCRIPTION 51The functions 52.Fn cap_syslog 53.Fn cap_vsyslog 54.Fn cap_openlog 55.Fn cap_closelog 56.Fn cap_setlogmask 57are respectively equivalent to 58.Xr syslog 3 , 59.Xr vsyslog 3 , 60.Xr openlog 3 , 61.Xr closelog 3 , 62.Xr setlogmask 3 63except that the connection to the 64.Nm system.syslog 65service needs to be provided. 66.Sh EXAMPLES 67The following example first opens a capability to casper and then uses this 68capability to create the 69.Nm system.syslog 70casper service to log messages. 71.Bd -literal 72cap_channel_t *capcas, *capsyslog; 73 74/* Open capability to Casper. */ 75capcas = cap_init(); 76if (capcas == NULL) 77 err(1, "Unable to contact Casper"); 78 79/* Enter capability mode sandbox. */ 80if (cap_enter() < 0 && errno != ENOSYS) 81 err(1, "Unable to enter capability mode"); 82 83/* Use Casper capability to create capability to the system.syslog service. */ 84capsyslog = cap_service_open(capcas, "system.syslog"); 85if (capsyslog == NULL) 86 err(1, "Unable to open system.syslog service"); 87 88/* Close Casper capability, we don't need it anymore. */ 89cap_close(capcas); 90 91/* Let's log something. */ 92cap_syslog(capsyslog, LOG_NOTICE, "System logs from capability mode."); 93.Ed 94.Sh SEE ALSO 95.Xr cap_enter 2 , 96.Xr closelog 3 , 97.Xr err 3 , 98.Xr openlog 3 , 99.Xr setlogmask 3 , 100.Xr syslog 3 , 101.Xr vsyslog 3 , 102.Xr capsicum 4 , 103.Xr nv 9 104.Sh HISTORY 105The 106.Nm cap_syslog 107service first appeared in 108.Fx 10.3 . 109.Sh AUTHORS 110.An Mariusz Zaborski Aq Mt oshogbo@FreeBSD.org 111