From owner-p4-projects@FreeBSD.ORG Tue Feb 24 19:41:46 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 749A216A4D0; Tue, 24 Feb 2004 19:41:46 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F7F116A4CE for ; Tue, 24 Feb 2004 19:41:46 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4959F43D1D for ; Tue, 24 Feb 2004 19:41:46 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i1P3fkGe058826 for ; Tue, 24 Feb 2004 19:41:46 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i1P3fj03058817 for perforce@freebsd.org; Tue, 24 Feb 2004 19:41:45 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 24 Feb 2004 19:41:45 -0800 (PST) Message-Id: <200402250341.i1P3fj03058817@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 47608 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2004 03:41:46 -0000 http://perforce.freebsd.org/chv.cgi?CH=47608 Change 47608 by rwatson@rwatson_paprika on 2004/02/24 19:41:02 Loop back addition of bsd_add_rule() from FreeBSD CVS HEAD to TrustedBSD base. Affected files ... .. //depot/projects/trustedbsd/base/lib/libugidfw/Makefile#4 integrate .. //depot/projects/trustedbsd/base/lib/libugidfw/bsde_get_rule.3#3 integrate .. //depot/projects/trustedbsd/base/lib/libugidfw/libugidfw.3#3 integrate .. //depot/projects/trustedbsd/base/lib/libugidfw/ugidfw.c#5 integrate .. //depot/projects/trustedbsd/base/lib/libugidfw/ugidfw.h#4 integrate Differences ... ==== //depot/projects/trustedbsd/base/lib/libugidfw/Makefile#4 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/lib/libugidfw/Makefile,v 1.4 2003/01/07 11:23:43 chris Exp $ +# $FreeBSD: src/lib/libugidfw/Makefile,v 1.5 2004/02/25 03:24:39 rwatson Exp $ LIB= ugidfw SHLIB_MAJOR= 1 @@ -8,6 +8,7 @@ MAN+= bsde_get_rule.3 bsde_get_rule_count.3 bsde_parse_rule.3 \ bsde_rule_to_string.3 libugidfw.3 +MLINKS= bsde_get_rule.3 bsde_add_rule.3 MLINKS= bsde_get_rule.3 bsde_delete_rule.3 MLINKS+= bsde_get_rule.3 bsde_set_rule.3 MLINKS+= bsde_get_rule_count.3 bsde_get_rule_slots.3 ==== //depot/projects/trustedbsd/base/lib/libugidfw/bsde_get_rule.3#3 (text+ko) ==== @@ -1,4 +1,4 @@ -.\" Copyright (c) 2003 Networks Associates Technology, Inc. +.\" Copyright (c) 2003-2004 Networks Associates Technology, Inc. .\" All rights reserved. .\" .\" This software was developed for the FreeBSD Project by Chris @@ -28,12 +28,13 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libugidfw/bsde_get_rule.3,v 1.2 2003/06/01 19:41:49 ru Exp $ +.\" $FreeBSD: src/lib/libugidfw/bsde_get_rule.3,v 1.3 2004/02/25 03:24:39 rwatson Exp $ .\" -.Dd January 7, 2003 +.Dd February 24, 2004 .Os .Dt BSDE_GET_RULE 3 .Sh NAME +.Nm bsde_add_rule , .Nm bsde_get_rule , .Nm bsde_set_rule , .Nm bsde_delete_rule @@ -43,6 +44,11 @@ .Sh SYNOPSIS .In ugidfw.h .Ft int +.Fo bsde_add_rule +.Fa "int *rulenum" "struct mac_bsdextended_rule *rule" +.Fa "size_t buflen" "char *errstr" +.Fc +.Ft int .Fo bsde_get_rule .Fa "int rulenum" "struct mac_bsdextended_rule *rule" .Fa "size_t errlen" "char *errstr" @@ -56,6 +62,27 @@ .Fn bsde_delete_rule "int rulenum" "size_t errlen" "char *errstr" .Sh DESCRIPTION The +.Fn bsde_add_rule +function fills the next available +rule (in +.Vt "struct mac_bsdextended_rule" +form, either from +.Fn bsde_get_rule +or +.Xr bsde_parse_rule 3 ) . +If an error occurs, +.Fa *errstr +is filled with the error string +(up to +.Fa errlen +characters, including the terminating +.Dv NUL ) . +If successful and +.Fa rulenum +is non-NULL, the rule number used will be returned in +.Fa *rulenum . +.Pp +The .Fn bsde_get_rule function fills in .Fa *rule ==== //depot/projects/trustedbsd/base/lib/libugidfw/libugidfw.3#3 (text+ko) ==== @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libugidfw/libugidfw.3,v 1.3 2003/06/01 19:41:49 ru Exp $ +.\" $FreeBSD: src/lib/libugidfw/libugidfw.3,v 1.4 2004/02/25 03:24:39 rwatson Exp $ .\" .Dd January 5, 2003 .Os @@ -96,6 +96,10 @@ module and applies it; see .Xr bsde_set_rule 3 . +.It Fn bsde_add_rule +Upload the rule to the module, automatically selecting the next available +rule number; see +.Xr bsde_add_rule 3 . .El .Sh SEE ALSO .Xr bsde_delete_rule 3 , ==== //depot/projects/trustedbsd/base/lib/libugidfw/ugidfw.c#5 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002 Networks Associates Technology, Inc. + * Copyright (c) 2002, 2004 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Network Associates @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libugidfw/ugidfw.c,v 1.4 2002/11/07 20:37:04 rwatson Exp $ + * $FreeBSD: src/lib/libugidfw/ugidfw.c,v 1.5 2004/02/25 03:24:39 rwatson Exp $ */ #include #include @@ -708,3 +708,44 @@ return (0); } + +int +bsde_add_rule(int *rulenum, struct mac_bsdextended_rule *rule, size_t buflen, + char *errstr) +{ + char charstr[BUFSIZ]; + int name[10]; + size_t len, size; + int error, rule_slots; + + len = 10; + error = bsde_get_mib(MIB ".rules", name, &len); + if (error) { + len = snprintf(errstr, buflen, "%s: %s", MIB ".rules", + strerror(errno)); + return (-1); + } + + rule_slots = bsde_get_rule_slots(BUFSIZ, charstr); + if (rule_slots == -1) { + len = snprintf(errstr, buflen, "unable to get rule slots: %s", + strerror(errno)); + return (-1); + } + + name[len] = rule_slots; + len++; + + size = sizeof(*rule); + error = sysctl(name, len, NULL, NULL, rule, size); + if (error) { + len = snprintf(errstr, buflen, "%s.%d: %s", MIB ".rules", + rule_slots, strerror(errno)); + return (-1); + } + + if (rulenum != NULL) + rule_slots; + + return (0); +} ==== //depot/projects/trustedbsd/base/lib/libugidfw/ugidfw.h#4 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002 Networks Associates Technology, Inc. + * Copyright (c) 2002, 2004 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Network Associates @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libugidfw/ugidfw.h,v 1.3 2002/11/07 20:37:04 rwatson Exp $ + * $FreeBSD: src/lib/libugidfw/ugidfw.h,v 1.4 2004/02/25 03:24:39 rwatson Exp $ */ #ifndef _UGIDFW_H @@ -54,6 +54,8 @@ int bsde_delete_rule(int rulenum, size_t buflen, char *errstr); int bsde_set_rule(int rulenum, struct mac_bsdextended_rule *rule, size_t buflen, char *errstr); +int bsde_add_rule(int *rulename, struct mac_bsdextended_rule *rule, + size_t buflen, char *errstr); __END_DECLS #endif