Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Dec 2002 15:44:54 +0700 (KRAT)
From:      System Administrator <sa@gw2.svzserv.kemerovo.su>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/45958: [PATCH] extend arp -f syntax
Message-ID:  <200212030844.gB38isrO051312@gw2.svzserv.kemerovo.su>

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

>Number:         45958
>Category:       bin
>Synopsis:       [PATCH] extend arp -f syntax
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 03 00:50:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Eugene Grosbein <eugen@grosbein.pp.ru>
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
Svyaz Service JSC
>Environment:
System: FreeBSD gw2.svzserv.kemerovo.su 4.7-STABLE FreeBSD 4.7-STABLE #6: Thu Nov 21 10:54:09 KRAT 2002 sa@gw2.svzserv.kemerovo.su:/usr/obj/usr/src/sys/GW2 i386


>Description:
		arp(8) has option -f to load data from file
		but it doesn't support comments in file.
		This makes it impossible to keep $Id: $ in a file
		when configuration files are kept in CVS Repository.

>How-To-Repeat:
		N/A
>Fix:

		This patch allows use of comments starting with #
		and extending to the end of the line; it allows use
		of empty lines and lines containing whitespace only,
		those are skipped.


diff -ur src/usr.sbin/arp.orig/arp.8 src/usr.sbin/arp/arp.8
--- src/usr.sbin/arp.orig/arp.8	Tue Dec  3 15:43:07 2002
+++ src/usr.sbin/arp/arp.8	Tue Dec  3 15:39:20 2002
@@ -163,6 +163,9 @@
 .Ed
 .Pp
 with argument meanings as given above.
+.Pp
+Comments start with hash symbol (#) and extend to the end of the line.
+Empty lines and lines containing white spaces only are ignored.
 .El
 .Sh SEE ALSO
 .Xr inet 3 ,
diff -ur src/usr.sbin/arp.orig/arp.c src/usr.sbin/arp/arp.c
--- src/usr.sbin/arp.orig/arp.c	Tue Dec  3 15:43:07 2002
+++ src/usr.sbin/arp/arp.c	Tue Dec  3 15:28:08 2002
@@ -81,6 +81,7 @@
 #include <stdlib.h>
 #include <strings.h>
 #include <unistd.h>
+#include <ctype.h>
 
 void search(u_long addr, void (*action)(struct sockaddr_dl *sdl,
 	struct sockaddr_inarp *sin, struct rt_msghdr *rtm));
@@ -218,7 +219,7 @@
 {
 	FILE *fp;
 	int i, retval;
-	char line[100], arg[5][50], *args[5];
+	char line[100], arg[5][50], *args[5], *c;
 
 	if ((fp = fopen(name, "r")) == NULL)
 		errx(1, "cannot open %s", name);
@@ -229,6 +230,17 @@
 	args[4] = &arg[4][0];
 	retval = 0;
 	while(fgets(line, 100, fp) != NULL) {
+		for (i = 1, c = line; *c; c++) {
+			if (*c == '#') {
+				*c = '\0';
+				break;
+			}
+			else {
+			    if (!isspace(*c))
+				i=0;
+			}
+		}
+		if (i) continue;
 		i = sscanf(line, "%49s %49s %49s %49s %49s", arg[0], arg[1],
 		    arg[2], arg[3], arg[4]);
 		if (i < 2) {
>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?200212030844.gB38isrO051312>