From owner-svn-src-all@freebsd.org Mon Jan 29 04:38:12 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FD75ED4735; Mon, 29 Jan 2018 04:38:12 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 219417E8D2; Mon, 29 Jan 2018 04:38:12 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1BEFA235E5; Mon, 29 Jan 2018 04:38:12 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0T4cBk2064082; Mon, 29 Jan 2018 04:38:11 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0T4cBt4064080; Mon, 29 Jan 2018 04:38:11 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201801290438.w0T4cBt4064080@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Mon, 29 Jan 2018 04:38:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328531 - head/lib/libcasper/services/cap_syslog X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: head/lib/libcasper/services/cap_syslog X-SVN-Commit-Revision: 328531 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jan 2018 04:38:12 -0000 Author: oshogbo Date: Mon Jan 29 04:38:11 2018 New Revision: 328531 URL: https://svnweb.freebsd.org/changeset/base/328531 Log: Document the syslog Casper service. Reviewed by: bcr@ Differential Revision: https://reviews.freebsd.org/D14084 Added: head/lib/libcasper/services/cap_syslog/cap_syslog.3 (contents, props changed) Modified: head/lib/libcasper/services/cap_syslog/Makefile Modified: head/lib/libcasper/services/cap_syslog/Makefile ============================================================================== --- head/lib/libcasper/services/cap_syslog/Makefile Mon Jan 29 04:33:41 2018 (r328530) +++ head/lib/libcasper/services/cap_syslog/Makefile Mon Jan 29 04:38:11 2018 (r328531) @@ -21,4 +21,13 @@ LIBADD= nv CFLAGS+=-I${.CURDIR} +MAN+= cap_syslog.3 + +MLINKS+= cap_syslog.3 libcap_syslog.3 +MLINKS+= cap_syslog.3 cap_syslog.3 +MLINKS+= cap_syslog.3 cap_vsyslog.3 +MLINKS+= cap_syslog.3 cap_openlog.3 +MLINKS+= cap_syslog.3 cap_closelog.3 +MLINKS+= cap_syslog.3 cap_setlogmask.3 + .include Added: head/lib/libcasper/services/cap_syslog/cap_syslog.3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libcasper/services/cap_syslog/cap_syslog.3 Mon Jan 29 04:38:11 2018 (r328531) @@ -0,0 +1,107 @@ +.\" Copyright (c) 2018 Mariusz Zaborski +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 28, 2018 +.Dt CAP_SYSLOG 3 +.Os +.Sh NAME +.Nm cap_syslog +.Nm cap_vsyslog +.Nm cap_openlog +.Nm cap_closelog +.Nm cap_setlogmask +.Nd "library for syslog in capability mode" +.Sh LIBRARY +.Lb libcap_syslog +.Sh SYNOPSIS +.In libcasper.h +.In casper/cap_syslog.h +.Ft void +.Fn cap_syslog "cap_channel_t *chan" "int pri" "const char *fmt" "..." +.Ft void +.Fn cap_vsyslog "cap_channel_t *chan" "int priority" "const char *fmt" "va_list ap" +.Ft void +.Fn cap_openlog "cap_channel_t *chan" "const char *ident" "int logopt" "int facility" +.Ft void +.Fn cap_closelog "cap_channel_t *chan" +.Ft int +.Fn cap_setlogmask "cap_channel_t *chan" "int maskpri" +.Sh DESCRIPTION +The functions +.Fn cap_syslog +.Fn cap_vsyslog +.Fn cap_openlog +.Fn cap_closelog +.Fn cap_setlogmask +are respectively equivalent to +.Xr syslog 3 , +.Xr vsyslog 3 , +.Xr openlog 3 , +.Xr closelog 3 , +.Xr setlogmask 3 +except that the connection to the +.Nm system.syslog +service needs to be provided. +.Sh EXAMPLES +The following example first opens a capability to casper and then uses this +capability to create the +.Nm system.syslog +casper service to log messages. +.Bd -literal +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."); +.Ed +.Sh SEE ALSO +.Xr cap_enter 2 , +.Xr closelog 3 , +.Xr err 3 , +.Xr nv 3 , +.Xr openlog 3 , +.Xr setlogmask 3 +.Xr syslog 3 , +.Xr vsyslog 3 , +.Xr capsicum 4 +.Sh AUTHORS +.An Mariusz Zaborski Aq Mt oshogbo@FreeBSD.org