From ace4c0498573b056a34f3298a83e4c476883760c Mon Sep 17 00:00:00 2001 From: rwatson Date: Wed, 18 Feb 2004 05:40:15 +0000 Subject: Add "-q" argument to setfmac and setfsmac to allow the patient but exhausted reader not to see non-fatal warnings. --- usr.sbin/setfmac/setfmac.8 | 8 +++++--- usr.sbin/setfmac/setfmac.c | 24 +++++++++++++++++------- usr.sbin/setfmac/setfsmac.8 | 8 +++++--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/usr.sbin/setfmac/setfmac.8 b/usr.sbin/setfmac/setfmac.8 index 98e5f44..b541a4a 100644 --- a/usr.sbin/setfmac/setfmac.8 +++ b/usr.sbin/setfmac/setfmac.8 @@ -1,4 +1,4 @@ -.\" 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 Chris @@ -29,7 +29,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd March 13, 2003 +.Dd February 17, 2004 .Dt SETFMAC 8 .Os .Sh NAME @@ -37,7 +37,7 @@ .Nd set MAC label for a file system object .Sh SYNOPSIS .Nm setfmac -.Op Fl hR +.Op Fl hqR .Ar label .Ar .Sh DESCRIPTION @@ -52,6 +52,8 @@ just the files themselves. .It Fl h If the file is a symbolic link, change the label of the link rather than the file that the link points to. +.It Fl q +Do not print non-fatal warnings during execution. .El .Sh SEE ALSO .Xr mac 3 , diff --git a/usr.sbin/setfmac/setfmac.c b/usr.sbin/setfmac/setfmac.c index aee0905..d5f5a61 100644 --- a/usr.sbin/setfmac/setfmac.c +++ b/usr.sbin/setfmac/setfmac.c @@ -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 NAI Labs, the @@ -77,6 +77,8 @@ void add_spec_line(const char *, int, struct label_spec_entry *, char *); int apply_specs(struct label_specs *, FTSENT *, int, int); int specs_empty(struct label_specs *); +static int qflag; + int main(int argc, char **argv) { @@ -93,7 +95,8 @@ main(int argc, char **argv) is_setfmac = strcmp(bn, "setfmac") == 0; hflag = is_setfmac ? FTS_LOGICAL : FTS_PHYSICAL; specs = new_specs(); - while ((ch = getopt(argc, argv, is_setfmac ? "Rh" : "ef:s:vx")) != -1) { + while ((ch = getopt(argc, argv, is_setfmac ? "Rhq" : "ef:qs:vx")) != + -1) { switch (ch) { case 'R': Rflag = 1; @@ -107,6 +110,9 @@ main(int argc, char **argv) case 'h': hflag = FTS_PHYSICAL; break; + case 'q': + qflag = 1; + break; case 's': add_specs(specs, optarg, 1); break; @@ -156,8 +162,10 @@ main(int argc, char **argv) "%.*s", ftsent->fts_pathlen, ftsent->fts_path); } - warnx("labeling not supported in %.*s", - ftsent->fts_pathlen, ftsent->fts_path); + if (!qflag) + warnx("labeling not supported in %.*s", + ftsent->fts_pathlen, + ftsent->fts_path); fts_set(fts, ftsent, FTS_SKIP); } break; @@ -181,9 +189,9 @@ usage(int is_setfmac) { if (is_setfmac) - fprintf(stderr, "usage: setfmac [-Rh] label file ...\n"); + fprintf(stderr, "usage: setfmac [-Rhq] label file ...\n"); else - fprintf(stderr, "usage: setfsmac [-ehvx] [-f specfile [...]] [-s specfile [...]] file ...\n"); + fprintf(stderr, "usage: setfsmac [-ehqvx] [-f specfile [...]] [-s specfile [...]] file ...\n"); exit(1); } @@ -270,7 +278,9 @@ add_specs(struct label_specs *specs, const char *file, int is_sebsd) free(line); } fclose(fp); - warnx("%s: read %lu specifications", file, (long)spec->nentries); + if (!qflag) + warnx("%s: read %lu specifications", file, + (long)spec->nentries); STAILQ_INSERT_TAIL(&specs->head, spec, link); } diff --git a/usr.sbin/setfmac/setfsmac.8 b/usr.sbin/setfmac/setfsmac.8 index 62dd494..ca4a918 100644 --- a/usr.sbin/setfmac/setfsmac.8 +++ b/usr.sbin/setfmac/setfsmac.8 @@ -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 Costello @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 13, 2003 +.Dd February 17, 2004 .Os .Dt SETFSMAC 8 .Sh NAME @@ -38,7 +38,7 @@ .Nd set MAC label for a file hierarchy .Sh SYNOPSIS .Nm -.Op Fl ehvx +.Op Fl ehqvx .Oo Fl f Ar specfile Oc ... .Oo Fl s Ar specfile Oc ... .Ar @@ -75,6 +75,8 @@ specification files. .It Fl h When a symbolic link is encountered, change the label of the link rather than the file the link points to. +.It Fl q +Do not print non-fatal warnings during execution. .It Fl s Ar specfile Apply the specifications in .Ar specfile , -- cgit v1.1