From e80ee2d01d02bd1175acf42096c70a0649257581 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 1 Jul 2005 13:52:29 +0000 Subject: Fixed an issue with not dropping the broadcast route Package-Manager: portage-2.0.51.19 --- net-misc/pump/ChangeLog | 9 +- net-misc/pump/Manifest | 8 +- net-misc/pump/files/digest-pump-0.8.21-r2 | 1 - net-misc/pump/files/digest-pump-0.8.21-r3 | 1 + net-misc/pump/files/pump-0.8-gentoo.diff | 383 --------------------------- net-misc/pump/files/pump-0.8.21-gentoo.diff | 391 ++++++++++++++++++++++++++++ net-misc/pump/pump-0.8.21-r2.ebuild | 50 ---- net-misc/pump/pump-0.8.21-r3.ebuild | 50 ++++ 8 files changed, 454 insertions(+), 439 deletions(-) delete mode 100644 net-misc/pump/files/digest-pump-0.8.21-r2 create mode 100644 net-misc/pump/files/digest-pump-0.8.21-r3 delete mode 100644 net-misc/pump/files/pump-0.8-gentoo.diff create mode 100644 net-misc/pump/files/pump-0.8.21-gentoo.diff delete mode 100644 net-misc/pump/pump-0.8.21-r2.ebuild create mode 100644 net-misc/pump/pump-0.8.21-r3.ebuild (limited to 'net-misc/pump') diff --git a/net-misc/pump/ChangeLog b/net-misc/pump/ChangeLog index 1e5b39cb19fe..ae7ede0c2cf0 100644 --- a/net-misc/pump/ChangeLog +++ b/net-misc/pump/ChangeLog @@ -1,6 +1,13 @@ # ChangeLog for net-misc/pump # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/pump/ChangeLog,v 1.14 2005/07/01 09:47:18 uberlord Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-misc/pump/ChangeLog,v 1.15 2005/07/01 13:52:29 uberlord Exp $ + +*pump-0.8.21-r3 (01 Jul 2005) + + 01 Jul 2005; Roy Marples + +files/pump-0.8.21-gentoo.diff, -files/pump-0.8-gentoo.diff, + -pump-0.8.21-r2.ebuild, +pump-0.8.21-r3.ebuild: + Fixed an issue with not dropping the broadcast route *pump-0.8.21-r2 (01 Jul 2005) diff --git a/net-misc/pump/Manifest b/net-misc/pump/Manifest index 66304999d33a..d53264e91920 100644 --- a/net-misc/pump/Manifest +++ b/net-misc/pump/Manifest @@ -1,10 +1,10 @@ -MD5 131a864a2726fbe59e240a6f2792e193 ChangeLog 2790 +MD5 ed46d88d1f5e6c96f3296854e98edd71 ChangeLog 3039 MD5 94fe4b6cace933a6aaedd7fb52194eca metadata.xml 288 MD5 4c6b8d7f8184a00ee8adf70f36c63f71 pump-0.8.11-r1.ebuild 688 MD5 9b00840a5ad1b3f1a8742b0fb6699969 pump-0.8.19-r1.ebuild 815 -MD5 75d84aa584bc445f4e181b06a88a7062 pump-0.8.21-r2.ebuild 1234 +MD5 2bc874f9d1442220817a186e47e94138 pump-0.8.21-r3.ebuild 1236 MD5 7158de78d2fd79881a6b2cbf4e13803c files/digest-pump-0.8.11-r1 67 MD5 2b45c75857947cb4866c175f48304eda files/digest-pump-0.8.19-r1 67 -MD5 959a589a3f057beacdeeb5fc2477e895 files/digest-pump-0.8.21-r2 67 -MD5 70b27d3dc38f7f8e8b8b045b97c8b9af files/pump-0.8-gentoo.diff 11581 +MD5 959a589a3f057beacdeeb5fc2477e895 files/digest-pump-0.8.21-r3 67 +MD5 8da7a9a8affd0c5692b46a4ece4375cb files/pump-0.8.21-gentoo.diff 11871 MD5 dbccd88cdb05d334ef22e298091382e3 files/pump.conf 155 diff --git a/net-misc/pump/files/digest-pump-0.8.21-r2 b/net-misc/pump/files/digest-pump-0.8.21-r2 deleted file mode 100644 index 10bcdfd4bbd9..000000000000 --- a/net-misc/pump/files/digest-pump-0.8.21-r2 +++ /dev/null @@ -1 +0,0 @@ -MD5 a6925de6cd011605237934a907f8a9c4 pump_0.8.21.orig.tar.gz 79289 diff --git a/net-misc/pump/files/digest-pump-0.8.21-r3 b/net-misc/pump/files/digest-pump-0.8.21-r3 new file mode 100644 index 000000000000..10bcdfd4bbd9 --- /dev/null +++ b/net-misc/pump/files/digest-pump-0.8.21-r3 @@ -0,0 +1 @@ +MD5 a6925de6cd011605237934a907f8a9c4 pump_0.8.21.orig.tar.gz 79289 diff --git a/net-misc/pump/files/pump-0.8-gentoo.diff b/net-misc/pump/files/pump-0.8-gentoo.diff deleted file mode 100644 index bf31ebcb411b..000000000000 --- a/net-misc/pump/files/pump-0.8-gentoo.diff +++ /dev/null @@ -1,383 +0,0 @@ ---- pump.h.orig 2003-10-24 20:37:53.000000000 +0100 -+++ pump.h 2005-07-01 10:30:28.526406380 +0100 -@@ -100,13 +100,14 @@ - char * pumpDhcpRun(char * device, int flags, int lease, - char * reqHostname, struct pumpNetIntf * intf, - struct pumpOverrideInfo * override); --char * pumpSetupInterface(struct pumpNetIntf * intf); -+char * pumpSetupInterface(struct pumpNetIntf * intf, int metric); - /* setup an interface for sending a broadcast -- uses all 0's address */ - char * pumpPrepareInterface(struct pumpNetIntf * intf, int s); - char * pumpDisableInterface(char * device); -+char * pumpDownInterface(char * device); - int pumpDhcpRenew(struct pumpNetIntf * intf); - int pumpDhcpRelease(struct pumpNetIntf * intf); --int pumpSetupDefaultGateway(struct in_addr * gw); -+int pumpSetupDefaultGateway(struct pumpNetIntf * intf, int metric); - time_t pumpUptime(void); - - #define RESULT_OKAY 0 ---- pump.c.orig 2002-06-18 18:03:59.000000000 +0100 -+++ pump.c 2005-07-01 10:30:26.579634633 +0100 -@@ -69,10 +69,13 @@ - int flags; - int reqLease; /* in seconds */ - char reqHostname[200]; -+ char resolv[1024]; -+ int routeMetric; - } start; - int result; /* 0 for success */ - struct { - char device[20]; -+ int keepUp; - } stop; - struct { - char device[20]; -@@ -92,13 +95,14 @@ - - static int openControlSocket(char * configFile, struct pumpOverrideInfo * override); - --char * readSearchPath(void) { -+char * readSearchPath(char *file) { - int fd; - struct stat sb; - char * buf; - char * start; - -- fd = open("/etc/resolv.conf", O_RDONLY); -+ if (! file) return NULL; -+ fd = open(file, O_RDONLY); - if (fd < 0) return NULL; - - fstat(fd, &sb); -@@ -132,8 +136,8 @@ - return NULL; - } - --static void createResolvConf(struct pumpNetIntf * intf, char * domain, -- int isSearchPath) { -+static void createResolvConf(char * file, struct pumpNetIntf * intf, -+ char * domain, int isSearchPath) { - FILE * f; - int i; - char * chptr; -@@ -142,7 +146,7 @@ - res_close(); - - if (!domain) { -- domain = readSearchPath(); -+ domain = readSearchPath(file); - if (domain) { - chptr = alloca(strlen(domain) + 1); - strcpy(chptr, domain); -@@ -152,19 +156,21 @@ - } - } - -- f = fopen("/etc/resolv.conf", "w"); -+ f = fopen(file, "w"); - if (!f) { -- syslog(LOG_ERR, "cannot create /etc/resolv.conf: %s\n", -+ syslog(LOG_ERR, "cannot create %s: %s\n", file, - strerror(errno)); - return; - } - -+ fprintf(f, "# Generated by pump for interface %s\n", intf->device); -+ - if (domain && isSearchPath) { - fprintf(f, "search %s\n", domain); - } else if (domain && !strchr(domain, '.')) { -- fprintf(f, "search %s\n", domain); -+ fprintf(f, "domain %s\n", domain); - } else if (domain) { -- fprintf(f, "search"); -+ fprintf(f, "domain"); - chptr = domain; - do { - /* If there is a single . in the search path, write it out -@@ -240,7 +246,7 @@ - return; - } - --void setupDns(struct pumpNetIntf * intf, struct pumpOverrideInfo * override) { -+void setupDns(char *file, struct pumpNetIntf * intf, struct pumpOverrideInfo * override) { - char * hn, * dn = NULL; - struct hostent * he; - -@@ -249,7 +255,7 @@ - } - - if (override->searchPath) { -- createResolvConf(intf, override->searchPath, 1); -+ createResolvConf(file, intf, override->searchPath, 1); - return; - } - -@@ -258,7 +264,7 @@ - if (intf->set & PUMP_NETINFO_HAS_HOSTNAME) { - hn = intf->hostname; - } else { -- createResolvConf(intf, NULL, 0); -+ createResolvConf(file, intf, NULL, 0); - - he = gethostbyaddr((char *) &intf->ip, sizeof(intf->ip), - AF_INET); -@@ -278,7 +284,7 @@ - dn = intf->domain; - } - -- createResolvConf(intf, dn, 0); -+ createResolvConf(file, intf, dn, 0); - } - } - -@@ -529,16 +535,18 @@ - intf + numInterfaces, o)) { - cmd.u.result = 1; - } else { -- pumpSetupInterface(intf + numInterfaces); -+ pumpSetupInterface(intf + numInterfaces, -+ cmd.u.start.routeMetric); - i = numInterfaces; - - syslog(LOG_INFO, "configured interface %s", intf[i].device); - - if ((intf[i].set & PUMP_NETINFO_HAS_GATEWAY) && - !(o->flags & OVERRIDE_FLAG_NOGATEWAY)) -- pumpSetupDefaultGateway(&intf[i].gateway); -+ pumpSetupDefaultGateway(intf + i, -+ cmd.u.start.routeMetric); - -- setupDns(intf + i, o); -+ setupDns(cmd.u.start.resolv, intf + i, o); - setupDomain(intf + i, o); - - callScript(o->script, PUMP_SCRIPT_NEWLEASE, -@@ -570,6 +578,8 @@ - cmd.u.result = RESULT_UNKNOWNIFACE; - else { - cmd.u.result = pumpDhcpRelease(intf + i); -+ syslog(LOG_INFO, "keekUp %i", cmd.u.stop.keepUp); -+ if (! cmd.u.stop.keepUp) pumpDownInterface(intf[i].device); - callScript(o->script, PUMP_SCRIPT_DOWN, intf + i); - if (numInterfaces == 1) { - cmd.type = CMD_RESULT; -@@ -811,17 +821,24 @@ - int nogateway = 0, nobootp = 0; - struct command cmd, response; - char * configFile = "/etc/pump.conf"; -+ char * etcDir = "/etc"; -+ int routeMetric = 0, keepUp = 0; -+ char * script = ""; - struct pumpOverrideInfo * overrides; - int cont; - struct poptOption options[] = { - { "config-file", 'c', POPT_ARG_STRING, &configFile, 0, - N_("Configuration file to use instead of " - "/etc/pump.conf") }, -+ { "etc-dir", 'e', POPT_ARG_STRING, &etcDir, 0, -+ N_("Directory to store resolv.conf (normally /etc)") }, - { "hostname", 'h', POPT_ARG_STRING, &hostname, 0, - N_("Hostname to request"), N_("hostname") }, - { "interface", 'i', POPT_ARG_STRING, &device, 0, - N_("Interface to configure (normally eth0)"), - N_("iface") }, -+ { "keep-up", 'u', POPT_ARG_NONE, &keepUp, 0, -+ N_("Keep the interface up when releasing it") }, - { "kill", 'k', POPT_ARG_NONE, &killDaemon, 0, - N_("Kill daemon (and disable all interfaces)"), NULL }, - { "lease", 'l', POPT_ARG_INT, &lease_hrs, 0, -@@ -834,6 +851,10 @@ - N_("Release interface"), NULL }, - { "renew", 'R', POPT_ARG_NONE, &renew, 0, - N_("Force immediate lease renewal"), NULL }, -+ { "route-metric", 'm', POPT_ARG_INT, &routeMetric, 0, -+ N_("Metric applied to routes (normally 0)") }, -+ { "script", '\0', POPT_ARG_STRING, &script, 0, -+ N_("Script to run when on DHCP actions") }, - { "status", 's', POPT_ARG_NONE, &status, 0, - N_("Display interface status"), NULL }, - { "no-dns", 'd', POPT_ARG_NONE, &nodns, 0, -@@ -889,6 +910,8 @@ - overrides->flags |= OVERRIDE_FLAG_NOBOOTP; - if (nogateway) - overrides->flags |= OVERRIDE_FLAG_NOGATEWAY; -+ if (strlen(script)) -+ overrides->script = script; - - cont = openControlSocket(configFile, overrides); - if (cont < 0) -@@ -905,6 +928,7 @@ - } else if (release) { - cmd.type = CMD_STOPIFACE; - strcpy(cmd.u.stop.device, device); -+ cmd.u.stop.keepUp = keepUp; - } else { - cmd.type = CMD_STARTIFACE; - strcpy(cmd.u.start.device, device); -@@ -914,6 +938,8 @@ - else - cmd.u.start.reqLease = lease; - strcpy(cmd.u.start.reqHostname, hostname); -+ sprintf(cmd.u.start.resolv, "%s/resolv.conf", etcDir); -+ cmd.u.start.routeMetric = routeMetric; - } - - write(cont, &cmd, sizeof(cmd)); ---- dhcp.c.orig 2004-09-21 16:19:06.000000000 +0100 -+++ dhcp.c 2005-07-01 10:32:30.240170027 +0100 -@@ -203,43 +203,68 @@ - return err; - } - -- - char * pumpDisableInterface(char * device) { -+ struct sockaddr_in * addrp; - struct ifreq req; - int s; - -+ /* Instead of downing the interface, we erase the address -+ * This is important as other daemons such as ifplugd and/or -+ * wpa_supplicant may be using it */ -+ - s = socket(AF_INET, SOCK_DGRAM, 0); - - memset(&req,0,sizeof(req)); -+ addrp = (struct sockaddr_in *) &req.ifr_addr; -+ addrp->sin_family = AF_INET; -+ strcpy(req.ifr_name, device); -+ -+ addrp->sin_addr.s_addr = 0; -+ if (ioctl(s, SIOCSIFADDR, &req)) { -+ close(s); -+ return perrorstr("SIOCSIFADDR"); -+ } -+ -+ close(s); -+ return NULL; -+} -+ -+char * pumpDownInterface(char * device) { -+ struct ifreq req; -+ int s; -+ -+ s = socket(AF_INET, SOCK_DGRAM, 0); -+ -+ memset(&req,0,sizeof(req)); - - strcpy(req.ifr_name, device); - if (ioctl(s, SIOCGIFFLAGS, &req)) { -- close(s); -- return perrorstr("SIOCGIFFLAGS"); -+ close(s); -+ return perrorstr("SIOCGIFFLAGS"); - } - - req.ifr_flags &= ~(IFF_UP | IFF_RUNNING); - if (ioctl(s, SIOCSIFFLAGS, &req)) { -- close(s); -- return perrorstr("SIOCSIFFLAGS"); -+ close(s); -+ return perrorstr("SIOCSIFFLAGS"); - } - - close(s); -- - return NULL; - } - --char * pumpSetupInterface(struct pumpNetIntf * intf) { -+char * pumpSetupInterface(struct pumpNetIntf * intf, int metric) { - char * rc; - struct sockaddr_in * addrp; - struct ifreq req; - struct rtentry route; - int s; - -+ if ((rc = pumpDisableInterface(intf->device))) return rc; -+ - s = socket(AF_INET, SOCK_DGRAM, 0); - - memset(&req,0,sizeof(req)); -- memset(&route,0,sizeof(route)); - /* we have to have basic information to get this far */ - addrp = (struct sockaddr_in *) &req.ifr_addr; - addrp->sin_family = AF_INET; -@@ -267,29 +292,45 @@ - if (ioctl(s, SIOCSIFFLAGS, &req)) - return perrorstr("SIOCSIFFLAGS"); - -- if (!strcmp(intf->device, "lo") || oldKernel()) { -- /* add a route for this network */ -- route.rt_dev = intf->device; -- route.rt_flags = RTF_UP; -+ /* If the we're on a modern kernel and the metric we want is not zero -+ * then we don't need todo anything else */ -+ if (! oldKernel() && metric == 0) { -+ return NULL; -+ } -+ -+ /* Prepare the route */ -+ memset(&route,0,sizeof(route)); -+ route.rt_dev = intf->device; -+ route.rt_flags = RTF_UP; -+ -+ addrp->sin_family = AF_INET; -+ addrp->sin_port = 0; -+ addrp->sin_addr = intf->network; -+ memcpy(&route.rt_dst, addrp, sizeof(*addrp)); -+ addrp->sin_addr = intf->netmask; -+ memcpy(&route.rt_genmask, addrp, sizeof(*addrp)); -+ -+ /* Modern kernels automatically add a default route with a metric of zero -+ * we need to delete this route and add our own */ -+ if (! oldKernel()) { - route.rt_metric = 0; - -- addrp->sin_family = AF_INET; -- addrp->sin_port = 0; -- addrp->sin_addr = intf->network; -- memcpy(&route.rt_dst, addrp, sizeof(*addrp)); -- addrp->sin_addr = intf->netmask; -- memcpy(&route.rt_genmask, addrp, sizeof(*addrp)); -- -- if (ioctl(s, SIOCADDRT, &route)) { -- /* the route cannot already exist, as we've taken the device down */ -- return perrorstr("SIOCADDRT 1"); -+ if (ioctl(s, SIOCDELRT, &route)) { -+ return perrorstr("SIOCADDRT"); - } - } - -+ /* Now add our route */ -+ if (metric > 0) metric++; -+ route.rt_metric = metric; -+ if (ioctl(s, SIOCADDRT, &route)) { -+ return perrorstr("SIOCADDRT 1"); -+ } -+ - return NULL; - } - --int pumpSetupDefaultGateway(struct in_addr * gw) { -+int pumpSetupDefaultGateway(struct pumpNetIntf * intf, int metric) { - struct sockaddr_in addr; - struct rtentry route; - int s; -@@ -303,12 +344,12 @@ - addr.sin_addr.s_addr = INADDR_ANY; - memcpy(&route.rt_dst, &addr, sizeof(addr)); - memcpy(&route.rt_genmask, &addr, sizeof(addr)); -- addr.sin_addr = *gw; -+ addr.sin_addr = intf->gateway; - memcpy(&route.rt_gateway, &addr, sizeof(addr)); - - route.rt_flags = RTF_UP | RTF_GATEWAY; -- route.rt_metric = 0; -- route.rt_dev = NULL; -+ route.rt_metric = metric + 1; -+ route.rt_dev = intf->device; - - if (ioctl(s, SIOCADDRT, &route)) { - syslog(LOG_ERR, "failed to set default route: %s", strerror(errno)); diff --git a/net-misc/pump/files/pump-0.8.21-gentoo.diff b/net-misc/pump/files/pump-0.8.21-gentoo.diff new file mode 100644 index 000000000000..57baa885238a --- /dev/null +++ b/net-misc/pump/files/pump-0.8.21-gentoo.diff @@ -0,0 +1,391 @@ +--- pump.h.orig 2005-07-01 11:46:54.337215787 +0100 ++++ pump.h 2005-07-01 11:38:08.969331584 +0100 +@@ -100,13 +100,14 @@ + char * pumpDhcpRun(char * device, int flags, int lease, + char * reqHostname, struct pumpNetIntf * intf, + struct pumpOverrideInfo * override); +-char * pumpSetupInterface(struct pumpNetIntf * intf); ++char * pumpSetupInterface(struct pumpNetIntf * intf, int metric); + /* setup an interface for sending a broadcast -- uses all 0's address */ + char * pumpPrepareInterface(struct pumpNetIntf * intf, int s); + char * pumpDisableInterface(char * device); ++char * pumpDownInterface(char * device); + int pumpDhcpRenew(struct pumpNetIntf * intf); + int pumpDhcpRelease(struct pumpNetIntf * intf); +-int pumpSetupDefaultGateway(struct in_addr * gw); ++int pumpSetupDefaultGateway(struct pumpNetIntf * intf, int metric); + time_t pumpUptime(void); + + #define RESULT_OKAY 0 +--- pump.c.orig 2005-07-01 11:46:58.824710842 +0100 ++++ pump.c 2005-07-01 14:31:45.883753527 +0100 +@@ -69,10 +69,13 @@ + int flags; + int reqLease; /* in seconds */ + char reqHostname[200]; ++ char resolv[1024]; ++ int routeMetric; + } start; + int result; /* 0 for success */ + struct { + char device[20]; ++ int keepUp; + } stop; + struct { + char device[20]; +@@ -92,13 +95,14 @@ + + static int openControlSocket(char * configFile, struct pumpOverrideInfo * override); + +-char * readSearchPath(void) { ++char * readSearchPath(char *file) { + int fd; + struct stat sb; + char * buf; + char * start; + +- fd = open("/etc/resolv.conf", O_RDONLY); ++ if (! file) return NULL; ++ fd = open(file, O_RDONLY); + if (fd < 0) return NULL; + + fstat(fd, &sb); +@@ -132,8 +136,8 @@ + return NULL; + } + +-static void createResolvConf(struct pumpNetIntf * intf, char * domain, +- int isSearchPath) { ++static void createResolvConf(char * file, struct pumpNetIntf * intf, ++ char * domain, int isSearchPath) { + FILE * f; + int i; + char * chptr; +@@ -142,7 +146,7 @@ + res_close(); + + if (!domain) { +- domain = readSearchPath(); ++ domain = readSearchPath(file); + if (domain) { + chptr = alloca(strlen(domain) + 1); + strcpy(chptr, domain); +@@ -152,19 +156,21 @@ + } + } + +- f = fopen("/etc/resolv.conf", "w"); ++ f = fopen(file, "w"); + if (!f) { +- syslog(LOG_ERR, "cannot create /etc/resolv.conf: %s\n", ++ syslog(LOG_ERR, "cannot create %s: %s\n", file, + strerror(errno)); + return; + } + ++ fprintf(f, "# Generated by pump for interface %s\n", intf->device); ++ + if (domain && isSearchPath) { + fprintf(f, "search %s\n", domain); + } else if (domain && !strchr(domain, '.')) { +- fprintf(f, "search %s\n", domain); ++ fprintf(f, "domain %s\n", domain); + } else if (domain) { +- fprintf(f, "search"); ++ fprintf(f, "domain"); + chptr = domain; + do { + /* If there is a single . in the search path, write it out +@@ -240,7 +246,7 @@ + return; + } + +-void setupDns(struct pumpNetIntf * intf, struct pumpOverrideInfo * override) { ++void setupDns(char *file, struct pumpNetIntf * intf, struct pumpOverrideInfo * override) { + char * hn, * dn = NULL; + struct hostent * he; + +@@ -249,7 +255,7 @@ + } + + if (override->searchPath) { +- createResolvConf(intf, override->searchPath, 1); ++ createResolvConf(file, intf, override->searchPath, 1); + return; + } + +@@ -258,7 +264,7 @@ + if (intf->set & PUMP_NETINFO_HAS_HOSTNAME) { + hn = intf->hostname; + } else { +- createResolvConf(intf, NULL, 0); ++ createResolvConf(file, intf, NULL, 0); + + he = gethostbyaddr((char *) &intf->ip, sizeof(intf->ip), + AF_INET); +@@ -278,7 +284,7 @@ + dn = intf->domain; + } + +- createResolvConf(intf, dn, 0); ++ createResolvConf(file, intf, dn, 0); + } + } + +@@ -529,16 +535,18 @@ + intf + numInterfaces, o)) { + cmd.u.result = 1; + } else { +- pumpSetupInterface(intf + numInterfaces); ++ pumpSetupInterface(intf + numInterfaces, ++ cmd.u.start.routeMetric); + i = numInterfaces; + + syslog(LOG_INFO, "configured interface %s", intf[i].device); + + if ((intf[i].set & PUMP_NETINFO_HAS_GATEWAY) && + !(o->flags & OVERRIDE_FLAG_NOGATEWAY)) +- pumpSetupDefaultGateway(&intf[i].gateway); ++ pumpSetupDefaultGateway(intf + i, ++ cmd.u.start.routeMetric); + +- setupDns(intf + i, o); ++ setupDns(cmd.u.start.resolv, intf + i, o); + setupDomain(intf + i, o); + + callScript(o->script, PUMP_SCRIPT_NEWLEASE, +@@ -570,6 +578,7 @@ + cmd.u.result = RESULT_UNKNOWNIFACE; + else { + cmd.u.result = pumpDhcpRelease(intf + i); ++ if (! cmd.u.stop.keepUp) pumpDownInterface(intf[i].device); + callScript(o->script, PUMP_SCRIPT_DOWN, intf + i); + if (numInterfaces == 1) { + cmd.type = CMD_RESULT; +@@ -811,17 +820,24 @@ + int nogateway = 0, nobootp = 0; + struct command cmd, response; + char * configFile = "/etc/pump.conf"; ++ char * etcDir = "/etc"; ++ int routeMetric = 0, keepUp = 0; ++ char * script = ""; + struct pumpOverrideInfo * overrides; + int cont; + struct poptOption options[] = { + { "config-file", 'c', POPT_ARG_STRING, &configFile, 0, + N_("Configuration file to use instead of " + "/etc/pump.conf") }, ++ { "etc-dir", 'e', POPT_ARG_STRING, &etcDir, 0, ++ N_("Directory to store resolv.conf (normally /etc)") }, + { "hostname", 'h', POPT_ARG_STRING, &hostname, 0, + N_("Hostname to request"), N_("hostname") }, + { "interface", 'i', POPT_ARG_STRING, &device, 0, + N_("Interface to configure (normally eth0)"), + N_("iface") }, ++ { "keep-up", 'u', POPT_ARG_NONE, &keepUp, 0, ++ N_("Keep the interface up when releasing it") }, + { "kill", 'k', POPT_ARG_NONE, &killDaemon, 0, + N_("Kill daemon (and disable all interfaces)"), NULL }, + { "lease", 'l', POPT_ARG_INT, &lease_hrs, 0, +@@ -834,6 +850,10 @@ + N_("Release interface"), NULL }, + { "renew", 'R', POPT_ARG_NONE, &renew, 0, + N_("Force immediate lease renewal"), NULL }, ++ { "route-metric", 'm', POPT_ARG_INT, &routeMetric, 0, ++ N_("Metric applied to routes (normally 0)") }, ++ { "script", '\0', POPT_ARG_STRING, &script, 0, ++ N_("Script to run when on DHCP actions") }, + { "status", 's', POPT_ARG_NONE, &status, 0, + N_("Display interface status"), NULL }, + { "no-dns", 'd', POPT_ARG_NONE, &nodns, 0, +@@ -889,6 +909,8 @@ + overrides->flags |= OVERRIDE_FLAG_NOBOOTP; + if (nogateway) + overrides->flags |= OVERRIDE_FLAG_NOGATEWAY; ++ if (strlen(script)) ++ overrides->script = script; + + cont = openControlSocket(configFile, overrides); + if (cont < 0) +@@ -905,6 +927,7 @@ + } else if (release) { + cmd.type = CMD_STOPIFACE; + strcpy(cmd.u.stop.device, device); ++ cmd.u.stop.keepUp = keepUp; + } else { + cmd.type = CMD_STARTIFACE; + strcpy(cmd.u.start.device, device); +@@ -914,6 +937,8 @@ + else + cmd.u.start.reqLease = lease; + strcpy(cmd.u.start.reqHostname, hostname); ++ sprintf(cmd.u.start.resolv, "%s/resolv.conf", etcDir); ++ cmd.u.start.routeMetric = routeMetric; + } + + write(cont, &cmd, sizeof(cmd)); +--- dhcp.c.orig 2005-07-01 11:47:05.221991003 +0100 ++++ dhcp.c 2005-07-01 14:43:41.215170958 +0100 +@@ -203,13 +203,62 @@ + return err; + } + +- + char * pumpDisableInterface(char * device) { ++ struct sockaddr_in * addrp; + struct ifreq req; + int s; ++ struct rtentry route; ++ ++ /* Instead of downing the interface, we erase the addresses ++ * This is important as other daemons such as ifplugd and/or ++ * wpa_supplicant may be using it */ + + s = socket(AF_INET, SOCK_DGRAM, 0); +- ++ ++ memset(&req,0,sizeof(req)); ++ addrp = (struct sockaddr_in *) &req.ifr_addr; ++ addrp->sin_family = AF_INET; ++ strcpy(req.ifr_name, device); ++ ++ while(! ioctl(s, SIOCGIFADDR, &req)) { ++ addrp->sin_addr.s_addr = 0; ++ if (ioctl(s, SIOCSIFADDR, &req)) { ++ close(s); ++ return perrorstr("SIOCSIFADDR"); ++ } ++ } ++ ++ /* Delete the broadcast route that we may have added earlier */ ++ memset(&route, 0, sizeof(route)); ++ memcpy(&route.rt_gateway, addrp, sizeof(*addrp)); ++ ++ addrp->sin_family = AF_INET; ++ addrp->sin_port = 0; ++ addrp->sin_addr.s_addr = INADDR_ANY; ++ memcpy(&route.rt_dst, addrp, sizeof(*addrp)); ++ memcpy(&route.rt_genmask, addrp, sizeof(*addrp)); ++ ++ route.rt_dev = device; ++ route.rt_flags = RTF_UP; ++ route.rt_metric = 0; ++ ++ if (ioctl(s, SIOCDELRT, &route)) { ++ if (errno != EEXIST) { ++ close(s); ++ return perrorstr("SIOCADDRT 3"); ++ } ++ } ++ ++ close(s); ++ return NULL; ++} ++ ++char * pumpDownInterface(char * device) { ++ struct ifreq req; ++ int s; ++ ++ s = socket(AF_INET, SOCK_DGRAM, 0); ++ + memset(&req,0,sizeof(req)); + + strcpy(req.ifr_name, device); +@@ -229,17 +278,18 @@ + return NULL; + } + +-char * pumpSetupInterface(struct pumpNetIntf * intf) { ++char * pumpSetupInterface(struct pumpNetIntf * intf, int metric) { + char * rc; + struct sockaddr_in * addrp; + struct ifreq req; + struct rtentry route; + int s; + ++ if ((rc = pumpDisableInterface(intf->device))) return rc; ++ + s = socket(AF_INET, SOCK_DGRAM, 0); + + memset(&req,0,sizeof(req)); +- memset(&route,0,sizeof(route)); + /* we have to have basic information to get this far */ + addrp = (struct sockaddr_in *) &req.ifr_addr; + addrp->sin_family = AF_INET; +@@ -267,29 +317,45 @@ + if (ioctl(s, SIOCSIFFLAGS, &req)) + return perrorstr("SIOCSIFFLAGS"); + +- if (!strcmp(intf->device, "lo") || oldKernel()) { +- /* add a route for this network */ +- route.rt_dev = intf->device; +- route.rt_flags = RTF_UP; ++ /* If the we're on a modern kernel and the metric we want is not zero ++ * then we don't need todo anything else */ ++ if (! oldKernel() && metric == 0) { ++ return NULL; ++ } ++ ++ /* Prepare the route */ ++ memset(&route,0,sizeof(route)); ++ route.rt_dev = intf->device; ++ route.rt_flags = RTF_UP; ++ ++ addrp->sin_family = AF_INET; ++ addrp->sin_port = 0; ++ addrp->sin_addr = intf->network; ++ memcpy(&route.rt_dst, addrp, sizeof(*addrp)); ++ addrp->sin_addr = intf->netmask; ++ memcpy(&route.rt_genmask, addrp, sizeof(*addrp)); ++ ++ /* Modern kernels automatically add a default route with a metric of zero ++ * we need to delete this route and add our own */ ++ if (! oldKernel()) { + route.rt_metric = 0; + +- addrp->sin_family = AF_INET; +- addrp->sin_port = 0; +- addrp->sin_addr = intf->network; +- memcpy(&route.rt_dst, addrp, sizeof(*addrp)); +- addrp->sin_addr = intf->netmask; +- memcpy(&route.rt_genmask, addrp, sizeof(*addrp)); +- +- if (ioctl(s, SIOCADDRT, &route)) { +- /* the route cannot already exist, as we've taken the device down */ +- return perrorstr("SIOCADDRT 1"); ++ if (ioctl(s, SIOCDELRT, &route)) { ++ return perrorstr("SIOCADDRT"); + } + } + ++ /* Now add our route */ ++ if (metric > 0) metric++; ++ route.rt_metric = metric; ++ if (ioctl(s, SIOCADDRT, &route)) { ++ return perrorstr("SIOCADDRT 1"); ++ } ++ + return NULL; + } + +-int pumpSetupDefaultGateway(struct in_addr * gw) { ++int pumpSetupDefaultGateway(struct pumpNetIntf * intf, int metric) { + struct sockaddr_in addr; + struct rtentry route; + int s; +@@ -303,12 +369,12 @@ + addr.sin_addr.s_addr = INADDR_ANY; + memcpy(&route.rt_dst, &addr, sizeof(addr)); + memcpy(&route.rt_genmask, &addr, sizeof(addr)); +- addr.sin_addr = *gw; ++ addr.sin_addr = intf->gateway; + memcpy(&route.rt_gateway, &addr, sizeof(addr)); + + route.rt_flags = RTF_UP | RTF_GATEWAY; +- route.rt_metric = 0; +- route.rt_dev = NULL; ++ route.rt_metric = metric + 1; ++ route.rt_dev = intf->device; + + if (ioctl(s, SIOCADDRT, &route)) { + syslog(LOG_ERR, "failed to set default route: %s", strerror(errno)); diff --git a/net-misc/pump/pump-0.8.21-r2.ebuild b/net-misc/pump/pump-0.8.21-r2.ebuild deleted file mode 100644 index 415868e6b249..000000000000 --- a/net-misc/pump/pump-0.8.21-r2.ebuild +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 1999-2005 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/pump/pump-0.8.21-r2.ebuild,v 1.1 2005/07/01 09:47:18 uberlord Exp $ - -inherit eutils - -DESCRIPTION="This is the DHCP/BOOTP client written by RedHat" -HOMEPAGE="http://ftp.debian.org/debian/pool/main/p/pump/" -SRC_URI="mirror://debian/pool/main/p/${PN}/${PN}_${PV}.orig.tar.gz" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="~amd64 ~arm ~hppa ~ia64 ~ppc ~sparc ~x86" -IUSE="" - -DEPEND=">=dev-libs/popt-1.5" - -PROVIDE="virtual/dhcpc" - -src_unpack() { - unpack "${A}" - cd "${S}" - - # Enable the -e (--etc-dir) option to specify where to make - # resolv.conf - default /etc - # Enable the -m (--route-metric) option to specify the default - # metric applied to routes - # Enable the --script option to specify a script to run on DHCP actions - # Enable the --keep-up option to keep interfaces up when we release - epatch "${FILESDIR}/pump-0.8-gentoo.diff" -} - -src_compile() { - make pump RPM_OPT_FLAGS="${CFLAGS}" || die -} - -src_install() { - into / - dosbin pump || die - - doman pump.8 - dodoc CREDITS - - into /usr/ - dolib.a libpump.a - insinto /usr/include/ - doins pump.h - - make -C po install datadir="${D}/usr/share/" -} diff --git a/net-misc/pump/pump-0.8.21-r3.ebuild b/net-misc/pump/pump-0.8.21-r3.ebuild new file mode 100644 index 000000000000..7787ea5e3679 --- /dev/null +++ b/net-misc/pump/pump-0.8.21-r3.ebuild @@ -0,0 +1,50 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/pump/pump-0.8.21-r3.ebuild,v 1.1 2005/07/01 13:52:29 uberlord Exp $ + +inherit eutils + +DESCRIPTION="This is the DHCP/BOOTP client written by RedHat" +HOMEPAGE="http://ftp.debian.org/debian/pool/main/p/pump/" +SRC_URI="mirror://debian/pool/main/p/${PN}/${PN}_${PV}.orig.tar.gz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~arm ~hppa ~ia64 ~ppc ~sparc ~x86" +IUSE="" + +DEPEND=">=dev-libs/popt-1.5" + +PROVIDE="virtual/dhcpc" + +src_unpack() { + unpack "${A}" + cd "${S}" + + # Enable the -e (--etc-dir) option to specify where to make + # resolv.conf - default /etc + # Enable the -m (--route-metric) option to specify the default + # metric applied to routes + # Enable the --script option to specify a script to run on DHCP actions + # Enable the --keep-up option to keep interfaces up when we release + epatch "${FILESDIR}/pump-${PV}-gentoo.diff" +} + +src_compile() { + make pump RPM_OPT_FLAGS="${CFLAGS}" || die +} + +src_install() { + into / + dosbin pump || die + + doman pump.8 + dodoc CREDITS + + into /usr/ + dolib.a libpump.a + insinto /usr/include/ + doins pump.h + + make -C po install datadir="${D}/usr/share/" +} -- cgit v1.2.3-65-gdbad