xref: /freebsd/lib/libcasper/services/cap_syslog/cap_syslog.3 (revision 389e4940069316fe667ffa263fa7d6390d0a960f)
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.\" $FreeBSD$
26.\"
27.Dd January 27, 2018
28.Dt CAP_SYSLOG 3
29.Os
30.Sh NAME
31.Nm cap_syslog
32.Nm cap_vsyslog
33.Nm cap_openlog
34.Nm cap_closelog
35.Nm cap_setlogmask
36.Nd "library for syslog in capability mode"
37.Sh LIBRARY
38.Lb libcap_syslog
39.Sh SYNOPSIS
40.In libcasper.h
41.In casper/cap_syslog.h
42.Ft void
43.Fn cap_syslog "cap_channel_t *chan" "int pri" "const char *fmt" "..."
44.Ft void
45.Fn cap_vsyslog "cap_channel_t *chan" "int priority" "const char *fmt" "va_list ap"
46.Ft void
47.Fn cap_openlog "cap_channel_t *chan" "const char *ident" "int logopt" "int facility"
48.Ft void
49.Fn cap_closelog "cap_channel_t *chan"
50.Ft int
51.Fn cap_setlogmask "cap_channel_t *chan" "int maskpri"
52.Sh DESCRIPTION
53The functions
54.Fn cap_syslog
55.Fn cap_vsyslog
56.Fn cap_openlog
57.Fn cap_closelog
58.Fn cap_setlogmask
59are respectively equivalent to
60.Xr syslog 3 ,
61.Xr vsyslog 3 ,
62.Xr openlog 3 ,
63.Xr closelog 3 ,
64.Xr setlogmask 3
65except that the connection to the
66.Nm system.syslog
67service needs to be provided.
68.Sh EXAMPLES
69The following example first opens a capability to casper and then uses this
70capability to create the
71.Nm system.syslog
72casper service to log messages.
73.Bd -literal
74cap_channel_t *capcas, *capsyslog;
75
76/* Open capability to Casper. */
77capcas = cap_init();
78if (capcas == NULL)
79	err(1, "Unable to contact Casper");
80
81/* Enter capability mode sandbox. */
82if (cap_enter() < 0 && errno != ENOSYS)
83	err(1, "Unable to enter capability mode");
84
85/* Use Casper capability to create capability to the system.syslog service. */
86capsyslog = cap_service_open(capcas, "system.syslog");
87if (capsyslog == NULL)
88	err(1, "Unable to open system.syslog service");
89
90/* Close Casper capability, we don't need it anymore. */
91cap_close(capcas);
92
93/* Let's log something. */
94cap_syslog(capsyslog, LOG_NOTICE, "System logs from capability mode.");
95.Ed
96.Sh SEE ALSO
97.Xr cap_enter 2 ,
98.Xr closelog 3 ,
99.Xr err 3 ,
100.Xr openlog 3 ,
101.Xr setlogmask 3
102.Xr syslog 3 ,
103.Xr vsyslog 3 ,
104.Xr capsicum 4 ,
105.Xr nv 9
106.Sh AUTHORS
107.An Mariusz Zaborski Aq Mt oshogbo@FreeBSD.org
108