From owner-freebsd-bugs Tue Dec 3 0:50: 7 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 53AD237B404 for ; Tue, 3 Dec 2002 00:50:04 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 77DA543EC2 for ; Tue, 3 Dec 2002 00:50:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gB38o3x3083283 for ; Tue, 3 Dec 2002 00:50:03 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gB38o3SP083282; Tue, 3 Dec 2002 00:50:03 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9654B37B401 for ; Tue, 3 Dec 2002 00:45:10 -0800 (PST) Received: from gw2.svzserv.kemerovo.su (gw2.svzserv.kemerovo.su [213.184.65.69]) by mx1.FreeBSD.org (Postfix) with ESMTP id CEBC943E9C for ; Tue, 3 Dec 2002 00:45:06 -0800 (PST) (envelope-from sa@gw2.svzserv.kemerovo.su) Received: from gw2.svzserv.kemerovo.su (localhost [127.0.0.1]) by gw2.svzserv.kemerovo.su (8.12.6/8.12.6) with ESMTP id gB38j00C051333 for ; Tue, 3 Dec 2002 15:45:01 +0700 (KRAT) (envelope-from sa@gw2.svzserv.kemerovo.su) Received: (from root@localhost) by gw2.svzserv.kemerovo.su (8.12.6/8.12.6/Submit) id gB38isrO051312; Tue, 3 Dec 2002 15:44:54 +0700 (KRAT) Message-Id: <200212030844.gB38isrO051312@gw2.svzserv.kemerovo.su> Date: Tue, 3 Dec 2002 15:44:54 +0700 (KRAT) From: System Administrator Reply-To: System Administrator To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/45958: [PATCH] extend arp -f syntax Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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 >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 #include #include +#include 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