Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jul 2001 13:14:17 -0600 (MDT)
From:      Lyndon Nerenberg <lyndon@orthanc.ab.ca>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/28729: [PATCH] ipfw usage verbiage buries the actual error message
Message-ID:  <200107051914.f65JEHL53572@orthanc.ab.ca>

next in thread | raw e-mail | index | archive | help

>Number:         28729
>Category:       bin
>Synopsis:       [PATCH] ipfw usage verbiage buries the actual error message
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 05 12:20:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Lyndon Nerenberg
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
The Frobozz Magic Homing Pigeon Company
>Environment:
System: FreeBSD orthanc.ab.ca 4.3-STABLE FreeBSD 4.3-STABLE #1: Thu Jun 28 13:31:23 MDT 2001 lyndon@orthanc.ab.ca:/u/freebsd/obj/u/freebsd/cvssrc/RELENG_4/sys/FROBOZZ i386


>Description:

Any ipfw command line error results is a one line message describing
the error, followed by a multi-line usage statement. The usage statement
is so long that it forces the original error message to scroll off the
screen. This makes it very difficult to catch errors at boot time.

>How-To-Repeat:
>Fix:

Apply the following patch, which suppresses the annoying usage message.

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	ipfw.diff
#
echo x - ipfw.diff
sed 's/^X//' >ipfw.diff << 'END-of-ipfw.diff'
XIndex: ipfw.c
X===================================================================
XRCS file: /home/ncvs/src/sbin/ipfw/ipfw.c,v
Xretrieving revision 1.80.2.9
Xdiff -u -r1.80.2.9 ipfw.c
X--- ipfw.c	2001/02/20 11:39:11	1.80.2.9
X+++ ipfw.c	2001/07/05 19:07:20
X@@ -93,8 +93,6 @@
X       { 0, NULL }
X };
X 
X-static void show_usage(const char *fmt, ...);
X-
X static int
X mask_bits(struct in_addr m_ad)
X {
X@@ -804,62 +802,6 @@
X 	free(data);
X }
X 
X-static void
X-show_usage(const char *fmt, ...)
X-{
X-	if (fmt) {
X-		char buf[100];
X-		va_list args;
X-
X-		va_start(args, fmt);
X-		vsnprintf(buf, sizeof(buf), fmt, args);
X-		va_end(args);
X-		warnx("error: %s", buf);
X-	}
X-	fprintf(stderr, "usage: ipfw [options]\n"
X-"    [pipe] flush\n"
X-"    add [number] rule\n"
X-"    [pipe] delete number ...\n"
X-"    [pipe] list [number ...]\n"
X-"    [pipe] show [number ...]\n"
X-"    zero [number ...]\n"
X-"    resetlog [number ...]\n"
X-"    pipe number config [pipeconfig]\n"
X-"  rule: [prob <match_probability>] action proto src dst extras...\n"
X-"    action:\n"
X-"      {allow|permit|accept|pass|deny|drop|reject|unreach code|\n"
X-"       reset|count|skipto num|divert port|tee port|fwd ip|\n"
X-"       pipe num} [log [logamount count]]\n"
X-"    proto: {ip|tcp|udp|icmp|<number>}\n"
X-"    src: from [not] {me|any|ip[{/bits|:mask}]} [{port|port-port},[port],...]\n"
X-"    dst: to [not] {me|any|ip[{/bits|:mask}]} [{port|port-port},[port],...]\n"
X-"  extras:\n"
X-"    uid {user id}\n"
X-"    gid {group id}\n"
X-"    fragment     (may not be used with ports or tcpflags)\n"
X-"    in\n"
X-"    out\n"
X-"    {xmit|recv|via} {iface|ip|any}\n"
X-"    {established|setup}\n"
X-"    tcpflags [!]{syn|fin|rst|ack|psh|urg},...\n"
X-"    ipoptions [!]{ssrr|lsrr|rr|ts},...\n"
X-"    tcpoptions [!]{mss|window|sack|ts|cc},...\n"
X-"    icmptypes {type[,type]}...\n"
X-"  pipeconfig:\n"
X-"    {bw|bandwidth} <number>{bit/s|Kbit/s|Mbit/s|Bytes/s|KBytes/s|MBytes/s}\n"
X-"    {bw|bandwidth} interface_name\n"
X-"    delay <milliseconds>\n"
X-"    queue <size>{packets|Bytes|KBytes}\n"
X-"    plr <fraction>\n"
X-"    mask {all| [dst-ip|src-ip|dst-port|src-port|proto] <number>}\n"
X-"    buckets <number>}\n"
X-"    {red|gred} <fraction>/<number>/<number>/<fraction>\n"
X-"    droptail\n"
X-);
X-
X-	exit(EX_USAGE);
X-}
X-
X static int
X lookup_host (host, ipaddr)
X 	char *host;
X@@ -897,17 +839,17 @@
X 		}
X 
X 		if (lookup_host(*av, ipno) != 0)
X-			show_usage("hostname ``%s'' unknown", *av);
X+			errx(EX_USAGE, "hostname ``%s'' unknown", *av);
X 		switch (md) {
X 			case ':':
X 				if (!inet_aton(p,mask))
X-					show_usage("bad netmask ``%s''", p);
X+					errx(EX_USAGE, "bad netmask ``%s''", p);
X 				break;
X 			case '/':
X 				if (atoi(p) == 0) {
X 					mask->s_addr = 0;
X 				} else if (atoi(p) > 32) {
X-					show_usage("bad width ``%s''", p);
X+					errx(EX_USAGE, "bad width ``%s''", p);
X 				} else {
X 					mask->s_addr =
X 					    htonl(~0 << (32 - atoi(p)));
X@@ -942,7 +884,7 @@
X 			*codep = ic->code;
X 			return;
X 		}
X-	show_usage("unknown ICMP unreachable code ``%s''", str);
X+	errx(EX_USAGE, "unknown ICMP unreachable code ``%s''", str);
X }
X 
X static void
X@@ -1092,7 +1034,7 @@
X 				break;
X 			}
X 		if (i == sizeof(flags) / sizeof(flags[0]))
X-			show_usage("invalid tcp flag ``%s''", p);
X+			errx(EX_USAGE, "invalid tcp flag ``%s''", p);
X 		p = q;
X 	}
X }
X@@ -1131,7 +1073,7 @@
X 				break;
X 			}
X 		if (i == sizeof(opts) / sizeof(opts[0]))
X-			show_usage("invalid tcp option ``%s''", p);
X+			errx(EX_USAGE, "invalid tcp option ``%s''", p);
X 		p = q;
X 	}
X }
X@@ -1178,10 +1120,10 @@
X 		icmptype = strtoul(c, &c, 0);
X 
X 		if ( *c != ',' && *c != '\0' )
X-			show_usage("invalid ICMP type");
X+			errx(EX_USAGE, "invalid ICMP type");
X 
X 		if (icmptype >= IP_FW_ICMPTYPES_DIM * sizeof(unsigned) * 8)
X-			show_usage("ICMP type out of range");
X+			errx(EX_USAGE, "ICMP type out of range");
X 
X 		types[icmptype / (sizeof(unsigned) * 8)] |= 
X 			1 << (icmptype % (sizeof(unsigned) * 8));
X@@ -1254,7 +1196,7 @@
X fill_iface(char *which, union ip_fw_if *ifu, int *byname, int ac, char *arg)
X {
X 	if (!ac)
X-	    show_usage("missing argument for ``%s''", which);
X+	    errx(EX_USAGE, "missing argument for ``%s''", which);
X 
X 	/* Parse the interface or address */
X 	if (!strcmp(arg, "any")) {
X@@ -1273,7 +1215,7 @@
X 		*q = '\0';
X 		verify_interface(ifu);
X 	} else if (!inet_aton(arg, &ifu->fu_via_ip)) {
X-		show_usage("bad ip address ``%s''", arg);
X+		errx(EX_USAGE, "bad ip address ``%s''", arg);
X 	} else
X 		*byname = 0;
X }
X@@ -1359,7 +1301,7 @@
X                     else
X                         break ;
X                     if (ac < 2)
X-                        show_usage("mask: %s value missing", *av);
X+                        errx(EX_USAGE, "mask: %s value missing", *av);
X                     if (*av[1] == '/') {
X                         a = strtoul(av[1]+1, &end, 0);
X                         if (a == 32) /* special case... */
X@@ -1372,12 +1314,12 @@
X                     if ( (u_int16_t *)par == &(pipe.fs.flow_mask.src_port) ||
X                          (u_int16_t *)par == &(pipe.fs.flow_mask.dst_port) ) {
X                         if (a >= (1<<16) )
X-                            show_usage("mask: %s must be 16 bit, not 0x%08x",
X+                            errx(EX_USAGE, "mask: %s must be 16 bit, not 0x%08x",
X                                 *av, a);
X                         *((u_int16_t *)par) = (u_int16_t) a;
X                     } else if ( (u_int8_t *)par == &(pipe.fs.flow_mask.proto) ) {
X                         if (a >= (1<<8) )
X-                            show_usage("mask: %s must be 8 bit, not 0x%08x",
X+                            errx(EX_USAGE, "mask: %s must be 8 bit, not 0x%08x",
X                                 *av, a);
X                         *((u_int8_t *)par) = (u_int8_t) a;
X                     } else
X@@ -1395,7 +1337,7 @@
X 		if ( (end = strsep(&av[1],"/")) ) {
X 		    double w_q = strtod(end, NULL) ;
X 		    if (w_q > 1 || w_q <= 0) 
X-			show_usage("w_q %f must be 0 < x <= 1", w_q ) ;
X+			errx(EX_USAGE, "w_q %f must be 0 < x <= 1", w_q ) ;
X 		    pipe.fs.w_q = (int) ( w_q * (1 << SCALE_RED) ) ;
X 		}
X 		if ( (end = strsep(&av[1],"/")) ) {
X@@ -1411,7 +1353,7 @@
X 		if ( (end = strsep(&av[1],"/")) ) {
X 		    double max_p = strtod(end, NULL) ;
X 		    if (max_p > 1 || max_p <= 0) 
X-			show_usage("max_p %f must be 0 < x <= 1", max_p ) ;
X+			errx(EX_USAGE, "max_p %f must be 0 < x <= 1", max_p ) ;
X 		    pipe.fs.max_p = (int) ( max_p * (1 << SCALE_RED) ) ;
X 		}
X 		av+=2 ; ac-=2 ;
X@@ -1444,7 +1386,7 @@
X 			pipe.delay = strtoul(av[1], NULL, 0);
X 			av+=2; ac-=2;
X             } else
X-			show_usage("unrecognised pipe option ``%s''", *av);
X+			errx(EX_USAGE, "unrecognised pipe option ``%s''", *av);
X 		} else { /* this refers to a queue */
X 		    if (!strncmp(*av,"weight",strlen(*av)) ) {
X 			pipe.fs.weight = strtoul(av[1], &end, 0) ;
X@@ -1455,36 +1397,36 @@
X 			av += 2;
X 			ac -= 2;
X             } else
X-                show_usage("unrecognised option ``%s''", *av);
X+                errx(EX_USAGE, "unrecognised option ``%s''", *av);
X         }
X 	    }
X         }
X 	if (do_pipe == 1) {
X         if (pipe.pipe_nr == 0 )
X-		show_usage("pipe_nr %d must be > 0", pipe.pipe_nr);
X+		errx(EX_USAGE, "pipe_nr %d must be > 0", pipe.pipe_nr);
X         if (pipe.delay > 10000 )
X-            show_usage("delay %d must be < 10000", pipe.delay);
X+            errx(EX_USAGE, "delay %d must be < 10000", pipe.delay);
X 	} else { /* do_pipe == 2, queue */
X 	    if (pipe.fs.parent_nr == 0)
X-		show_usage("pipe %d must be > 0", pipe.fs.parent_nr);
X+		errx(EX_USAGE, "pipe %d must be > 0", pipe.fs.parent_nr);
X 	    if (pipe.fs.weight >100)
X-		show_usage("weight %d must be <= 100", pipe.fs.weight);
X+		errx(EX_USAGE, "weight %d must be <= 100", pipe.fs.weight);
X 	}
X 	if (pipe.fs.flags_fs & DN_QSIZE_IS_BYTES ) {
X 	    if (pipe.fs.qsize > 1024*1024 )
X-		show_usage("queue size %d, must be < 1MB",
X+		errx(EX_USAGE, "queue size %d, must be < 1MB",
X 		    pipe.fs.qsize);
X 	} else {
X 	    if (pipe.fs.qsize > 100 )
X-		show_usage("queue size %d, must be 2 <= x <= 100",
X+		errx(EX_USAGE, "queue size %d, must be 2 <= x <= 100",
X 		    pipe.fs.qsize);
X 	}
X 	if (pipe.fs.flags_fs & DN_IS_RED) {
X 	    if ( pipe.fs.min_th >= pipe.fs.max_th ) 
X-		show_usage("min_th %d must be < than max_th %d", 
X+		errx(EX_USAGE, "min_th %d must be < than max_th %d", 
X 			pipe.fs.min_th, pipe.fs.max_th) ;
X 	    if ( pipe.fs.max_th == 0 ) 
X-		show_usage("max_th must be > 0") ;
X+		errx(EX_USAGE, "max_th must be > 0") ;
X 	    if ( pipe.bandwidth ) {
X 		size_t len ; 
X 		int lookup_depth, avg_pkt_size ;
X@@ -1499,7 +1441,7 @@
X 		    errx(1, "sysctlbyname(\"%s\")",
X 			    "net.inet.ip.dummynet.red_lookup_depth");
X 		if (lookup_depth == 0) 
X-		    show_usage("net.inet.ip.dummynet.red_lookup_depth must" 
X+		    errx(EX_USAGE, "net.inet.ip.dummynet.red_lookup_depth must" 
X 			    "greater than zero") ;
X 
X 		len = sizeof(int) ;
X@@ -1509,7 +1451,7 @@
X 		    errx(1, "sysctlbyname(\"%s\")",
X 			    "net.inet.ip.dummynet.red_avg_pkt_size");
X 		if (avg_pkt_size == 0) 
X-		    show_usage("net.inet.ip.dummynet.red_avg_pkt_size must" 
X+		    errx(EX_USAGE, "net.inet.ip.dummynet.red_avg_pkt_size must" 
X 				"greater than zero") ;
X 
X 		len = sizeof(struct clockinfo) ;
X@@ -1570,7 +1512,7 @@
X 	if (ac > 1 && !strncmp(*av, "prob", strlen(*av) ) ) {
X 		double d = strtod(av[1], NULL);
X 		if (d <= 0 || d > 1)
X-			show_usage("illegal match prob. %s", av[1]);
X+			errx(EX_USAGE, "illegal match prob. %s", av[1]);
X 		if (d != 1) { /* 1 means always match */
X 			rule.fw_flg |= IP_FW_F_RND_MATCH ;
X 			/* we really store dont_match probability */
X@@ -1580,7 +1522,7 @@
X 	}
X 
X 	if (ac == 0)
X-		show_usage("missing action");
X+		errx(EX_USAGE, "missing action");
X 	if (!strncmp(*av,"accept",strlen(*av))
X 		    || !strncmp(*av,"pass",strlen(*av))
X 		    || !strncmp(*av,"allow",strlen(*av))
X@@ -1591,17 +1533,17 @@
X         } else if (!strncmp(*av,"pipe",strlen(*av))) {
X                 rule.fw_flg |= IP_FW_F_PIPE; av++; ac--;
X                 if (!ac)
X-                        show_usage("missing pipe number");
X+                        errx(EX_USAGE, "missing pipe number");
X                 rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--;
X         } else if (!strncmp(*av,"queue",strlen(*av))) {
X                 rule.fw_flg |= IP_FW_F_QUEUE; av++; ac--;
X                 if (!ac)
X-                        show_usage("missing queue number");
X+                        errx(EX_USAGE, "missing queue number");
X                 rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--;
X 	} else if (!strncmp(*av,"divert",strlen(*av))) {
X 		rule.fw_flg |= IP_FW_F_DIVERT; av++; ac--;
X 		if (!ac)
X-			show_usage("missing %s port", "divert");
X+			errx(EX_USAGE, "missing %s port", "divert");
X 		rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--;
X 		if (rule.fw_divert_port == 0) {
X 			struct servent *s;
X@@ -1610,12 +1552,12 @@
X 			if (s != NULL)
X 				rule.fw_divert_port = ntohs(s->s_port);
X 			else
X-				show_usage("illegal %s port", "divert");
X+				errx(EX_USAGE, "illegal %s port", "divert");
X 		}
X 	} else if (!strncmp(*av,"tee",strlen(*av))) {
X 		rule.fw_flg |= IP_FW_F_TEE; av++; ac--;
X 		if (!ac)
X-			show_usage("missing %s port", "tee divert");
X+			errx(EX_USAGE, "missing %s port", "tee divert");
X 		rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--;
X 		if (rule.fw_divert_port == 0) {
X 			struct servent *s;
X@@ -1624,7 +1566,7 @@
X 			if (s != NULL)
X 				rule.fw_divert_port = ntohs(s->s_port);
X 			else
X-				show_usage("illegal %s port", "tee divert");
X+				errx(EX_USAGE, "illegal %s port", "tee divert");
X 		}
X 	} else if (!strncmp(*av,"fwd",strlen(*av)) ||
X 		   !strncmp(*av,"forward",strlen(*av))) {
X@@ -1632,7 +1574,7 @@
X 		char *pp;
X 		rule.fw_flg |= IP_FW_F_FWD; av++; ac--;
X 		if (!ac)
X-			show_usage("missing forwarding IP address");
X+			errx(EX_USAGE, "missing forwarding IP address");
X 		rule.fw_fwd_ip.sin_len = sizeof(struct sockaddr_in);
X 		rule.fw_fwd_ip.sin_family = AF_INET;
X 		rule.fw_fwd_ip.sin_port = 0;
X@@ -1644,18 +1586,18 @@
X 			*(pp++) = '\0';
X 			i = lookup_port(pp, 0, 1, 0);
X 			if (i == -1)
X-				show_usage("illegal forwarding port ``%s''", pp);
X+				errx(EX_USAGE, "illegal forwarding port ``%s''", pp);
X 			else
X 				rule.fw_fwd_ip.sin_port = (u_short)i;
X 		}
X 		fill_ip(&(rule.fw_fwd_ip.sin_addr), &dummyip, &ac, &av);
X 		if (rule.fw_fwd_ip.sin_addr.s_addr == 0)
X-			show_usage("illegal forwarding IP address");
X+			errx(EX_USAGE, "illegal forwarding IP address");
X 
X 	} else if (!strncmp(*av,"skipto",strlen(*av))) {
X 		rule.fw_flg |= IP_FW_F_SKIPTO; av++; ac--;
X 		if (!ac)
X-			show_usage("missing skipto rule number");
X+			errx(EX_USAGE, "missing skipto rule number");
X 		rule.fw_skipto_rule = strtoul(*av, NULL, 0); av++; ac--;
X 	} else if ((!strncmp(*av,"deny",strlen(*av))
X 		    || !strncmp(*av,"drop",strlen(*av)))) {
X@@ -1673,7 +1615,7 @@
X 		rule.fw_flg |= IP_FW_F_CHECK_S ; av++; ac--;
X 		goto done ;
X 	} else {
X-		show_usage("invalid action ``%s''", *av);
X+		errx(EX_USAGE, "invalid action ``%s''", *av);
X 	}
X 
X 	/* [log] */
X@@ -1682,13 +1624,13 @@
X 	}
X 	if (ac && !strncmp(*av,"logamount",strlen(*av))) {
X 		if (!(rule.fw_flg & IP_FW_F_PRN))
X-			show_usage("``logamount'' not valid without ``log''");
X+			errx(EX_USAGE, "``logamount'' not valid without ``log''");
X 		ac--; av++;
X 		if (!ac)
X-			show_usage("``logamount'' requires argument");
X+			errx(EX_USAGE, "``logamount'' requires argument");
X 		rule.fw_logamount = atoi(*av);
X 		if (rule.fw_logamount < 0)
X-			show_usage("``logamount'' argument must be positive");
X+			errx(EX_USAGE, "``logamount'' argument must be positive");
X 		if (rule.fw_logamount == 0)
X 			rule.fw_logamount = -1;
X 		ac--; av++;
X@@ -1696,7 +1638,7 @@
X 
X 	/* protocol */
X 	if (ac == 0)
X-		show_usage("missing protocol");
X+		errx(EX_USAGE, "missing protocol");
X 	if ((proto = atoi(*av)) > 0) {
X 		rule.fw_prot = proto; av++; ac--;
X 	} else if (!strncmp(*av,"all",strlen(*av))) {
X@@ -1704,25 +1646,25 @@
X 	} else if ((pe = getprotobyname(*av)) != NULL) {
X 		rule.fw_prot = pe->p_proto; av++; ac--;
X 	} else {
X-		show_usage("invalid protocol ``%s''", *av);
X+		errx(EX_USAGE, "invalid protocol ``%s''", *av);
X 	}
X 
X 	if (rule.fw_prot != IPPROTO_TCP
X 	    && (rule.fw_flg & IP_FW_F_COMMAND) == IP_FW_F_REJECT
X 	    && rule.fw_reject_code == IP_FW_REJECT_RST)
X-		show_usage("``reset'' is only valid for tcp packets");
X+		errx(EX_USAGE, "``reset'' is only valid for tcp packets");
X 
X 	/* from */
X 	if (ac && !strncmp(*av,"from",strlen(*av))) { av++; ac--; }
X 	else
X-		show_usage("missing ``from''");
X+		errx(EX_USAGE, "missing ``from''");
X 
X 	if (ac && !strncmp(*av,"not",strlen(*av))) {
X 		rule.fw_flg |= IP_FW_F_INVSRC;
X 		av++; ac--;
X 	}
X 	if (!ac)
X-		show_usage("missing arguments");
X+		errx(EX_USAGE, "missing arguments");
X 
X 	if (ac && !strncmp(*av,"me",strlen(*av))) {
X 		rule.fw_flg |= IP_FW_F_SME;
X@@ -1747,14 +1689,14 @@
X 	/* to */
X 	if (ac && !strncmp(*av,"to",strlen(*av))) { av++; ac--; }
X 	else
X-		show_usage("missing ``to''");
X+		errx(EX_USAGE, "missing ``to''");
X 
X 	if (ac && !strncmp(*av,"not",strlen(*av))) {
X 		rule.fw_flg |= IP_FW_F_INVDST;
X 		av++; ac--;
X 	}
X 	if (!ac)
X-		show_usage("missing arguments");
X+		errx(EX_USAGE, "missing arguments");
X 
X 	if (ac && !strncmp(*av,"me",strlen(*av))) {
X 		rule.fw_flg |= IP_FW_F_DME;
X@@ -1779,7 +1721,7 @@
X 
X 	if ((rule.fw_prot != IPPROTO_TCP) && (rule.fw_prot != IPPROTO_UDP)
X 	    && (IP_FW_GETNSRCP(&rule) || IP_FW_GETNDSTP(&rule))) {
X-		show_usage("only TCP and UDP protocols are valid"
X+		errx(EX_USAGE, "only TCP and UDP protocols are valid"
X 		    " with port specifications");
X 	}
X 
X@@ -1792,7 +1734,7 @@
X 			rule.fw_flg |= IP_FW_F_UID;
X 			ac--; av++;
X 			if (!ac)
X-				show_usage("``uid'' requires argument");
X+				errx(EX_USAGE, "``uid'' requires argument");
X 			
X 			uid = strtoul(*av, &end, 0);
X 			if (*end == '\0')
X@@ -1800,7 +1742,7 @@
X 			else
X 				pwd = getpwnam(*av);
X 			if (pwd == NULL)
X-				show_usage("uid \"%s\" is nonexistant", *av);
X+				errx(EX_USAGE, "uid \"%s\" is nonexistant", *av);
X 			rule.fw_uid = pwd->pw_uid;
X 			ac--; av++;
X 			continue;
X@@ -1813,7 +1755,7 @@
X 			rule.fw_flg |= IP_FW_F_GID;
X 			ac--; av++;
X 			if (!ac)
X-				show_usage("``gid'' requires argument");
X+				errx(EX_USAGE, "``gid'' requires argument");
X 			
X 			gid = strtoul(*av, &end, 0);
X 			if (*end == '\0')
X@@ -1821,7 +1763,7 @@
X 			else
X 				grp = getgrnam(*av);
X 			if (grp == NULL)
X-				show_usage("gid \"%s\" is nonexistant", *av);
X+				errx(EX_USAGE, "gid \"%s\" is nonexistant", *av);
X 			rule.fw_gid = grp->gr_gid;
X 			ac--; av++;
X 			continue;
X@@ -1855,7 +1797,7 @@
X 
X 			if (saw_via) {
X badviacombo:
X-				show_usage("``via'' is incompatible"
X+				errx(EX_USAGE, "``via'' is incompatible"
X 				    " with ``xmit'' and ``recv''");
X 			}
X 			saw_xmrc = 1;
X@@ -1904,7 +1846,7 @@
X 		if (!strncmp(*av,"ipoptions",strlen(*av))) { 
X 			av++; ac--; 
X 			if (!ac)
X-				show_usage("missing argument"
X+				errx(EX_USAGE, "missing argument"
X 				    " for ``ipoptions''");
X 			fill_ipopt(&rule.fw_ipopt, &rule.fw_ipnopt, av);
X 			av++; ac--; continue;
X@@ -1922,7 +1864,7 @@
X 			if (!strncmp(*av,"tcpflags",strlen(*av)) || !strncmp(*av,"tcpflgs",strlen(*av))) { 
X 				av++; ac--; 
X 				if (!ac)
X-					show_usage("missing argument"
X+					errx(EX_USAGE, "missing argument"
X 					    " for ``tcpflags''");
X 				fill_tcpflag(&rule.fw_tcpf, &rule.fw_tcpnf, av);
X 				av++; ac--; continue;
X@@ -1930,7 +1872,7 @@
X 			if (!strncmp(*av,"tcpoptions",strlen(*av)) || !strncmp(*av, "tcpopts",strlen(*av))) { 
X 				av++; ac--; 
X 				if (!ac)
X-					show_usage("missing argument"
X+					errx(EX_USAGE, "missing argument"
X 					    " for ``tcpoptions''");
X 				fill_tcpopts(&rule.fw_tcpopt, &rule.fw_tcpnopt, av);
X 				av++; ac--; continue;
X@@ -1940,14 +1882,14 @@
X 			if (!strncmp(*av,"icmptypes",strlen(*av))) {
X 				av++; ac--;
X 				if (!ac)
X-					show_usage("missing argument"
X+					errx(EX_USAGE, "missing argument"
X 					    " for ``icmptypes''");
X 				fill_icmptypes(rule.fw_uar.fw_icmptypes,
X 				    av, &rule.fw_flg);
X 				av++; ac--; continue;
X 			}
X 		}
X-		show_usage("unknown argument ``%s''", *av);
X+		errx(EX_USAGE, "unknown argument ``%s''", *av);
X 	}
X 
X 	/* No direction specified -> do both directions */
X@@ -1961,15 +1903,15 @@
X 		if (rule.fw_flg & IP_FW_F_OUT)
X 			rule.fw_flg |= IP_FW_F_OIFACE;
X 	} else if ((rule.fw_flg & IP_FW_F_OIFACE) && (rule.fw_flg & IP_FW_F_IN))
X-		show_usage("can't check xmit interface of incoming packets");
X+		errx(EX_USAGE, "can't check xmit interface of incoming packets");
X 
X 	/* frag may not be used in conjunction with ports or TCP flags */
X 	if (rule.fw_flg & IP_FW_F_FRAG) {
X 		if (rule.fw_tcpf || rule.fw_tcpnf)
X-			show_usage("can't mix 'frag' and tcpflags");
X+			errx(EX_USAGE, "can't mix 'frag' and tcpflags");
X 
X 		if (rule.fw_nports)
X-			show_usage("can't mix 'frag' and port specifications");
X+			errx(EX_USAGE, "can't mix 'frag' and port specifications");
X 	}
X 	if (rule.fw_flg & IP_FW_F_PRN) {
X 		if (!rule.fw_logamount) {
X@@ -2023,7 +1965,7 @@
X 					printf("Entry %d cleared\n",
X 					    rule.fw_number);
X 			} else
X-				show_usage("invalid rule number ``%s''", *av);
X+				errx(EX_USAGE, "invalid rule number ``%s''", *av);
X 		}
X 		if (failed != EX_OK)
X 			exit(failed);
X@@ -2062,7 +2004,7 @@
X 					printf("Entry %d logging count reset\n",
X 					    rule.fw_number);
X 			} else
X-				show_usage("invalid rule number ``%s''", *av);
X+				errx(EX_USAGE, "invalid rule number ``%s''", *av);
X 		}
X 		if (failed != EX_OK)
X 			exit(failed);
X@@ -2078,7 +2020,7 @@
X 	int 		ch;
X 
X 	if ( ac == 1 ) {
X-		show_usage(NULL);
X+		errx(EX_USAGE, NULL);
X 	}
X 
X 	/* Initialize globals. */
X@@ -2113,12 +2055,12 @@
X 	 		do_resolv=1;
X 			break;
X 		default:
X-			show_usage(NULL);
X+			errx(EX_USAGE, NULL);
X 	}
X 
X 	ac -= optind;
X 	if (*(av+=optind)==NULL) {
X-		 show_usage("bad arguments");
X+		 errx(EX_USAGE, "bad arguments");
X 	}
X 
X         if (!strncmp(*av, "pipe", strlen(*av))) {
X@@ -2131,7 +2073,7 @@
X                 av++ ;
X         }
X 	if (!ac) {
X-		show_usage("pipe requires arguments");
X+		errx(EX_USAGE, "pipe requires arguments");
X 	}
X         /* allow argument swapping */
X         if (ac > 1 && *av[0]>='0' && *av[0]<='9') {
X@@ -2187,7 +2129,7 @@
X 		do_acct++;
X 		list(--ac,++av);
X 	} else {
X-		show_usage("bad arguments");
X+		errx(EX_USAGE, "bad arguments");
X 	}
X 	return 0;
X }
X@@ -2256,13 +2198,13 @@
X 				break;
X 
X 			default:
X-				show_usage(NULL);
X+				errx(EX_USAGE, NULL);
X 			}
X 
X 		av += optind;
X 		ac -= optind;
X 		if (ac != 1)
X-			show_usage("extraneous filename arguments");
X+			errx(EX_USAGE, "extraneous filename arguments");
X 
X 		if ((f = fopen(av[0], "r")) == NULL)
X 			err(EX_UNAVAILABLE, "fopen: %s", av[0]);
END-of-ipfw.diff
exit

>Release-Note:
>Audit-Trail:
>Unformatted:

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




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