debian/0000755000000000000000000000000012163234031007161 5ustar debian/NEWS0000644000000000000000000000121311673467034007675 0ustar rarpd (0.981107-8) unstable; urgency=low This package has undergone a long due revision. A new init script has been crafted, and a setup file in `/etc/default/rarpd' is now being sourced. In contains only remarks when shipped in the package. The default setting is still `-e -v'. In addition, the source code has been modified to run in a debug mode which prints relevant information to the console, not only in the log file! The manual page has been updated to actually tell the capabilities of this daemon, including a SIGHUP response. -- Mats Erik Andersson Sun, 18 Dec 2011 23:43:41 +0100 debian/init.d0000644000000000000000000000313712163231203010273 0ustar #!/bin/sh ### BEGIN INIT INFO # Provides: rarpd # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: RARP lookup daemon # Description: Rarpd is a deamon allowing network devices # to be assigned an IP address bases on their # Ethernet MAC address alone. The service # implements the RARP protocol standard. ### END INIT INFO DESC="RARP lookup daemon" NAME="rarpd" DAEMON="/usr/sbin/rarpd" SCRIPT="/etc/init.d/$NAME" PATH=/sbin:/bin:/usr/sbin:/usr/bin # Default options OPTS="-e -v" # Halt silently when rarpd is gone. test -x $DAEMON || exit 0 # Read configuration file if it all present. [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Define all LSB log_* functions. . /lib/lsb/init-functions case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" start-stop-daemon --start --quiet --exec $DAEMON -- $OPTS case "$?" in 0) log_end_msg 0 ;; 1) log_progress_msg "already up and running" log_end_msg 0 ;; *) log_end_msg 1 ;; esac ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" start-stop-daemon --stop --quiet --exec $DAEMON case "$?" in 0) log_end_msg 0 ;; 1) log_progress_msg "not running" log_end_msg 0 ;; *) log_end_msg 1 ;; esac ;; restart|force-reload) log_action_msg "Restarting $DESC: $NAME" $0 stop sleep 1 $0 start ;; status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; *) echo "Usage: $SCRIPT {start|stop|restart|force-reload|status}" >&2 exit 3 ;; esac exit 0 debian/control0000644000000000000000000000111712150141337010566 0ustar Source: rarpd Section: net Priority: extra Maintainer: Mats Erik Andersson Standards-Version: 3.9.4 Build-Depends: debhelper (>= 8) Package: rarpd Architecture: linux-any Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.0-6) Description: Reverse Address Resolution Protocol daemon RARP is a protocol which allows individual devices on a network to get their IP addresses assigned based on their MAC addresses. . You have use of this daemon only if you have on your local network machines like diskless Sun boxes, or other netbooting devices. debian/copyright0000644000000000000000000000166111672113241011123 0ustar This package was debianized by Marco d'Itri on Fri, 11 Aug 2000 16:10:14 +0200. It was downloaded from rawhide.redhat.com. Upstream Authors: Alexey Kuznetsov and Jakub Jelinek. Files: * debian/patches/001_manual_page.diff Copyright: 1998, Alexey Kutznetsov 1988, Jakub Jelinek, License: GPL-2 Files: debian/ Copyright: 2000, Marco d'Itri 2001-2006, Junichi Uekawa 2011, Mats Erik Andersson License: GPL-2 License: GPL-2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . On a Debian system, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-2'. debian/changelog0000644000000000000000000000766512163233611011054 0ustar rarpd (0.981107-9) unstable; urgency=low * debian/control: Standards 3.9.4, no changes were needed. * debian/init.d: No need to source '/lib/init/vars.sh'. * debian/rules: Add CPPFLAGS for fortified hardening. * Install upstream's only descriptive file README. + debian/rarpd.docs: New file. * Repair non-verbose logging messages. + debian/patches/015_notsock_and_debugging.diff: Updated. * Activate a functional option '-A'. (Closes: #710403) + debian/patches/017_respond_to_arp.diff: New file. * Improve the manual page on the subject above. + debian/patches/020_manual_page.diff: New file. * [lintian] Missing homepage and changelog. + debian/rarpd.lintian-overrides: New file. -- Mats Erik Andersson Fri, 28 Jun 2013 09:11:44 +0200 rarpd (0.981107-8) unstable; urgency=low * New maintainer. (Closes: #520268) * Standards-Version: 3.9.2. + debian/init.d: Modified and expanded with LSB functions. + Build depends on lsb-base. + debian/rarpd.default: New file. * Compatibility 8, build depends on debhelper (>= 8). * Migrate to source format "3.0 (quilt)". + Collect historic changes made on original source: + debian/patches/001_from_0.981107_4.diff: New file. + debian/patches/001_manual_page.diff: New file. + debian/patches/002_from_0.981107_6.diff: New file. + debian/patches/003_from_0.981107_7.diff: New file. * Remove references to package "update-cluster". * debian/control: Reworked description. (Closes: #630612) + Marking binary as "linux-any". * debian/copyright: Slight clarification and completion. * debian/rules: Rewrite using debhelper front-end "dh". * debian/watch: New file, only comments. * debian/NEWS: New file. * Improve portability and standards: + debian/patches/010_standard_conventions.diff: New file. * Debugging and invalid socket recovery (Closes: #627907): + debian/patches/015_notsock_and_debugging.diff: New file. -- Mats Erik Andersson Mon, 19 Dec 2011 00:00:52 +0100 rarpd (0.981107-7.1) unstable; urgency=low * Non-maintainer upload to solve release goal. * Add LSB dependency header to init.d scripts (Closes: #466973). -- Petter Reinholdtsen Sun, 30 Mar 2008 12:44:48 +0200 rarpd (0.981107-7) unstable; urgency=low * Bug fix: "rarpd: missing binary-indep target in debian/rules (Policy 4.9)", thanks to Aurelien Jarno (Closes: #395739). * warning fix: use socklen_t instead of int for recvfrom parmeter. * debian/rules: update debhelper compatibility level (DH_COMPAT) to 4. * Standards-Version: 3.7.2 -- Junichi Uekawa Thu, 23 Nov 2006 14:21:01 +0900 rarpd (0.981107-6) unstable; urgency=low * Bug fix: "rarpd: Can not be removed if daemon is not running?", thanks to Christopher Huhn (Closes: #237252). * Fix warnings. -- Junichi Uekawa Fri, 12 Mar 2004 22:48:24 +0900 rarpd (0.981107-5) unstable; urgency=low * Update packaging * Check Policy 3.5.7. It's compliant * Do no longer provide /usr/doc, please use /usr/share/doc -- Junichi Uekawa Sun, 6 Oct 2002 18:46:19 +0900 rarpd (0.981107-4) unstable; urgency=low * support for update-cluster * migrate to debhelper version 3 from version 1. -- Junichi Uekawa Sun, 29 Jul 2001 02:10:35 +0900 rarpd (0.981107-3) unstable; urgency=low * new maintainer. (closes: #103705) * bumped up the standards-version to 3.5.5 and added build-depends for debhelper. I think this package only needs the standard tools to build -- Junichi Uekawa Sat, 14 Jul 2001 08:10:26 +0900 rarpd (0.981107-2) unstable; urgency=low * Fixed segfault. -- Marco d'Itri Sat, 23 Dec 2000 16:35:01 +0100 rarpd (0.981107-1) unstable; urgency=low * Initial Release. * Removed the ethernet.c file. -- Marco d'Itri Fri, 11 Aug 2000 16:19:17 +0200 debian/compat0000644000000000000000000000000211672000100010347 0ustar 8 debian/rarpd.docs0000644000000000000000000000000712150163136011143 0ustar README debian/rarpd.default0000644000000000000000000000100211672116520011636 0ustar # Settings for rarpd(8). # # This is a shell script snippet, source from init-script. # Any values assigned here will override the internal ones. # The package default options, set in init-script. # # Interpretation: verbose (-v), skip image checking (-e) # #OPTS="-e -v" # More advanced settings might use a boot directory # differing from the hardcoded default (/tftpboot), # might activate image checking, and decide to only # serve requests on a specific network adapter. # ##OPTS="-v -b /srv/tftpboot eth2" debian/watch0000644000000000000000000000014511672006263010222 0ustar #version=3 # # The location used to be at http://rawhide.redhat.com/, # but seems to be extinct now. debian/rarpd.lintian-overrides0000644000000000000000000000016712163231752013664 0ustar # Source contains no changelog. no-upstream-changelog # Legacy source archive without live homepage. no-homepage-field debian/patches/0000755000000000000000000000000012163234031010610 5ustar debian/patches/020_manual_page.diff0000644000000000000000000001066412162662336014317 0ustar Description: Describe image checks. Add to the existing manual page some clarifying text on how the daemon locates image files, as this check is one step for the daemon to decide to answer a request, or not. . Add text explaining the use of '-A' and give some background. . Expand the Files section slightly. Author: Mats Erik Andersson Forwarded: no Last-Update: 2013-06-20 --- rarpd-0.981107.debian3/rarpd.8 +++ rarpd-0.981107/rarpd.8 @@ -16,15 +16,22 @@ responds with their IP address if it finds it in the ethers database (either .I /etc/ethers -file or NIS+ lookup) and using DNS lookup if ethers database +file or NIS+ lookup) and using DNS lookup if the ethers database contains a hostname and not an IP address. +In addition, \fI/etc/hosts\fP will provide further means of pairing +an IP address to a hostname, in the standard fashion. +.PP By default .B rarpd -also checks if a bootable image with a name starting with the IP address -in hexadecimal uppercase letters is present in the TFTP boot directory -(usually -.I /tftpboot -) before it decides to respond to the RARP request. +also checks if a bootable image, of a name starting with the +IP address in hexadecimal upper-case letters, is present in +the TFTP boot directory before it decides whether to respond +to the RARP request. +The comparison involves exactly the first eight characters, +and ignores any additional character. +A file name shorter than eight characters in length is unsuccessful. +Typically, \fI192.168.0.122\fP would correspond to an image +named like \fIC0A8007A.SUN\fP. .PP The optional argument \fIinterface\fR restricts the daemon instance to access only the indicated network interface. Only a single name @@ -32,24 +39,29 @@ .SH OPTIONS .TP .B \-a -Do not bind to the interface. +Do not bind to a single interface, but listen at all +configured interfaces. .TP .B \-A -Respond to ARP as well as RARP requests. +Respond to reverse requests received as ARP-packets, +in addition to those protocol conformant requests +transmitted as RARP-packets. +See the notes for the background. .TP .B \-v Tell the user what is going on by being verbose. .TP .B \-d -Debugging mode. Do not detach from the tty. -This also implies verbose mode. +Debugging mode. Do not detach from the tty. This also +implies verbose mode. .TP .B \-e -Skip the check for bootable image in the TFTP boot directory. If not -present, then even if the Ethernet address is present in -the ethers database but the bootable image for the resolved IP does not exist, +Skip the check for bootable images in the TFTP boot directory. +In the absence of this switch, even if the Ethernet address +is present in the ethers database, the lack of a bootable image +for the resolved IP will make .B rarpd -will not respond to the request. +refrain from responding to requests for this particular address. .TP .B \-o Accept offlink packages on the active interfaces. @@ -73,14 +85,48 @@ Renew the internal address list, which records IPv4 addresses available at each active network interface. The restriction set by the command line argument \fIinterface\fR is still in effect, if in use. +. +.SH NOTES +The protocol stipulates that Reverse Requests be broadcast as +RARP packets, using a protocol number different from that in +use by ARP packets. +However, there has been an obsolete practice of transmitting +also Reverse Requests in ARP packets, and some old clients may +still be around that adhere to that practice. +To activate support for such obsolete client hosts, +the switch \fB\-A\fP must be applied. +Observe, however, that only ARP-packaged ARPOP_RREQUEST +messages are added to the servers responsabilities with the +use of this option, and that the replies to these will be +sent as ARP-packaged ARPOP_RREPLY messages. +. .SH FILES -.I /etc/ethers, -.br -.I /etc/nsswitch.conf, -.br +.TP +.I /etc/ethers +Text data base of ethernet to host pairs. +. +.TP +.I /etc/hosts +Text lookup table of host names. +. +.TP +.I /etc/nsswitch.conf +Name resolver configuration. +. +.TP .I /tftpboot +Default boot directory. +. +.TP +.I /tftpboot/HEXADDR +Typical name of a boot image. +It is a file or a directory. +The IPv4 address is translated as eight upper-case, +hexadecimal digits in the mandatory part \fBHEXADDR\fP. +Optionally, the name may be extended with an arbitrary suffix. +. .SH SEE ALSO -ethers(5) +ethers(5), hosts(5), nsswitch.conf(5) .SH AUTHORS Alexey Kuznetsov, .br debian/patches/017_respond_to_arp.diff0000644000000000000000000000300112162654307015054 0ustar Description: Activate ARP-packaged requests. The original source correctly implements a filter for capturing reverse requests sent as ARP-packages, but the corresponding socket is never polled for incoming messages. This is caused by incorrect setting of PSIZE. Amend this. . The original source replies with an ARP-packaged response, to an ARP-packaged request. This is reasonable, so it is left intact. . Add also a marker "(ARP-packet)" to the syslog message reporting the undertaken action for this exceptional case. Author: Mats Erik Andersson Bug-Debian: http://bugs.debian.org/710403 Forwarded: no Last-Update: 2013-06-20 diff -Naurp rarpd-0.981107.debian3/rarpd.c rarpd-0.981107/rarpd.c --- rarpd-0.981107.debian3/rarpd.c +++ rarpd-0.981107/rarpd.c @@ -495,7 +495,9 @@ int serve_it(int fd) sprintf(tmpname, "if%d", sll.sll_ifindex); if (verbose) - syslog(LOG_INFO, "RARP request from %s on %s", + syslog(LOG_INFO, "RARP request%s from %s on %s", + (sll.sll_protocol == htons(ETH_P_ARP)) + ? " (ARP-packet)" : "", tmpbuf, tmpname); } @@ -668,7 +670,7 @@ int main(int argc, char **argv) pset[1].fd = socket(PF_PACKET, SOCK_DGRAM, 0); if (pset[1].fd >= 0) { load_arp_bpflet(pset[1].fd); - psize = 1; + psize++; } } @@ -681,7 +683,7 @@ int main(int argc, char **argv) if (bind(pset[1].fd, (struct sockaddr*)&sll, sizeof(sll)) < 0) { close(pset[1].fd); pset[1].fd = -1; - psize = 1; + psize--; } } if (pset[0].fd >= 0) { debian/patches/002_from_0.981107_6.diff0000644000000000000000000000151711672111500014205 0ustar Description: Silence compiler warnings. Missing header file inclusion. . Print expected network adapter name. Author: Junichi Uekawa Comment: Computed as difference between 0.981107-4 and 0.981107-6. Forwarded: no Last-Update: 2004-03-12 --- rarpd-0.981107.orig/rarpd.c +++ rarpd-0.981107/rarpd.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,7 @@ #include #include + int do_reload = 1; int debug; @@ -475,7 +477,7 @@ tmpname[IFNAMSIZ-1] = 0; } else sprintf(tmpname, "if%d", sll.sll_ifindex); - syslog(LOG_INFO, "RARP request from %s on if%d",tmpbuf,tmpname); + syslog(LOG_INFO, "RARP request from %s on %s",tmpbuf,tmpname); } /* Sanity checks */ debian/patches/003_from_0.981107_7.diff0000644000000000000000000000101011672111561014202 0ustar Description: Silence compiler warning. Use proper type for socket address length. Author: Junichi Uekawa Comment: Computed as difference between 0.981107-6 and 0.981107-7. Forwarded: no Last-Update: 2006-11-23 --- rarpd-0.981107.orig/rarpd.c +++ rarpd-0.981107/rarpd.c @@ -424,7 +424,7 @@ { unsigned char buf[1024]; struct sockaddr_ll sll; - int sll_len = sizeof(sll); + socklen_t sll_len = sizeof(sll); struct arphdr *a = (struct arphdr*)buf; struct rarp_map *rmap; unsigned char *ptr; debian/patches/series0000644000000000000000000000031212162647320012031 0ustar 001_from_0.981107_4.diff 001_manual_page.diff 002_from_0.981107_6.diff 003_from_0.981107_7.diff 010_standard_conventions.diff 015_notsock_and_debugging.diff 017_respond_to_arp.diff 020_manual_page.diff debian/patches/010_standard_conventions.diff0000644000000000000000000000663611673460576016306 0ustar Description: Conventions and portability. Alter the make file to reflect better the expected standards. . Minor improvments on the source code, including a logging message. . Select improvements to the manual page, mentioning capabilities in the existing source code, but which were not expressed in the existing manual page. Most importantly, mention the use of SIGHUP. Author: Mats Erik Andersson Forwarded: no Last-Update: 2011-12-18 diff -Naurp rarpd-0.981107.debian/Makefile rarpd-0.981107/Makefile --- rarpd-0.981107.debian/Makefile +++ rarpd-0.981107/Makefile @@ -1,11 +1,22 @@ -CC=gcc -CFLAGS=-O2 -Wall -g $(DEFINES) +CC ?= gcc +CFLAGS ?= -O2 -Wall -g $(DEFINES) OBJ=rarpd.o #ethernet.o +PREFIX ?= /usr/local +MANPREFIX ?= $(PREFIX)/share/man + all: rarpd rarpd: $(OBJ) clean: rm -f $(OBJ) rarpd + +install: + install -d $(DESTDIR)$(PREFIX)/sbin + install -m 0755 rarpd $(DESTDIR)$(PREFIX)/sbin/ + if [ -r rarpd.8 ]; then \ + install -d $(DESTDIR)$(MANPREFIX)/man8; \ + install -m 0644 rarpd.8 $(DESTDIR)$(MANPREFIX)/man8/; \ + fi diff -Naurp rarpd-0.981107.debian/rarpd.8 rarpd-0.981107/rarpd.8 --- rarpd-0.981107.debian/rarpd.8 +++ rarpd-0.981107/rarpd.8 @@ -2,7 +2,11 @@ .SH NAME rarpd \- Reverse Address Resolution Protocol (RARP) daemon .SH SYNOPSIS -.B "rarpd [-aAvde] [-b bootdir ] [ interface ]" +.B rarpd +.RB [\| \-aAvode \|] +.RB [\| \-b +.IR bootdir \|] +.RI [\| interface \|] .SH DESCRIPTION .B Rarpd is a daemon which responds to RARP requests. @@ -21,6 +25,10 @@ in hexadecimal uppercase letters is pres (usually .I /tftpboot ) before it decides to respond to the RARP request. +.PP +The optional argument \fIinterface\fR restricts the daemon instance +to access only the indicated network interface. Only a single name +is possible. .SH OPTIONS .TP .B \-a @@ -42,19 +50,28 @@ the ethers database but the bootable ima .B rarpd will not respond to the request. .TP -.B "\-b bootdir" -Use +.B \-o +Accept offlink packages on the active interfaces. +.TP +.B \-b \fIbootdir\fR +Access .I bootdir instead of the default .I /tftpboot as the TFTP boot directory for bootable image checks. .SH OBSOLETES -This +This daemon .B rarpd obsoletes kernel .B rarp daemon present in Linux kernels up to 2.2 which was controlled by the rarp(8) command. +.SH SIGNALS +.TP +.B SIGHUP +Renew the internal address list, which records IPv4 addresses available +at each active network interface. The restriction set by the command +line argument \fIinterface\fR is still in effect, if in use. .SH FILES .I /etc/ethers, .br diff -Naurp rarpd-0.981107.debian/rarpd.c rarpd-0.981107/rarpd.c --- rarpd-0.981107.debian/rarpd.c +++ rarpd-0.981107/rarpd.c @@ -33,6 +33,9 @@ #include #include +#ifndef ETH_ALEN +# define ETH_ALEN 6 /* Ethernet address length. */ +#endif int do_reload = 1; @@ -57,7 +60,7 @@ struct rarpiflink int index; int hatype; u_int8_t lladdr[ETH_ALEN]; - unsigned char name[IFNAMSIZ]; + char name[IFNAMSIZ]; struct rarpifaddr *ifa_list; } *ifl_list; @@ -82,7 +85,7 @@ struct rarp_map void usage() { - fprintf(stderr, "Usage: rarpd [ -dveaA ] [ -b tftpdir ] [ interface]\n"); + fprintf(stderr, "Usage: rarpd [ -dveaAo ] [ -b tftpdir ] [ interface]\n"); exit(1); } @@ -219,6 +222,7 @@ void load_if() void configure() { + syslog(LOG_INFO, "Building list of addresses per interface."); load_if(); load_db(); } debian/patches/015_notsock_and_debugging.diff0000644000000000000000000001400112160671370016350 0ustar Description: Debug messages and invalid sockets. Attempt at identifying invalid socket descriptors, and deactivate them after detection. This should avoid message flooding in case of ENOTSOCK. . Implement the changes needed to make debug mode useful, printing to the console, and verbosely. . The verbose mode, as introduced by the Debian package no later than rarpd_0.981107-4, was the only way to initialize TMPBUF and TMPNAME in serve_it(). Yet these two variables were used also in non-verbose mode to send a response notification using syslog(). Now we always execute the code block which initializes both variables, but we tell syslog about an incoming request only in verbose mode, and we always report about an outgoing response packet. Author: Mats Erik Andersson Bug-Debian: http://bugs.debian.org/627907 Forwarded: no Last-Update: 2013-06-20 diff -Naurp rarpd-0.981107.debian2/rarpd.8 rarpd-0.981107/rarpd.8 --- rarpd-0.981107.debian2/rarpd.8 +++ rarpd-0.981107/rarpd.8 @@ -41,7 +41,8 @@ Respond to ARP as well as RARP requests. Tell the user what is going on by being verbose. .TP .B \-d -Debugging mode. Do not detach from the tty. +Debugging mode. Do not detach from the tty. +This also implies verbose mode. .TP .B \-e Skip the check for bootable image in the TFTP boot directory. If not diff -Naurp rarpd-0.981107.debian2/rarpd.c rarpd-0.981107/rarpd.c --- rarpd-0.981107.debian2/rarpd.c +++ rarpd-0.981107/rarpd.c @@ -424,7 +424,10 @@ void arp_advise(int ifindex, u_int8_t *l close(fd); } -void serve_it(int fd) +#define SERVEIT_KNOWN 0 +#define SERVEIT_NOTSOCK 1 + +int serve_it(int fd) { unsigned char buf[1024]; struct sockaddr_ll sll; @@ -435,32 +438,41 @@ void serve_it(int fd) int n; char tmpbuf[16 * 3], tmpname[IFNAMSIZ]; + if (fd < 0) + return SERVEIT_KNOWN; + n = recvfrom(fd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr*)&sll, &sll_len); if (n<0) { if (errno != EINTR) syslog(LOG_ERR, "recvfrom: %m"); - return; + + if (errno == ENOTSOCK) { + syslog(LOG_ERR, "Warning: Removing a socket from list. Send HUP to renew list."); + return SERVEIT_NOTSOCK; + } + + return SERVEIT_KNOWN; } /* Do not accept packets for other hosts and our own ones */ if (sll.sll_pkttype != PACKET_BROADCAST && sll.sll_pkttype != PACKET_MULTICAST && sll.sll_pkttype != PACKET_HOST) - return; + return SERVEIT_KNOWN; if (ifidx && sll.sll_ifindex != ifidx) - return; + return SERVEIT_KNOWN; if (nar_op != htons(ARPOP_RREQUEST)) - return; + return SERVEIT_KNOWN; - if (verbose) { + { int i; char *ptr = tmpbuf; struct rarpiflink *ifl; @@ -481,7 +493,10 @@ void serve_it(int fd) tmpname[IFNAMSIZ-1] = 0; } else sprintf(tmpname, "if%d", sll.sll_ifindex); - syslog(LOG_INFO, "RARP request from %s on %s",tmpbuf,tmpname); + + if (verbose) + syslog(LOG_INFO, "RARP request from %s on %s", + tmpbuf, tmpname); } /* Sanity checks */ @@ -489,12 +504,12 @@ void serve_it(int fd) /* 1. IP only -> pln==4 */ if (a->ar_pln != 4) { syslog(LOG_ERR, "interesting rarp_req plen=%d", a->ar_pln); - return; + return SERVEIT_KNOWN; } /* 2. ARP protocol must be IP */ if (a->ar_pro != htons(ETH_P_IP)) { syslog(LOG_ERR, "rarp protocol is not IP %04x", ntohs(a->ar_pro)); - return; + return SERVEIT_KNOWN; } /* 3. ARP types must match */ if (htons(sll.sll_hatype) != a->ar_hrd) { @@ -505,25 +520,25 @@ void serve_it(int fd) break; default: syslog(LOG_ERR, "rarp htype mismatch"); - return; + return SERVEIT_KNOWN; } } /* 3. LL address lengths must be equal */ if (a->ar_hln != sll.sll_halen) { syslog(LOG_ERR, "rarp hlen mismatch"); - return; + return SERVEIT_KNOWN; } /* 4. Check packet length */ if (sizeof(*a) + 2*4 + 2*a->ar_hln > n) { syslog(LOG_ERR, "truncated rarp request; len=%d", n); - return; + return SERVEIT_KNOWN; } /* 5. Silly check: if this guy set different source addresses in MAC header and in ARP, he is insane */ if (memcmp(sll.sll_addr, a+1, sll.sll_halen)) { syslog(LOG_ERR, "this guy set different his lladdrs in arp and header"); - return; + return SERVEIT_KNOWN; } /* End of sanity checks */ @@ -531,7 +546,7 @@ void serve_it(int fd) rmap = rarp_lookup(sll.sll_ifindex, sll.sll_hatype, sll.sll_halen, (unsigned char*)(a+1) + sll.sll_halen + 4); if (rmap == NULL) - return; + return SERVEIT_KNOWN; /* Prepare reply. It is almost ready, we only replace ARP packet type, put our lladdr and @@ -541,9 +556,9 @@ void serve_it(int fd) a->ar_op = htons(ARPOP_RREPLY); ptr = (unsigned char*)(a+1); if (put_mylladdr(&ptr, sll.sll_ifindex, rmap->lladdr_len)) - return; + return SERVEIT_KNOWN; if (put_myipaddr(&ptr, sll.sll_ifindex, rmap->ipaddr)) - return; + return SERVEIT_KNOWN; /* It is already filled */ ptr += rmap->lladdr_len; memcpy(ptr, &rmap->ipaddr, 4); @@ -560,6 +575,8 @@ void serve_it(int fd) alarm(5); sendto(fd, buf, ptr - buf, 0, (struct sockaddr*)&sll, sizeof(sll)); alarm(0); + + return SERVEIT_KNOWN; } void catch_signal(int sig, void (*handler)(int)) @@ -603,6 +620,7 @@ int main(int argc, char **argv) case 'd': ++debug; + ++verbose; /* Activate additional messages! */ break; case 'v': @@ -709,7 +727,15 @@ int main(int argc, char **argv) setsid(); } +#ifdef LOG_PERROR + openlog("rarpd", + (debug) ? (LOG_PID | LOG_CONS | LOG_PERROR) + : (LOG_PID | LOG_CONS), + LOG_DAEMON); +#else openlog("rarpd", LOG_PID | LOG_CONS, LOG_DAEMON); +#endif /* !defined LOG_PERROR */ + catch_signal(SIGALRM, sig_alarm); catch_signal(SIGHUP, sig_hup); @@ -736,8 +762,9 @@ int main(int argc, char **argv) continue; } for (i=0; i= 0) + if (serve_it(pset[i].fd) == SERVEIT_NOTSOCK) + pset[i].fd = -1; } } } debian/patches/001_manual_page.diff0000644000000000000000000000422211672111364014302 0ustar Description: Manual page rarpd(8). The manual page rarpd(8) is missing in the source archive but exists as adocument of the same authors. Authors: Alexey Kuznetsov Jakub Jelinek Comment: Recovered from rarpd_0.981107-4. Forwarded: no Last-Update: 2000-04-07 --- rarpd-0.981107.orig/rarpd.8 +++ rarpd-0.981107/rarpd.8 @@ -0,0 +1,69 @@ +.TH RARP 8 "7 April 2000" "rarpd" "Linux Programmer's Manual" +.SH NAME +rarpd \- Reverse Address Resolution Protocol (RARP) daemon +.SH SYNOPSIS +.B "rarpd [-aAvde] [-b bootdir ] [ interface ]" +.SH DESCRIPTION +.B Rarpd +is a daemon which responds to RARP requests. +RARP is used by some machines at boot time to discover their IP address. +They provide their Ethernet address and +.B rarpd +responds with their IP address if it finds it in the ethers database +(either +.I /etc/ethers +file or NIS+ lookup) and using DNS lookup if ethers database +contains a hostname and not an IP address. +By default +.B rarpd +also checks if a bootable image with a name starting with the IP address +in hexadecimal uppercase letters is present in the TFTP boot directory +(usually +.I /tftpboot +) before it decides to respond to the RARP request. +.SH OPTIONS +.TP +.B \-a +Do not bind to the interface. +.TP +.B \-A +Respond to ARP as well as RARP requests. +.TP +.B \-v +Tell the user what is going on by being verbose. +.TP +.B \-d +Debugging mode. Do not detach from the tty. +.TP +.B \-e +Skip the check for bootable image in the TFTP boot directory. If not +present, then even if the Ethernet address is present in +the ethers database but the bootable image for the resolved IP does not exist, +.B rarpd +will not respond to the request. +.TP +.B "\-b bootdir" +Use +.I bootdir +instead of the default +.I /tftpboot +as the TFTP boot directory for bootable image checks. +.SH OBSOLETES +This +.B rarpd +obsoletes kernel +.B rarp +daemon present in Linux kernels up to 2.2 which was controlled by the +rarp(8) command. +.SH FILES +.I /etc/ethers, +.br +.I /etc/nsswitch.conf, +.br +.I /tftpboot +.SH SEE ALSO +ethers(5) +.SH AUTHORS +Alexey Kuznetsov, +.br +Jakub Jelinek, debian/patches/001_from_0.981107_4.diff0000644000000000000000000001446011672111050014203 0ustar Description: Changes present in rarpd_0.981107-4. Author: Marco d'Itri Junichi Uekawa Comment: Recovered from rarpd_0.981107-4. Forwarded: no Last-Update: 2001-07-29 --- rarpd-0.981107.orig/rarpd.c +++ rarpd-0.981107/rarpd.c @@ -7,6 +7,7 @@ * 2 of the License, or (at your option) any later version. * * Authors: Alexey Kuznetsov, + * Jakub Jelinek, */ #include @@ -26,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -39,24 +42,26 @@ int all_ifaces; int listen_arp; char *ifname; -char *tftp_dir = "/etc/tftpboot"; +const char *tftp_dir = "/tftpboot"; +/* extern int ether_ntohost(char *name, unsigned char *ea); +*/ void usage(void) __attribute__((noreturn)); -struct iflink +struct rarpiflink { - struct iflink *next; + struct rarpiflink *next; int index; int hatype; - unsigned char lladdr[16]; + u_int8_t lladdr[ETH_ALEN]; unsigned char name[IFNAMSIZ]; - struct ifaddr *ifa_list; + struct rarpifaddr *ifa_list; } *ifl_list; -struct ifaddr +struct rarpifaddr { - struct ifaddr *next; + struct rarpifaddr *next; __u32 prefix; __u32 mask; __u32 local; @@ -69,7 +74,7 @@ int ifindex; int arp_type; int lladdr_len; - char lladdr[16]; + u_int8_t lladdr[ETH_ALEN]; __u32 ipaddr; } *rarp_db; @@ -87,8 +92,8 @@ { int fd; struct ifreq *ifrp, *ifend; - struct iflink *ifl; - struct ifaddr *ifa; + struct rarpiflink *ifl; + struct rarpifaddr *ifa; struct ifconf ifc; struct ifreq ibuf[256]; @@ -144,7 +149,7 @@ continue; } - ifl = (struct iflink*)malloc(sizeof(*ifl)); + ifl = (struct rarpiflink*)malloc(sizeof(*ifl)); if (ifl == NULL) continue; memset(ifl, 0, sizeof(*ifl)); @@ -152,8 +157,9 @@ ifl_list = ifl; ifl->index = index; ifl->hatype = ifrp->ifr_hwaddr.sa_family; - memcpy(ifl->lladdr, ifrp->ifr_hwaddr.sa_data, 14); + memcpy(ifl->lladdr, ifrp->ifr_hwaddr.sa_data, sizeof(u_int8_t) * ETH_ALEN); strncpy(ifl->name, ifrp->ifr_name, IFNAMSIZ); + ifl->name[IFNAMSIZ-1] = 0; p = strchr(ifl->name, ':'); if (p) *p = 0; @@ -179,7 +185,7 @@ if (ifa == NULL) { if (mask == 0 || prefix == 0) continue; - ifa = (struct ifaddr*)malloc(sizeof(*ifa)); + ifa = (struct rarpifaddr*)malloc(sizeof(*ifa)); memset(ifa, 0, sizeof(*ifa)); ifa->local = addr; ifa->prefix = prefix; @@ -235,10 +241,10 @@ return dent != NULL; } -struct ifaddr *select_ipaddr(int ifindex, __u32 *sel_addr, __u32 **alist) +struct rarpifaddr *select_ipaddr(int ifindex, __u32 *sel_addr, __u32 **alist) { - struct iflink *ifl; - struct ifaddr *ifa; + struct rarpiflink *ifl; + struct rarpifaddr *ifa; int retry = 0; int i; @@ -277,7 +283,7 @@ } struct rarp_map *rarp_lookup(int ifindex, int hatype, - int halen, unsigned char *lladdr) + int halen, u_int8_t *lladdr) { struct rarp_map *r; @@ -294,7 +300,7 @@ if (r == NULL) { if (hatype == ARPHRD_ETHER && halen == 6) { - struct ifaddr *ifa; + struct rarpifaddr *ifa; struct hostent *hp; char ename[256]; static struct rarp_map emap = { @@ -304,7 +310,7 @@ 6, }; - if (ether_ntohost(ename, lladdr) != 0 || + if (ether_ntohost(ename, (struct ether_addr *)lladdr) != 0 || (hp = gethostbyname(ename)) == NULL) { if (verbose) syslog(LOG_INFO, "not found in /etc/ethers"); @@ -316,7 +322,7 @@ } ifa = select_ipaddr(ifindex, &emap.ipaddr, (__u32 **)hp->h_addr_list); if (ifa) { - memcpy(emap.lladdr, lladdr, 6); + memcpy(emap.lladdr, lladdr, sizeof(u_int8_t) * ETH_ALEN); if (only_ethers || bootable(emap.ipaddr)) return &emap; if (verbose) @@ -345,7 +351,7 @@ int put_mylladdr(unsigned char **ptr_p, int ifindex, int alen) { - struct iflink *ifl; + struct rarpiflink *ifl; for (ifl=ifl_list; ifl; ifl = ifl->next) if (ifl->index == ifindex) @@ -362,8 +368,8 @@ int put_myipaddr(unsigned char **ptr_p, int ifindex, __u32 hisipaddr) { __u32 laddr = 0; - struct iflink *ifl; - struct ifaddr *ifa; + struct rarpiflink *ifl; + struct rarpifaddr *ifa; for (ifl=ifl_list; ifl; ifl = ifl->next) if (ifl->index == ifindex) @@ -383,12 +389,12 @@ return 0; } -void arp_advise(int ifindex, unsigned char *lladdr, int lllen, __u32 ipaddr) +void arp_advise(int ifindex, u_int8_t *lladdr, int lllen, __u32 ipaddr) { int fd; struct arpreq req; struct sockaddr_in *sin; - struct iflink *ifl; + struct rarpiflink *ifl; for (ifl=ifl_list; ifl; ifl = ifl->next) if (ifl->index == ifindex) @@ -421,6 +427,7 @@ struct rarp_map *rmap; unsigned char *ptr; int n; + char tmpbuf[16 * 3], tmpname[IFNAMSIZ]; n = recvfrom(fd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr*)&sll, &sll_len); if (n<0) { @@ -449,8 +456,9 @@ if (verbose) { int i; - char tmpbuf[16*3]; char *ptr = tmpbuf; + struct rarpiflink *ifl; + for (i=0; inext) + if (ifl->index == sll.sll_ifindex) + break; + if (ifl) { + strncpy(tmpname, ifl->name, IFNAMSIZ); + tmpname[IFNAMSIZ-1] = 0; + } else + sprintf(tmpname, "if%d", sll.sll_ifindex); + syslog(LOG_INFO, "RARP request from %s on if%d",tmpbuf,tmpname); } /* Sanity checks */ @@ -526,6 +542,8 @@ ptr += rmap->lladdr_len; memcpy(ptr, &rmap->ipaddr, 4); ptr += 4; + syslog(LOG_INFO, "RARP response to %s %s on %s", tmpbuf, + inet_ntoa(*(struct in_addr *)&rmap->ipaddr), tmpname); /* Update our ARP cache. Probably, this guy will not able to make ARP (if it is broken) @@ -613,7 +631,7 @@ if (ifname) { struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); if (ioctl(pset[0].fd, SIOCGIFINDEX, &ifr)) { perror("ioctl(SIOCGIFINDEX)"); usage(); --- rarpd-0.981107.orig/Makefile +++ rarpd-0.981107/Makefile @@ -1,7 +1,7 @@ CC=gcc CFLAGS=-O2 -Wall -g $(DEFINES) -OBJ=rarpd.o ethernet.o +OBJ=rarpd.o #ethernet.o all: rarpd debian/rules0000755000000000000000000000040412150137267010250 0ustar #!/usr/bin/make -f SHELL+= -e CPPFLAGS ?= $(shell dpkg-buildflags --get CPPFLAGS) CFLAGS ?= -Wall $(shell dpkg-buildflags --get CFLAGS) LDFLAGS ?= $(shell dpkg-buildflags --get LDFLAGS) export CPPFLAGS CFLAGS LDFLAGS PREFIX = /usr export PREFIX %: dh $@ debian/source/0000755000000000000000000000000012163234031010461 5ustar debian/source/format0000644000000000000000000000001411672000100011657 0ustar 3.0 (quilt)