OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: multiple specified interfaces for rarpd

From: Jonathan Gray (jsggoblin.cx)
Date: Thu Aug 26 2010 - 05:51:50 CDT


On Thu, Aug 26, 2010 at 12:34:19AM +1000, Jonathan Gray wrote:
> Currently rarpd can only listen on all or one interface, the
> following lets multiple interfaces be specified like dhcpd.

previous diff missed usage as pointed out by sthen/jmc

Index: rarpd.8
===================================================================
RCS file: /cvs/src/usr.sbin/rarpd/rarpd.8,v
retrieving revision 1.17
diff -u -p -r1.17 rarpd.8
--- rarpd.8 23 May 2008 15:23:53 -0000 1.17
+++ rarpd.8 26 Aug 2010 10:49:47 -0000
-30,11 +30,11
 .Sh SYNOPSIS
 .Nm rarpd
 .Op Fl adflt
-.Ar interface
+.Ar if0 Op Ar ... ifN
 .Sh DESCRIPTION
 .Nm
 services Reverse ARP requests on the Ethernet connected to
-.Ar interface .
+the specified interfaces.
 Upon receiving a request,
 .Nm
 maps the target hardware address to an IP address via its name, which
-58,9 +58,7 The options are as follows:
 Listen on all the Ethernets attached to the system.
 If
 .Fl a
-is omitted, an
-.Ar interface
-must be specified.
+is omitted, a list of interfaces must be specified.
 .It Fl d
 Run in debug mode, with all the output to stderr.
 This option implies the
Index: rarpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/rarpd/rarpd.c,v
retrieving revision 1.49
diff -u -p -r1.49 rarpd.c
--- rarpd.c 27 Oct 2009 23:59:54 -0000 1.49
+++ rarpd.c 26 Aug 2010 10:49:47 -0000
-134,14 +134,20 main(int argc, char *argv[])
                         /* NOTREACHED */
                 }
         }
- ifname = argv[optind++];
- if ((aflag && ifname) || (!aflag && ifname == 0))
+ argc -= optind;
+ argv += optind;
+
+ if ((aflag && argc > 0) || (!aflag && argc == 0))
                 usage();
 
         if (aflag)
                 init_all();
         else
- init_one(ifname);
+ while (argc > 0) {
+ init_one(argv[0]);
+ argc--;
+ argv++;
+ }
 
         if ((!fflag) && (!dflag)) {
                 pid = fork();
-247,7 +253,7 init_all(void)
 void
 usage(void)
 {
- (void) fprintf(stderr, "usage: rarpd [-adflt] interface\n");
+ (void) fprintf(stderr, "usage: rarpd [-adflt] if0 [... ifN]\n");
         exit(1);
 }