From owner-svn-src-head@freebsd.org Sat Jun 23 20:12:32 2018 Return-Path: Delivered-To: svn-src-head@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 4B30410048E6; Sat, 23 Jun 2018 20:12:32 +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 016CA911A6; Sat, 23 Jun 2018 20:12:32 +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 BC9C514974; Sat, 23 Jun 2018 20:12:31 +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 w5NKCV7r013204; Sat, 23 Jun 2018 20:12:31 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5NKCV3c013202; Sat, 23 Jun 2018 20:12:31 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201806232012.w5NKCV3c013202@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 23 Jun 2018 20:12:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335588 - head/lib/libcasper/libcasper X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: head/lib/libcasper/libcasper X-SVN-Commit-Revision: 335588 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2018 20:12:32 -0000 Author: oshogbo Date: Sat Jun 23 20:12:30 2018 New Revision: 335588 URL: https://svnweb.freebsd.org/changeset/base/335588 Log: Document libcasper_service. Reviewed by: bcr@ Differential Revision: https://reviews.freebsd.org/D15766 Added: head/lib/libcasper/libcasper/libcasper_service.3 (contents, props changed) Modified: head/lib/libcasper/libcasper/Makefile head/lib/libcasper/libcasper/libcasper.3 Modified: head/lib/libcasper/libcasper/Makefile ============================================================================== --- head/lib/libcasper/libcasper/Makefile Sat Jun 23 20:05:07 2018 (r335587) +++ head/lib/libcasper/libcasper/Makefile Sat Jun 23 20:12:30 2018 (r335588) @@ -25,6 +25,7 @@ LIBADD= nv CFLAGS+=-I${.CURDIR} MAN+= libcasper.3 +MAN+= libcasper_service.3 MLINKS+=libcasper.3 cap_init.3 MLINKS+=libcasper.3 cap_wrap.3 @@ -38,5 +39,7 @@ MLINKS+=libcasper.3 cap_send_nvlist.3 MLINKS+=libcasper.3 cap_recv_nvlist.3 MLINKS+=libcasper.3 cap_xfer_nvlist.3 MLINKS+=libcasper.3 cap_service_open.3 + +MLINKS+=libcasper_service.3 CREATE_SERVICE.3 .include Modified: head/lib/libcasper/libcasper/libcasper.3 ============================================================================== --- head/lib/libcasper/libcasper/libcasper.3 Sat Jun 23 20:05:07 2018 (r335587) +++ head/lib/libcasper/libcasper/libcasper.3 Sat Jun 23 20:12:30 2018 (r335588) @@ -265,6 +265,7 @@ functions always succeed. .Xr cap_ranodm 3 , .Xr cap_sysctl 3 , .Xr cap_syslog 3 , +.Xr libcasper_service 3 , .Xr capsicum 4 , .Xr unix 4 , .Xr nv 9 Added: head/lib/libcasper/libcasper/libcasper_service.3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libcasper/libcasper/libcasper_service.3 Sat Jun 23 20:12:30 2018 (r335588) @@ -0,0 +1,116 @@ +.\" 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 June 23, 2018 +.Dt LIBCASPER 3 +.Os +.Sh NAME +.Nm CREATE_SERVICE +.Nd "casper service declaration macro" +.Sh LIBRARY +.Lb libcasper +.Sh SYNOPSIS +.In sys/nv.h +.In libcasper.h +.In libcasper_service.h +.Bd -literal +typedef int service_limit_func_t(const nvlist_t *, const nvlist_t *); + +typedef int service_command_func_t(const char *, const nvlist_t *, nvlist_t *, + nvlist_t *); + +.Ed +.Fn CREATE_SERVICE "name" "limit_func" "command_func" "flags" +.Sh DESCRIPTION +The +.Nm CREATE_SERVICE +macro to create a new Casper service. +The +.Fa name +is a string containing the service name, which will be used in the +.Xr cap_service_open 3, +function to identify it. +.Pp +The +.Fa limit_func +is a function of type +.Li service_limit_func_t . +The first argument of the function contains +.Xr nvlist 9 , +old service limits and second one the new limits. +If the services wasn't limited the old limits will be set to +.Dv NULL . +This function should not allow to extend service limits and only limit it +further. +The +.Fa command_func +is a function of type +.Li service_command_func_t . +First argument is the name of the command that should be executed. +The first +.Xr nvlist 9 +contains the current limits. +Next one contains a +.Xr nvlist 9 +with current request. +The last one contains an output +.Xr nvlist 9 +which contains the response from Casper. +.Pp +The +.Fa flags +argument defines limits of the service. +The supported flags are: +.Bl -ohang -offset indent +.It CASPER_SERVICE_STDIO +The Casper service has access to the stdio descriptors from the process it was +spawned from. +.It CASPER_SERVICE_FD +The Casper service has access to all descriptors besides stdio descriptors from +the process it was spawned from. +.It CASPER_SERVICE_NO_UNIQ_LIMITS +The whole Casper communication is using +.Xr nvlist 9 +with +.Xr NVLIST_NO_UNIQ 9 +flag. +.El +.Sh SEE ALSO +.Xr cap_enter 2 , +.Xr libcasper 3 , +.Xr capsicum 4 , +.Xr nv 9 +.Sh AUTHORS +The +.Nm libcasper +library was implemented by +.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net +under sponsorship from the FreeBSD Foundation. +The +.Nm libcasper +new architecture was implemented by +.An Mariusz Zaborski Aq Mt oshogbo@FreeBSD.org +.