diff options
author | Benjamin Smee <strerror@gentoo.org> | 2005-12-07 20:47:26 +0000 |
---|---|---|
committer | Benjamin Smee <strerror@gentoo.org> | 2005-12-07 20:47:26 +0000 |
commit | c33e6e3e270843cc806ee4c7159334ed568b51be (patch) | |
tree | 572738155a8c9dda99c0a4a10f7cd9989eeae52c /net-misc/netkit-rwho | |
parent | x86 stable (diff) | |
download | gentoo-2-c33e6e3e270843cc806ee4c7159334ed568b51be.tar.gz gentoo-2-c33e6e3e270843cc806ee4c7159334ed568b51be.tar.bz2 gentoo-2-c33e6e3e270843cc806ee4c7159334ed568b51be.zip |
added new conf, initd and patch as per bug #114694 - Thanks to Philippe Troin
(Portage version: 2.0.51.22-r3)
Diffstat (limited to 'net-misc/netkit-rwho')
-rw-r--r-- | net-misc/netkit-rwho/ChangeLog | 10 | ||||
-rw-r--r-- | net-misc/netkit-rwho/Manifest | 12 | ||||
-rw-r--r-- | net-misc/netkit-rwho/files/digest-netkit-rwho-0.17-r2 | 1 | ||||
-rw-r--r-- | net-misc/netkit-rwho/files/netkit-rwho-0.17-confd | 6 | ||||
-rw-r--r-- | net-misc/netkit-rwho/files/netkit-rwho-0.17-cron | 8 | ||||
-rw-r--r-- | net-misc/netkit-rwho/files/netkit-rwho-0.17-debian.patch | 874 | ||||
-rw-r--r-- | net-misc/netkit-rwho/files/netkit-rwho-0.17-rc | 2 | ||||
-rw-r--r-- | net-misc/netkit-rwho/metadata.xml | 8 | ||||
-rw-r--r-- | net-misc/netkit-rwho/netkit-rwho-0.17-r2.ebuild | 52 |
9 files changed, 968 insertions, 5 deletions
diff --git a/net-misc/netkit-rwho/ChangeLog b/net-misc/netkit-rwho/ChangeLog index c11fbd41ec98..0c3b7719214f 100644 --- a/net-misc/netkit-rwho/ChangeLog +++ b/net-misc/netkit-rwho/ChangeLog @@ -1,6 +1,14 @@ # ChangeLog for net-misc/netkit-rwho # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/netkit-rwho/ChangeLog,v 1.9 2005/02/05 06:45:52 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-misc/netkit-rwho/ChangeLog,v 1.10 2005/12/07 20:47:26 strerror Exp $ + +*netkit-rwho-0.17-r2 (07 Dec 2005) + + 07 Dec 2005; Benjamin Smee <strerror@gentoo.org> + +files/netkit-rwho-0.17-confd, +files/netkit-rwho-0.17-cron, + +files/netkit-rwho-0.17-debian.patch, files/netkit-rwho-0.17-rc, + +metadata.xml, +netkit-rwho-0.17-r2.ebuild: + added new conf, initd and patch as per bug #114694 - Thanks to Philippe Troin *netkit-rwho-0.17-r1 (05 Feb 2005) diff --git a/net-misc/netkit-rwho/Manifest b/net-misc/netkit-rwho/Manifest index f34a4dbd2e6e..3a616f7a2808 100644 --- a/net-misc/netkit-rwho/Manifest +++ b/net-misc/netkit-rwho/Manifest @@ -1,6 +1,12 @@ -MD5 02c647322674035acab270d8fe10427c ChangeLog 1220 +MD5 1940f5b12e95bdb9e873f2ba234f2d12 netkit-rwho-0.17-r2.ebuild 1283 MD5 f613f5046419a1577a9efccb54994819 netkit-rwho-0.17-r1.ebuild 1142 -MD5 25a5144430969258d0a607505ba7e00a files/netkit-rwho-0.17-gentoo.diff 1139 -MD5 fd330d52abc6a48b8e25ab058b39c2b5 files/netkit-rwho-0.17-rc 246 +MD5 12059db9aececc410ee9f491b6b24023 ChangeLog 1564 +MD5 5355b4f79a0130d075711f0a54840239 metadata.xml 223 +MD5 e2a578a3b38f2f10cdd17c536e6ff3c1 files/netkit-rwho-0.17-debian.patch 23266 MD5 90c2da8beb52736b4e4f7973e0b16489 files/netkit-rwho-0.17-tiny-packet-dos.patch 583 +MD5 d1045fc5ab2fb6b9494fea17f0e00d04 files/netkit-rwho-0.17-rc 258 +MD5 25a5144430969258d0a607505ba7e00a files/netkit-rwho-0.17-gentoo.diff 1139 +MD5 44bd260acff9db77a7f1f9127f58dc95 files/netkit-rwho-0.17-confd 157 MD5 4817c77ec114079b62c6825805637f78 files/digest-netkit-rwho-0.17-r1 67 +MD5 4817c77ec114079b62c6825805637f78 files/digest-netkit-rwho-0.17-r2 67 +MD5 81c5d51793b8ba7a489d765509caf334 files/netkit-rwho-0.17-cron 288 diff --git a/net-misc/netkit-rwho/files/digest-netkit-rwho-0.17-r2 b/net-misc/netkit-rwho/files/digest-netkit-rwho-0.17-r2 new file mode 100644 index 000000000000..5ed5db18811d --- /dev/null +++ b/net-misc/netkit-rwho/files/digest-netkit-rwho-0.17-r2 @@ -0,0 +1 @@ +MD5 0f71620d45d472f89134ba0d74242e75 netkit-rwho-0.17.tar.gz 20610 diff --git a/net-misc/netkit-rwho/files/netkit-rwho-0.17-confd b/net-misc/netkit-rwho/files/netkit-rwho-0.17-confd new file mode 100644 index 000000000000..4b4fb193f33c --- /dev/null +++ b/net-misc/netkit-rwho/files/netkit-rwho-0.17-confd @@ -0,0 +1,6 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/netkit-rwho/files/netkit-rwho-0.17-confd,v 1.1 2005/12/07 20:47:26 strerror Exp $ +# +# rwhod arguments +RWHOD_OPTIONS="-b" diff --git a/net-misc/netkit-rwho/files/netkit-rwho-0.17-cron b/net-misc/netkit-rwho/files/netkit-rwho-0.17-cron new file mode 100644 index 000000000000..9624e8eb72ff --- /dev/null +++ b/net-misc/netkit-rwho/files/netkit-rwho-0.17-cron @@ -0,0 +1,8 @@ +#!/bin/sh +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/netkit-rwho/files/netkit-rwho-0.17-cron,v 1.1 2005/12/07 20:47:26 strerror Exp $ +# +# Clean up stale rwho entries after one month +find /var/spool/rwho -mindepth 1 -maxdepth 1 -type f ! -name .keep \ + ! -ctime -30 -print0 | xargs -r0 rm -f diff --git a/net-misc/netkit-rwho/files/netkit-rwho-0.17-debian.patch b/net-misc/netkit-rwho/files/netkit-rwho-0.17-debian.patch new file mode 100644 index 000000000000..d097b0f7ab57 --- /dev/null +++ b/net-misc/netkit-rwho/files/netkit-rwho-0.17-debian.patch @@ -0,0 +1,874 @@ +diff -ruN netkit-rwho-0.17.old/ruptime/ruptime.c netkit-rwho-0.17/ruptime/ruptime.c +--- netkit-rwho-0.17.old/ruptime/ruptime.c 1999-12-12 07:33:39.000000000 -0800 ++++ netkit-rwho-0.17/ruptime/ruptime.c 2005-12-06 21:08:35.000000000 -0800 +@@ -212,7 +212,7 @@ + static char resbuf[32]; + int days, hours, minutes; + +- if (tval < 0 || tval > 999*24*60*60) { ++ if (tval < 0) { + (void)snprintf(resbuf, sizeof(resbuf), "%s ??:??", updown); + return(resbuf); + } +@@ -220,10 +220,10 @@ + hours = minutes / 60; minutes %= 60; + days = hours / 24; hours %= 24; + if (days) +- (void)snprintf(resbuf, sizeof(resbuf), "%s %3d+%02d:%02d", ++ (void)snprintf(resbuf, sizeof(resbuf), "%s %4d+%02d:%02d", + updown, days, hours, minutes); + else +- (void)snprintf(resbuf, sizeof(resbuf), "%s %2d:%02d", ++ (void)snprintf(resbuf, sizeof(resbuf), "%s %2d:%02d", + updown, hours, minutes); + return(resbuf); + } +diff -ruN netkit-rwho-0.17.old/rwho/Makefile netkit-rwho-0.17/rwho/Makefile +--- netkit-rwho-0.17.old/rwho/Makefile 1999-12-12 10:05:05.000000000 -0800 ++++ netkit-rwho-0.17/rwho/Makefile 2005-12-06 21:08:35.000000000 -0800 +@@ -3,8 +3,6 @@ + include ../MCONFIG + include ../MRULES + +-CFLAGS += -I../include +- + rwho: rwho.o + $(CC) $(LDFLAGS) $^ $(LIBS) -o $@ + +diff -ruN netkit-rwho-0.17.old/rwhod/Makefile netkit-rwho-0.17/rwhod/Makefile +--- netkit-rwho-0.17.old/rwhod/Makefile 1999-07-31 23:00:13.000000000 -0700 ++++ netkit-rwho-0.17/rwhod/Makefile 2005-12-06 21:08:35.000000000 -0800 +@@ -3,8 +3,11 @@ + include ../MCONFIG + include ../MRULES + +-CFLAGS += -I../include +-OBJS = rwhod.o daemon.o ++ifneq ($(USE_GLIBC),1) ++CFLAGS += -D_GNU_SOURCE ++endif ++ ++OBJS = rwhod.o + + rwhod: $(OBJS) + $(CC) $(LDFLAGS) $^ $(LIBS) -o $@ +diff -ruN netkit-rwho-0.17.old/rwhod/rwhod.8 netkit-rwho-0.17/rwhod/rwhod.8 +--- netkit-rwho-0.17.old/rwhod/rwhod.8 2000-07-30 16:57:06.000000000 -0700 ++++ netkit-rwho-0.17/rwhod/rwhod.8 2005-12-06 21:08:35.000000000 -0800 +@@ -32,7 +32,10 @@ + .\" from: @(#)rwhod.8 6.5 (Berkeley) 3/16/91 + .\" $Id: netkit-rwho-0.17-debian.patch,v 1.1 2005/12/07 20:47:26 strerror Exp $ + .\" +-.Dd May 13, 1997 ++.\" Modified by Philippe Troin <phil@fifi.org>: added interface ++.\" options and forwarding. ++ ++.Dd March 10, 1999 + .Dt RWHOD 8 + .Os "Linux NetKit (0.17)" + .Sh NAME +@@ -40,7 +43,8 @@ + .Nd system status server + .Sh SYNOPSIS + .Nm rwhod +-.Op Fl bpa ++.Op Fl bpaf ++.Op -i <if>... + .Op Fl u Ar user + .Sh DESCRIPTION + .Nm Rwhod +@@ -67,22 +71,6 @@ + in the ``rwho'' service specification; see + .Xr services 5 . + .Pp +-If the +-.Fl b +-flag is supplied, only broadcast interfaces, such as ethernets, will +-be used. +-If the +-.Fl p +-flag is supplied, only point-to-point interfaces will be used. If the +-.Fl a +-flag is supplied, or no flags are supplied, all interfaces will be +-used. +-.Pp +-If the +-.Fl u +-flag is supplied, rwhod will run as the specified user instead of as +-root. +-.Pp + The messages sent and received, are of the form: + .Bd -literal -offset indent + struct outmp { +@@ -145,16 +133,78 @@ + .Nm Rwhod + recomputes the system boot time every 30 minutes because on + some (non-Linux) systems it is not a totally reliable process. ++.Sh FLAGS ++If the ++.Fl b ++flag is supplied, only broadcast interfaces, such as ethernets, will ++be used. ++If the ++.Fl p ++flag is supplied, only point-to-point interfaces will be used. If the ++.Fl a ++flag is supplied, or no flags are supplied, all interfaces will be ++used. ++.Pp ++Alternately, you may specify interfaces by name by providing one or ++more ++.Fl i ++options followed by the interface name. ++.Pp ++If the ++.Fl u ++flag is supplied, rwhod will run as the specified user instead of as ++root. ++.Pp ++.Nm Rwhod ++can also forward packets between interfaces if started with ++.Fl f. ++Please read the ++.Xr CAVEATS ++section before enabling ++.Xr rwhod ++forwarding. ++.Sh CAVEATS ++While ++.Xr rwhod ++listens on any interface present on the host, it will only send (or ++forward) to the interfaces determined by the ++.Fl a b p i ++flags. ++.Pp ++When operating in forwarding mode (with ++.Fl f ++), ++.Xr rwhod ++forwards all correct rwhod packets received on an interface to all the ++other interfaces. You can create a broadcast storm if there is a ++loop in your network and all the routers in the loop run in forwarding ++mode. To prevent this from happenning, ++.Xr rwhod ++will shut down forwarding (and log the event to the syslog) if more ++than one ++.Xr rwhod ++packet is forwarded per second on average over the last three ++minutes. If this happens, you must break the loop of forwarding routers. + .Sh SEE ALSO + .Xr rwho 1 , + .Xr ruptime 1 + .Sh BUGS +-There should be a way to relay status information between networks. ++Some kind of proxying feature might be useful if your router doesn't ++run ++.Xr rwhod. ++.Pp + People often interpret the server dying +-or network communtication failures ++or network communication failures + as a machine going down. ++.Pp ++.Xr Rwhod ++doesn't refresh its interface list, which might be useful when using ++.Fl a b p. + .Sh HISTORY + The + .Nm + command appeared in + .Bx 4.2 . ++.Pp ++Philippe Troin <phil@fifi.org> implemented forwarding and interface ++selection flags. +diff -ruN netkit-rwho-0.17.old/rwhod/rwhod.c netkit-rwho-0.17/rwhod/rwhod.c +--- netkit-rwho-0.17.old/rwhod/rwhod.c 2005-12-06 21:08:06.000000000 -0800 ++++ netkit-rwho-0.17/rwhod/rwhod.c 2005-12-06 21:12:57.000000000 -0800 +@@ -29,6 +29,10 @@ + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. ++ ++ * Modified by Philippe Troin <phil@fifi.org> (added options & implemented ++ * them. ++ + */ + + char copyright[] = +@@ -47,6 +51,7 @@ + #include <signal.h> + #include <sys/ioctl.h> + #include <sys/file.h> ++#include <sys/types.h> + + #include <net/if.h> + #include <netinet/in.h> +@@ -71,10 +76,10 @@ + #include <grp.h> + #include <time.h> + +-#include "daemon.h" +- + #include "../version.h" + ++typedef struct sockaddr_in SA; ++ + #define ENDIAN LITTLE_ENDIAN + + /* +@@ -98,27 +103,44 @@ + static int verify(const char *name); + int getloadavg(double ptr[3], int n); + ++ ++/* This is the list of interface we want to listen on */ ++struct wanted_neigh { ++ struct wanted_neigh *w_next; ++ char *w_ifname; ++ enum { W_USED_NOT, W_USED_ONCE, W_USED_MULTI } w_used; ++}; ++ + /* + * We communicate with each neighbor in + * a list constructed at the time we're + * started up. Neighbors are currently + * directly connected via a hardware interface. + */ +-struct neighbor { ++struct neighbor { + struct neighbor *n_next; + char *n_name; /* interface name */ +- char *n_addr; /* who to send to */ ++ SA *n_myaddr; /* My address on this i/f */ ++ SA *n_mask; /* Netmask on this i/f */ ++ SA *n_dstaddr; /* who to send to */ + int n_addrlen; /* size of address */ + int n_flags; /* should forward?, interface flags */ + }; + ++static struct wanted_neigh *wanted_neigh; + static struct neighbor *neighbors; + static struct servent *sp; + static int sk; +-static int use_pointopoint = 0; +-static int use_broadcast = 0; ++static int use_pointopoint; ++static int use_broadcast; + static int need_init = 1; +-static int child_pid = 0; ++static int child_pid; ++static int use_forwarding; ++static int forwarded_packets; ++ ++/* Max number of packets to forward between each alarm() tick. ++ If this number is exceeded, then the forwarding is switched off. */ ++#define MAX_FWD_PACKETS (AL_INTERVAL) + + #define WHDRSIZE (((caddr_t) &((struct whod *) 0)->wd_we) \ + - ((caddr_t) 0)) +@@ -127,24 +149,48 @@ + static void termhandler(int); + static void sendpacket(struct whod *); + static void getboottime(struct whod *); ++static void forward(const SA *, const struct whod *, int cc); ++static void usage(void); + + int + main(int argc, char *argv[]) + { ++ struct wanted_neigh *wn; ++ int wn_dup; + struct sockaddr_in from; +- struct passwd *pw = 0; ++ struct passwd *pw; + struct stat st; + char path[64]; + char *user = NULL; + int on = 1; + int opt; ++ time_t before; + + if (getuid()) { + fprintf(stderr, "rwhod: not super user\n"); ++ } ++ openlog("rwhod", LOG_PID, LOG_DAEMON); ++ sp = getservbyname("who", "udp"); ++ if (sp == 0) { ++ fprintf(stderr, "rwhod: udp/who: unknown service\n"); ++ exit(1); ++ } ++ if ((sk = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { ++ syslog(LOG_ERR, "socket: %m"); ++ exit(1); ++ } ++ if (setsockopt(sk, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { ++ syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m"); ++ exit(1); ++ } ++ sine.sin_family = AF_INET; ++ sine.sin_port = sp->s_port; ++ if (bind(sk, (struct sockaddr *)&sine, sizeof(sine)) < 0) { ++ syslog(LOG_ERR, "bind: %m"); + exit(1); + } + +- while ((opt = getopt(argc, argv, "bpau:")) != EOF) { ++ while ((opt = getopt(argc, argv, "bpai:fu:")) != EOF) { + switch (opt) { + case 'b': + use_broadcast = 1; +@@ -156,29 +202,57 @@ + use_broadcast = 1; + use_pointopoint = 1; + break; ++ case 'f': ++ use_forwarding = 1; ++ break; ++ case 'i': ++ wn_dup = 0; ++ for (wn = wanted_neigh; wn; wn = wn->w_next) { ++ if (strcmp(wn->w_ifname, optarg)== 0) { ++ wn_dup = 1; ++ break; ++ } ++ } ++ if (wn_dup) { ++ fprintf(stderr, "rwhod: warning: " ++ "duplicate interface %s in arguments\n", ++ optarg); ++ } else { ++ wn = malloc(sizeof(struct wanted_neigh)); ++ if (wn == NULL) { ++ fprintf(stderr, "rwhod: out of memory\n"); ++ exit(2); ++ } ++ wn->w_next = wanted_neigh; ++ wn->w_ifname = malloc(strlen(optarg)+1); ++ wn->w_used = W_USED_NOT; ++ if (wn->w_ifname == NULL) { ++ fprintf(stderr, "rwhod: out of memory\n"); ++ exit(2); ++ } ++ strcpy(wn->w_ifname, optarg); ++ wanted_neigh = wn; ++ } ++ break; + case 'u': + user = optarg; + break; + case '?': + default: +- fprintf(stderr, "usage: rwhod [-bpa] [-u user]\n"); +- exit(1); +- break; ++ usage(); + } + } + if (optind<argc) { +- fprintf(stderr, "usage: rwhod [-bpa] [-u user]\n"); +- exit(1); ++ usage(); + } +- if (!use_pointopoint && !use_broadcast) { ++ if (!use_pointopoint && !use_broadcast && !wanted_neigh) { + /* use none is nonsensical; default to all */ + use_pointopoint = 1; + use_broadcast = 1; + } +- +- sp = getservbyname("who", "udp"); +- if (sp == 0) { +- fprintf(stderr, "rwhod: udp/who: unknown service\n"); ++ if ((use_pointopoint || use_broadcast) && wanted_neigh) { ++ fprintf(stderr, "rwhod: cannot specify both -i and one of -b " ++ "-p -a\n"); + exit(1); + } + #ifndef DEBUG +@@ -190,26 +264,33 @@ + exit(1); + } + (void) signal(SIGHUP, huphandler); +- openlog("rwhod", LOG_PID, LOG_DAEMON); +- +- if ((sk = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { +- syslog(LOG_ERR, "socket: %m"); +- exit(1); +- } +- if (setsockopt(sk, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { +- syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m"); +- exit(1); +- } +- sine.sin_family = AF_INET; +- sine.sin_port = sp->s_port; +- if (bind(sk, (struct sockaddr *)&sine, sizeof(sine)) < 0) { +- syslog(LOG_ERR, "bind: %m"); +- exit(1); +- } + + (void) umask(022); + + signal(SIGTERM, termhandler); ++ ++ if (user) { ++ /* We have to drop privs in two steps--first get the ++ * account info, then drop privs after chroot */ ++ if ((pw = getpwnam(user)) == NULL) { ++ syslog(LOG_ERR, "unknown user: %s", user); ++ exit(1); ++ } ++ ++ /* Now drop privs */ ++ if (pw->pw_uid) { ++ if (setgroups(1, &pw->pw_gid) < 0 ++ || setgid(pw->pw_gid) < 0 ++ || setuid(pw->pw_uid) < 0) { ++ syslog(LOG_ERR,"failed to drop privilege: %m"); ++ exit(1); ++ } ++ } ++ } ++ ++ if (!configure(sk)) ++ exit(1); ++ + child_pid = fork(); + if (child_pid < 0) { + syslog(LOG_ERR, "fork: %m"); +@@ -220,35 +301,15 @@ + exit(0); + } + +- /* We have to drop privs in two steps--first get the +- * account info, then drop privs after chroot */ +- if (user && (pw = getpwnam(user)) == NULL) { +- syslog(LOG_ERR, "unknown user: %s", user); +- exit(1); +- } +- +- /* Chroot to the spool directory +- * (note this is already our $cwd) */ +- if (chroot(_PATH_RWHODIR) < 0) { +- syslog(LOG_ERR, "chroot(%s): %m", _PATH_RWHODIR); +- kill(child_pid, SIGTERM); +- exit(1); +- } +- +- /* Now drop privs */ +- if (pw) { +- if (setgroups(1, &pw->pw_gid) < 0 +- || setgid(pw->pw_gid) < 0 +- || setuid(pw->pw_uid) < 0) { +- syslog(LOG_ERR, "failed to drop privilege: %m"); +- exit(1); +- } +- } +- ++ before = 0; + for (;;) { + struct whod wd; + int cc, whod; ++#ifdef __GLIBC__ ++ socklen_t len = sizeof(from); ++#else + size_t len = sizeof(from); ++#endif + + memset(&wd, 0, sizeof(wd)); + cc = recvfrom(sk, (char *)&wd, sizeof(struct whod), 0, +@@ -262,6 +323,12 @@ + syslog(LOG_WARNING, "packet too small"); + continue; + } ++ if (cc < WHDRSIZE) { ++ syslog(LOG_WARNING, "packet too small"); ++ continue; ++ } ++ if (cc < WHDRSIZE) ++ continue; + if (from.sin_port != sp->s_port) { + syslog(LOG_WARNING, "%d: bad from port", + ntohs(from.sin_port)); +@@ -271,14 +338,24 @@ + continue; + if (wd.wd_type != WHODTYPE_STATUS) + continue; ++ ++ if (use_forwarding) { ++ time_t now = time(NULL); ++ if ((uintmax_t) (now - before) >= AL_INTERVAL) { ++ before = now; ++ forwarded_packets = 0; ++ } ++ forward(&from, &wd, cc); ++ } ++ + /* + * Ensure null termination of the name within the packet. + * Otherwise we might overflow or read past the end. + */ + wd.wd_hostname[sizeof(wd.wd_hostname)-1] = 0; + if (!verify(wd.wd_hostname)) { +- syslog(LOG_WARNING, "malformed host name from %x", +- from.sin_addr.s_addr); ++ syslog(LOG_WARNING, "malformed host name from %s", ++ inet_ntoa(from.sin_addr)); + continue; + } + snprintf(path, sizeof(path), "whod.%s", wd.wd_hostname); +@@ -350,9 +427,6 @@ + size_t mynamelen; + struct whod mywd; + +- if (!configure(sk)) +- exit(1); +- + /* + * Establish host name as returned by system. + */ +@@ -362,7 +436,7 @@ + } + if ((cp = index(myname, '.')) != NULL) + *cp = '\0'; +- mynamelen = strlen(myname); ++ mynamelen = strlen(myname) + 1; + if (mynamelen > sizeof(mywd.wd_hostname)) + mynamelen = sizeof(mywd.wd_hostname) - 1; + strncpy(mywd.wd_hostname, myname, mynamelen); +@@ -453,7 +527,9 @@ + } + we = wd->wd_we; + for (i = 0; i < nutmps; i++) { +- if (stat(we->we_utmp.out_line, &stb) >= 0) ++ const char *p = we->we_utmp.out_line; ++ ++ if (!strchr(p, ':') && stat(p, &stb) >= 0) + we->we_idle = htonl(now - stb.st_atime); + we++; + } +@@ -465,10 +541,10 @@ + wd->wd_vers = WHODVERSION; + wd->wd_type = WHODTYPE_STATUS; + for (np = neighbors; np != NULL; np = np->n_next) { +- if (sendto(sk, (char *)wd, cc, 0, +- (struct sockaddr *) np->n_addr, np->n_addrlen) < 0) ++ if (sendto(sk, wd, cc, 0, ++ (struct sockaddr *) np->n_dstaddr, np->n_addrlen) < 0) + syslog(LOG_ERR, "sendto(%s): %m", +- inet_ntoa(((struct sockaddr_in *)np->n_addr)->sin_addr)); ++ inet_ntoa(np->n_dstaddr->sin_addr)); + } + + if (nutmps && chdir(_PATH_RWHODIR)) { +@@ -477,6 +553,7 @@ + } + } + ++#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) + /* + * Taken from: + * +@@ -523,6 +600,7 @@ + fclose(fp); + return 0; + } ++#endif /* __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) */ + + + void +@@ -571,7 +649,7 @@ + exit(1); + } + (void) lseek(kmemf, (long)nl[NL_BOOTTIME].n_value, L_SET); +- (void) read(kmemf, (char *)&wd->wd_boottime, ++ (void) read(kmemf, &wd->wd_boottime, + sizeof (wd->wd_boottime)); + wd->wd_boottime = htonl(wd->wd_boottime); + #endif +@@ -589,10 +667,11 @@ + struct ifreq ifreq, *ifr; + struct sockaddr_in *sn; + register struct neighbor *np; ++ struct wanted_neigh *wn; + + ifc.ifc_len = sizeof (buf); + ifc.ifc_buf = buf; +- if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { ++ if (ioctl(s, SIOCGIFCONF, &ifc) < 0) { + syslog(LOG_ERR, "ioctl (get interface configuration)"); + return (0); + } +@@ -605,7 +684,11 @@ + #endif + cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */ + for (cp = buf; cp < cplim; ++#ifdef linux ++ cp += sizeof(struct ifreq)) { ++#else + cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) { ++#endif + ifr = (struct ifreq *)cp; + for (np = neighbors; np != NULL; np = np->n_next) + if (np->n_name && +@@ -619,63 +702,170 @@ + continue; + np->n_name = malloc(strlen(ifr->ifr_name) + 1); + if (np->n_name == NULL) { +- free((char *)np); ++ free(np); + continue; + } + strcpy(np->n_name, ifr->ifr_name); + np->n_addrlen = sizeof (ifr->ifr_addr); +- np->n_addr = malloc(np->n_addrlen); +- if (np->n_addr == NULL) { ++ ++ np->n_dstaddr = malloc(np->n_addrlen); ++ if (np->n_dstaddr == NULL) { ++ free(np->n_name); ++ free(np); ++ continue; ++ } ++ bzero(np->n_dstaddr, np->n_addrlen); ++ ++ np->n_myaddr = malloc(np->n_addrlen); ++ if (np->n_myaddr == NULL) { ++ free(np->n_dstaddr); + free(np->n_name); +- free((char *)np); ++ free(np); + continue; + } +- bcopy((char *)&ifr->ifr_addr, np->n_addr, np->n_addrlen); +- if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { ++ bzero(np->n_myaddr, np->n_addrlen); ++ ++ np->n_mask = malloc(np->n_addrlen); ++ if (np->n_mask == NULL) { ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); ++ free(np); ++ continue; ++ } ++ bzero(np->n_mask, np->n_addrlen); ++ ++ /* Initialize both my address and destination address by ++ the interface address. The destination address will be ++ overwritten when the interface has IFF_BROADCAST or ++ IFF_POINTOPOINT. */ ++ bcopy(&ifr->ifr_addr, np->n_dstaddr, np->n_addrlen); ++ bcopy(&ifr->ifr_addr, np->n_myaddr, np->n_addrlen); ++ ++ if (ioctl(s, SIOCGIFFLAGS, &ifreq) < 0) { + syslog(LOG_ERR, "ioctl (get interface flags)"); +- free((char *)np); ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); ++ free(np); + continue; + } + if ((ifreq.ifr_flags & IFF_UP) == 0 || +- (ifreq.ifr_flags & (IFF_BROADCAST|IFF_POINTOPOINT)) == 0) { +- free((char *)np); ++ (ifreq.ifr_flags & (IFF_BROADCAST|IFF_POINTOPOINT)) == 0 || ++ (ifreq.ifr_flags & IFF_LOOPBACK) != 0) { ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); ++ free(np); + continue; + } ++ if (wanted_neigh) { ++ int found = 0; ++ for (wn = wanted_neigh; wn; wn = wn->w_next) ++ if (strcmp(wn->w_ifname, ifreq.ifr_name)==0) { ++ found = 1; ++ break; ++ } ++ if (!found) { ++ free(np->n_mask); ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); ++ free(np); ++ continue; ++ } ++ switch (wn->w_used) { ++ case W_USED_NOT: ++ wn->w_used = W_USED_ONCE; ++ break; ++ case W_USED_ONCE: ++ syslog(LOG_ERR, ++ "specified interface %s more than once", ++ wn->w_ifname); ++ wn->w_used = W_USED_MULTI; ++ break; ++ case W_USED_MULTI: ++ /* oh well... don't tell again... */ ++ break; ++ default: ++ syslog(LOG_CRIT, "w_used=%d on %s", ++ wn->w_used, wn->w_ifname); ++ abort(); ++ } ++ } + np->n_flags = ifreq.ifr_flags; + if (np->n_flags & IFF_POINTOPOINT) { +- if (ioctl(s, SIOCGIFDSTADDR, (char *)&ifreq) < 0) { ++ if (ioctl(s, SIOCGIFDSTADDR, &ifreq) < 0) { + syslog(LOG_ERR, "ioctl (get dstaddr)"); ++ free(np->n_mask); ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); + free(np); + continue; + } +- if (!use_pointopoint) { ++ if (!wanted_neigh && !use_pointopoint) { ++ free(np->n_mask); ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); + free(np); + continue; + } + /* we assume addresses are all the same size */ +- bcopy((char *)&ifreq.ifr_dstaddr, +- np->n_addr, np->n_addrlen); ++ bcopy(&ifreq.ifr_dstaddr, np->n_dstaddr, np->n_addrlen); + } + if (np->n_flags & IFF_BROADCAST) { +- if (ioctl(s, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { ++ if (ioctl(s, SIOCGIFBRDADDR, &ifreq) < 0) { + syslog(LOG_ERR, "ioctl (get broadaddr)"); ++ free(np->n_mask); ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); + free(np); + continue; + } +- if (!use_broadcast) { ++ if (!wanted_neigh && !use_broadcast) { ++ free(np->n_mask); ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); + free(np); + continue; + } + /* we assume addresses are all the same size */ +- bcopy((char *)&ifreq.ifr_broadaddr, +- np->n_addr, np->n_addrlen); ++ bcopy(&ifreq.ifr_broadaddr, np->n_dstaddr, np->n_addrlen); ++ ++ /* Get netmask */ ++ if (ioctl(s, SIOCGIFNETMASK, &ifreq) < 0) { ++ syslog(LOG_ERR, "ioctl (get netmask)"); ++ free(np->n_mask); ++ free(np->n_myaddr); ++ free(np->n_dstaddr); ++ free(np->n_name); ++ free(np); ++ continue; ++ } ++ bcopy((char*)&ifreq.ifr_netmask, ++ np->n_mask, np->n_addrlen); + } + /* gag, wish we could get rid of Internet dependencies */ +- sn = (struct sockaddr_in *)np->n_addr; ++ sn = (SA *)np->n_dstaddr; + sn->sin_port = sp->s_port; + np->n_next = neighbors; + neighbors = np; + } ++ ++ /* Check for unfound i/f */ ++ for (wn = wanted_neigh; wn; wn = wn->w_next) ++ if (wn->w_used == W_USED_NOT) ++ syslog(LOG_WARNING, "didn't find interface %s", ++ wn->w_ifname); ++ ++ /* Dump out used i/f */ ++ for (np = neighbors; np; np = np->n_next) ++ syslog(LOG_INFO, "sending on interface %s", np->n_name); ++ + return (1); + } + +@@ -697,7 +887,7 @@ + { + register struct whod *w = (struct whod *)buf; + register struct whoent *we; +- struct sockaddr_in *sn = (struct sockaddr_in *)to; ++ struct sockaddr_in *sn = (SA *)to; + char *interval(); + + printf("sendto %x.%d\n", ntohl(sn->sin_addr.s_addr), ntohs(sn->sin_port)); +@@ -751,3 +941,63 @@ + return (resbuf); + } + #endif ++ ++/* Eventually forward the packet */ ++static void ++forward(const SA *from, const struct whod *wd, int cc) ++{ ++ struct neighbor *np; ++ int looped_back = 0; ++ ++ /* Scan to see if the packet was sent by us */ ++ for (np = neighbors; np != NULL; np = np->n_next) ++ if (from->sin_addr.s_addr == ++ np->n_myaddr->sin_addr.s_addr) { ++ looped_back = 1; ++ break; ++ } ++ ++ if (!looped_back) { ++ sigset_t saved_set; ++ sigset_t mask_set; ++ ++ sigemptyset(&mask_set); ++ sigaddset(&mask_set, SIGALRM); ++ sigprocmask(SIG_BLOCK, &mask_set, &saved_set); ++ ++ if (++forwarded_packets > MAX_FWD_PACKETS) { ++ syslog(LOG_ERR, "too many forward requests, " ++ "disabling forwarding"); ++ use_forwarding = 0; ++ } ++ ++ sigprocmask(SIG_SETMASK, &saved_set, NULL); ++ ++ /* Re-broadcast packet on all interfaces... */ ++ for (np = neighbors; np != NULL; np = np->n_next) { ++ /* .. but do not rebroadcast on the incoming interface */ ++ if (((np->n_flags & IFF_BROADCAST) && ++ (from->sin_addr.s_addr & ++ np->n_mask->sin_addr.s_addr) != ++ (np->n_myaddr->sin_addr.s_addr & ++ np->n_mask->sin_addr.s_addr)) || ++ ((np->n_flags & IFF_POINTOPOINT) && ++ (from->sin_addr.s_addr) != ++ np->n_dstaddr->sin_addr.s_addr)) { ++ if (sendto(sk, wd, cc, 0, ++ (struct sockaddr *)np->n_dstaddr, ++ np->n_addrlen) < 0) ++ syslog(LOG_ERR, ++ "forwarding sendto(%s): %m", ++ inet_ntoa(np->n_dstaddr->sin_addr)); ++ } ++ } ++ } ++} ++ ++static void ++usage() ++{ ++ fprintf(stderr, "usage: rwhod [-bpaf] [-i <ifname>] [-u user]...\n"); ++ exit(1); ++} diff --git a/net-misc/netkit-rwho/files/netkit-rwho-0.17-rc b/net-misc/netkit-rwho/files/netkit-rwho-0.17-rc index 3f6de07a80e2..18e3ffa9ce6e 100644 --- a/net-misc/netkit-rwho/files/netkit-rwho-0.17-rc +++ b/net-misc/netkit-rwho/files/netkit-rwho-0.17-rc @@ -6,7 +6,7 @@ depend() { start() { ebegin "Starting rwhod" - start-stop-daemon --start --quiet --exec /usr/sbin/rwhod -- -b + start-stop-daemon --start --quiet --exec /usr/sbin/rwhod -- $RWHOD_OPTIONS eend $? } diff --git a/net-misc/netkit-rwho/metadata.xml b/net-misc/netkit-rwho/metadata.xml new file mode 100644 index 000000000000..49f20b1c1d96 --- /dev/null +++ b/net-misc/netkit-rwho/metadata.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> +<herd>netmon</herd> +<maintainer> + <email>strerror@gentoo.org</email> +</maintainer> +</pkgmetadata> diff --git a/net-misc/netkit-rwho/netkit-rwho-0.17-r2.ebuild b/net-misc/netkit-rwho/netkit-rwho-0.17-r2.ebuild new file mode 100644 index 000000000000..3a34668cb247 --- /dev/null +++ b/net-misc/netkit-rwho/netkit-rwho-0.17-r2.ebuild @@ -0,0 +1,52 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/netkit-rwho/netkit-rwho-0.17-r2.ebuild,v 1.1 2005/12/07 20:47:26 strerror Exp $ + +inherit eutils + +DESCRIPTION="Netkit - ruptime/rwho/rwhod" +HOMEPAGE="http://www.hcs.harvard.edu/~dholland/computers/netkit.html" +SRC_URI="ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/${P}.tar.gz" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~mips ~ppc ~s390 ~sparc ~x86" +IUSE="" + +RDEPEND="virtual/libc" +DEPEND="${RDEPEND} + >=sys-apps/portage-2.0.51 + >=sys-apps/sed-4" + +src_unpack() { + unpack ${A} + cd ${S} + epatch ${FILESDIR}/${P}-tiny-packet-dos.patch + epatch ${FILESDIR}/${P}-gentoo.diff + epatch ${FILESDIR}/${P}-debian.patch +} + +src_compile() { + ./configure || die "configure failed" + sed -i \ + -e "s:-O2::" \ + -e "s:-Wpointer-arith::" \ + MCONFIG + emake || die "emake failed" +} + +src_install() { + keepdir /var/spool/rwho + + into /usr + dobin ruptime/ruptime rwho/rwho || die "dobin failed" + dosbin rwhod/rwhod || die "dosbin failed" + doman ruptime/ruptime.1 rwho/rwho.1 rwhod/rwhod.8 + dodoc README ChangeLog + + newinitd ${FILESDIR}/${P}-rc rwhod + newconfd ${FILESDIR}/${P}-confd rwhod + + exeinto /etc/cron.monthly + doexe ${FILESDIR}/${P}-cron +} |