Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 2002 11:46:28 -0700 (PDT)
From:      Brian Feldman <green@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 19342 for review
Message-ID:  <200210151846.g9FIkS1h085994@repoman.freebsd.org>

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

Change 19342 by green@green_laptop_2 on 2002/10/15 11:46:02

	Use MAC calls, not extattr calls, to set the labels.

Affected files ...

.. //depot/projects/trustedbsd/mac/sbin/sebsd_setfiles/setfiles.c#8 edit

Differences ...

==== //depot/projects/trustedbsd/mac/sbin/sebsd_setfiles/setfiles.c#8 (text+ko) ====

@@ -44,8 +44,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/param.h>
-#include <sys/extattr.h>
+#include <sys/mac.h>
 #include <fts.h>
+#include <err.h>
 
 #include <flask.h>
 #include <sebsd.h>
@@ -61,6 +62,7 @@
 	char *type_str;		/* type string for diagnostic messages */
 	char *context;		/* context string */
 	int contextlen;		/* length of context string */
+	mac_t maclabel;		/* context converted into a mac label */
 	regex_t regex;		/* compiled regular expression */
 	mode_t mode;		/* mode format value */
 	security_id_t sid;      /* SID */
@@ -172,17 +174,9 @@
 	 * For now, skip it and over-write prior labels.
 	 */
 
-	error = extattr_set_link(path, SEBSD_MAC_EXTATTR_NAMESPACE,
-				 SEBSD_MAC_EXTATTR_NAME, spec[idx].context,
-				 spec[idx].contextlen);
-	if (error != spec[idx].contextlen) {
-		perror("ERROR setting extended attribute");
-		printf("ERROR setting extended attribute for %s, "
-		       "bad write %d of %d\n",
-		       path, error, spec[idx].contextlen);
-	}
-	if (error < 0)
-		printf("ERROR setting extended attribute for %s\n", path);
+	error = mac_set_link(path, spec[idx].maclabel);
+	if (error)
+		warn("setting context for %s", path);
 
 	return;
 }
@@ -199,7 +193,7 @@
 int main(int argc, char **argv)
 {
 	FILE *fp;
-	char buf[255 + 1], *buf_p;
+	char buf[255 + 1], *buf_p, *labeltext;
 	char regex[1024], type[1024], context[1024];
 	char *anchored_regex;
 	int ch, items, len, lineno, pass, nerr, regerr;
@@ -348,6 +342,13 @@
 
 				spec[nspec].context = strdup(context);
 				spec[nspec].contextlen = strlen(context)+1;
+				asprintf(&labeltext, "sebsd/%s", context);
+				if (labeltext == NULL)
+					err(1, "asprintf");
+				if (mac_from_text(&spec[nspec].maclabel,
+				    labeltext) != 0)
+					err(1, "mac_from_text(%s)", labeltext);
+				free(labeltext);
 				if (strcmp(context, "<<none>>") == 0) {
 					spec[nspec].sid = 0;
 				} else {

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




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