X-Git-Url: https://git.distorted.org.uk/~mdw/userv-utils/blobdiff_plain/02b2392d025937ea5a1108b07b0dcd2a52cd957e..f9e59051127e72847e1bee84ad52670e875f7d2f:/ipif/service.c diff --git a/ipif/service.c b/ipif/service.c index 33ba2df..24ea45b 100644 --- a/ipif/service.c +++ b/ipif/service.c @@ -15,7 +15,7 @@ * is the address of the point-to-point peer. * /,/,... * List of additional routes to add for this interface. - * May be the empty argument. + * May be the empty argument, or `-' if this is problematic. * * is either * ,/[,] @@ -31,6 +31,25 @@ * * Should be run from userv with no-disconnect-hup. */ +/* + * Copyright (C) 1999 Ian Jackson + * + * This 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. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with userv-utils; if not, write to the Free Software + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ #include #include @@ -49,7 +68,7 @@ #define NARGS 4 #define MAXEXROUTES 5 -#define ATXTLEN 12 +#define ATXTLEN 16 static const unsigned long gidmaxval= (unsigned long)((gid_t)-2); static const char *const protos_ok[]= { "slip", "cslip", "adaptive", 0 }; @@ -75,7 +94,7 @@ static struct pplace { } *cpplace; -static int slpipe[2], ptmaster; +static int slpipe[2], ptmaster, undoslattach; static const char *ifname; static const char *ptyname; @@ -88,13 +107,36 @@ static union { sigset_t emptyset, fullset; +static int cleantask(void) { + pid_t pid; + + pid= fork(); + if (!pid) return 1; + if (pid == (pid_t)-1) + perror("userv-ipif: fork for undo slattach failed - cannot clean up properly"); + return 0; +} + static void terminate(int estatus) { int i, status; pid_t pid; for (i=0; i0 && ifnbuf[k-1]!=' '; k--); ifname= ifnbuf+k; @@ -646,21 +718,9 @@ static void netconfigure(void) { sysfatal("cannot exec ifconfig"); } - if (task()) { - execlp("route","route", "-host",localtxt, "netmask","255.255.255.255", - "dev",ifname, (char*)0); - sysfatal("cannot exec route (for local)"); - } - - if (task()) { - execlp("route","route", "-host",peertxt, "netmask","255.255.255.255", - "dev",ifname, (char*)0); - sysfatal("cannot exec route (for peer)"); - } - for (i=0; i