diff options
author | Hans Insulander <hin@cvs.openbsd.org> | 2000-07-11 09:06:57 +0000 |
---|---|---|
committer | Hans Insulander <hin@cvs.openbsd.org> | 2000-07-11 09:06:57 +0000 |
commit | 28a4cae812f49405f5cf67b75420db2c93bc6789 (patch) | |
tree | 2e46f253d05c95438bd53818ac8f877792a333a3 | |
parent | b7ffabf30e9b71c0fc4730b1cfd1d304402cc63f (diff) |
Import of KTH Kerberos4 1.0.2
-rw-r--r-- | kerberosIV/src/appl/kip/kip-join-network.in | 53 | ||||
-rw-r--r-- | kerberosIV/src/appl/kip/kipd-control.in | 54 | ||||
-rw-r--r-- | kerberosIV/src/lib/roken/strcollect.c | 96 |
3 files changed, 203 insertions, 0 deletions
diff --git a/kerberosIV/src/appl/kip/kip-join-network.in b/kerberosIV/src/appl/kip/kip-join-network.in new file mode 100644 index 00000000000..62fecc5f902 --- /dev/null +++ b/kerberosIV/src/appl/kip/kip-join-network.in @@ -0,0 +1,53 @@ +#!/bin/sh +# $Id: kip-join-network.in,v 1.1 2000/07/11 09:05:58 hin Exp $ +# +# Join a network, see kipd-control from more comments. +# + +PATH=/usr/sbin:/sbin:/usr/bin:/bin:%bindir% + +endpointhost=130.237.43.201 +thispointhost=130.237.43.17 +fakepoint=10.0.0.1 +dev=tun0 + +case $# in + 0) + modprobe tun + def=$(route -n | awk '$1 ~ /0.0.0.0/ && $3 ~ /0.0.0.0/ { print $2 }') + + if test "X$def" = "X" ; then + echo "missing default route" + exit 1 + fi + + exec kip -c $0 -a $def $endpointhost + ;; + *) + state=$1 + dev=$2 + host=$3 + arg=$4 + case $state in + up) + ifconfig $dev $thispointhost pointopoint $fakepoint + route delete default + + route add -host $endpointhost gw $arg + route add default gw $fakepoint + ;; + down) + + echo $dev $arg > /tmp/kip-down + + ifconfig $dev down + + route delete default + route delete $endpointhost + route add default gw $arg + ;; + *) + exit 17 + ;; + esac +esac diff --git a/kerberosIV/src/appl/kip/kipd-control.in b/kerberosIV/src/appl/kip/kipd-control.in new file mode 100644 index 00000000000..e5f4d778564 --- /dev/null +++ b/kerberosIV/src/appl/kip/kipd-control.in @@ -0,0 +1,54 @@ +#!/bin/sh +# +# $Id: kipd-control.in,v 1.1 2000/07/11 09:05:58 hin Exp $ +# +# Simple example how you can missuse kip to provide "mobile-ip". +# This is since there is no way to tunnel ip over udp or any other +# protocol. There is also problems to get thru firewalls and NATs +# with mobile-ip since (today) they usully doesn't support IPIP or +# GRE. +# +# All commands are for linux (redhat6.1) but it should be quite +# simple to fix it to support other OS. +# + +PATH=/sbin:/usr/sbin:/usr/bin:/bin + +# arguments are: [up|down] dev remote-peer-addr user + +state=$1 +dev=$2 +remote=$3 +user=$4 + +outdevice=eth0 + +case "$state" in + up) + case "$user" in + lha.root@E.KTH.SE) + ifconfig $dev 10.0.0.1 pointopoint 130.237.43.17 + route add -host 130.237.43.17 gw 10.0.0.1 + arp -H ether -i $outdevice \ + -s 130.237.43.17 00:80:c8:82:83:61 pub + ;; + esac + ;; + down) + case "$user" in + lha.root@E.KTH.SE) + ifconfig $dev 0.0.0.0 + ifconfig $dev down + arp -i $outdevice -d 130.237.43.17 + arp -d 130.237.43.17 + true + ;; + *) + ifconfig $dev down + ;; + esac + ;; + *) + exit 17 + ;; +esac diff --git a/kerberosIV/src/lib/roken/strcollect.c b/kerberosIV/src/lib/roken/strcollect.c new file mode 100644 index 00000000000..93fc681bf8f --- /dev/null +++ b/kerberosIV/src/lib/roken/strcollect.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$KTH: strcollect.c,v 1.1.8.1 2000/06/23 04:37:44 assar Exp $"); +#endif + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <roken.h> + +enum { initial = 10, increment = 5 }; + +static char ** +sub (char **argv, int i, int argc, va_list *ap) +{ + do { + if(i == argc) { + /* realloc argv */ + char **tmp = realloc(argv, (argc + increment) * sizeof(*argv)); + if(tmp == NULL) { + free(argv); + errno = ENOMEM; + return NULL; + } + argv = tmp; + argc += increment; + } + argv[i++] = va_arg(*ap, char*); + } while(argv[i - 1] != NULL); + return argv; +} + +/* + * return a malloced vector of pointers to the strings in `ap' + * terminated by NULL. + */ + +char ** +vstrcollect(va_list *ap) +{ + return sub (NULL, 0, 0, ap); +} + +/* + * + */ + +char ** +strcollect(char *first, ...) +{ + va_list ap; + char **ret = malloc (initial * sizeof(char *)); + + if (ret == NULL) + return ret; + + ret[0] = first; + va_start(ap, first); + ret = sub (ret, 1, initial, &ap); + va_end(ap); + return ret; +} |