From owner-p4-projects Tue Oct 15 11:46:33 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5B44537B401; Tue, 15 Oct 2002 11:46:30 -0700 (PDT) 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 DD99837B404 for ; Tue, 15 Oct 2002 11:46:29 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 787EB43EB7 for ; Tue, 15 Oct 2002 11:46:29 -0700 (PDT) (envelope-from green@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id g9FIkTMt085997 for ; Tue, 15 Oct 2002 11:46:29 -0700 (PDT) (envelope-from green@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.3/Submit) id g9FIkS1h085994 for perforce@freebsd.org; Tue, 15 Oct 2002 11:46:28 -0700 (PDT) Date: Tue, 15 Oct 2002 11:46:28 -0700 (PDT) Message-Id: <200210151846.g9FIkS1h085994@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to green@freebsd.org using -f From: Brian Feldman Subject: PERFORCE change 19342 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include #include -#include +#include #include +#include #include #include @@ -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, "<>") == 0) { spec[nspec].sid = 0; } else { To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message