Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 May 2003 06:17:24 -0700 (PDT)
From:      Chris Vance <cvance@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 30690 for review
Message-ID:  <200305071317.h47DHOiq029084@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=30690

Change 30690 by cvance@cvance_demo on 2003/05/07 06:16:32

	Allow ugidfw to add rules without requiring a rule number, 
	just use the next empty slot.

Affected files ...

.. //depot/projects/trustedbsd/mac/lib/libugidfw/ugidfw.c#9 edit
.. //depot/projects/trustedbsd/mac/lib/libugidfw/ugidfw.h#5 edit

Differences ...

==== //depot/projects/trustedbsd/mac/lib/libugidfw/ugidfw.c#9 (text+ko) ====

@@ -708,3 +708,40 @@
 
 	return (0);
 }
+
+int
+bsde_add_rule(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);
+	}
+
+	return (0);
+}

==== //depot/projects/trustedbsd/mac/lib/libugidfw/ugidfw.h#5 (text+ko) ====

@@ -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(struct mac_bsdextended_rule *rule, size_t buflen,
+	    char *errstr);
 __END_DECLS
 
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305071317.h47DHOiq029084>