- The daemon actually runs now (somewhat)

- Added support for tun/tap driver (autodetect!)
- More sophisticated checkpoint functionality
- Updated dutch translation
This commit is contained in:
Guus Sliepen 2000-10-15 00:59:37 +00:00
parent 97ce045189
commit 85adeef212
16 changed files with 1259 additions and 1173 deletions

View file

@ -1,6 +1,7 @@
/* /*
utils.c -- gathering of some stupid small functions utils.c -- gathering of some stupid small functions
Copyright (C) 1999 Ivo Timmermans <zarq@iname.com> Copyright (C) 1999,2000 Ivo Timmermans <zarq@iname.com>
2000 Guus Sliepen <guus@sliepen.warande.net>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -23,9 +24,11 @@
#include "config.h" #include "config.h"
#include <utils.h> #include <utils.h>
#include <syslog.h>
volatile int cp_line; volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0};
volatile char *cp_file; volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?"};
volatile int cp_index = 0;
char *charbin2hex = "0123456789ABCDEF"; char *charbin2hex = "0123456789ABCDEF";
@ -37,19 +40,33 @@ int charhex2bin(char c)
return tolower(c) - 'a' + 10; return tolower(c) - 'a' + 10;
} }
void hex2bin(char *src, char *dst, size_t length) void hex2bin(char *src, char *dst, int length)
{ {
size_t i; int i;
for(i=0; i<length; i++) for(i=0; i<length; i++)
dst[i] = charhex2bin(src[i*2])<<4 || charhex2bin(src[i*2+1]); dst[i] = charhex2bin(src[i*2])<<4 || charhex2bin(src[i*2+1]);
} }
void bin2hex(char *src, char *dst, size_t length) void bin2hex(char *src, char *dst, int length)
{ {
size_t i; int i;
for(i=length-1; i>=0; i--) for(i=length-1; i>=0; i--)
{ {
dst[i*2+1] = charbin2hex[src[i] & 15]; dst[i*2+1] = charbin2hex[(unsigned char)src[i] & 15];
dst[i*2] = charbin2hex[src[i]>>4]; dst[i*2] = charbin2hex[(unsigned char)src[i]>>4];
} }
} }
char *cp_trace()
{
syslog(LOG_DEBUG, "Checkpoint trace: %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d ...",
cp_file[(cp_index+7)%8], cp_line[(cp_index+7)%8],
cp_file[(cp_index+6)%8], cp_line[(cp_index+6)%8],
cp_file[(cp_index+5)%8], cp_line[(cp_index+5)%8],
cp_file[(cp_index+4)%8], cp_line[(cp_index+4)%8],
cp_file[(cp_index+3)%8], cp_line[(cp_index+3)%8],
cp_file[(cp_index+2)%8], cp_line[(cp_index+2)%8],
cp_file[(cp_index+1)%8], cp_line[(cp_index+1)%8],
cp_file[cp_index], cp_line[cp_index]
);
}

View file

@ -1,6 +1,7 @@
/* /*
utils.h -- header file for utils.c utils.h -- header file for utils.c
Copyright (C) 1999 Ivo Timmermans <zarq@iname.com> Copyright (C) 1999,2000 Ivo Timmermans <zarq@iname.com>
2000 Guus Sliepen <guus@sliepen.warande.net>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -26,18 +27,21 @@ enum {
DEBUG_CONNECTIONS = 0, DEBUG_CONNECTIONS = 0,
DEBUG_PROTOCOL, DEBUG_PROTOCOL,
DEBUG_STATUS, DEBUG_STATUS,
DEBUG_error, DEBUG_ERROR,
DEBUG_META DEBUG_META
}; };
#define min(a,b) (((a)<(b))?(a):(b)) #define min(a,b) (((a)<(b))?(a):(b))
#define cp { cp_line = __LINE__; cp_file = __FILE__; } extern volatile int cp_line[];
extern volatile char *cp_file[];
extern volatile int cp_index;
extern volatile int cp_line; #define cp { cp_line[cp_index] = __LINE__; cp_file[cp_index] = __FILE__; cp_index++; cp_index %= 8; }
extern volatile char *cp_file; #define ecp { fprintf(stderr, "Explicit checkpoint in %s line %d\n", __FILE__, __LINE__); }
extern void hex2bin(char *src, char *dst, size_t length); extern void hex2bin(char *src, char *dst, int length);
extern void bin2hex(char *src, char *dst, size_t length); extern void bin2hex(char *src, char *dst, int length);
extern char *cp_trace(void);
#endif /* __TINC_UTILS_H__ */ #endif /* __TINC_UTILS_H__ */

View file

@ -4,10 +4,12 @@
# Package source files # Package source files
lib/pidfile.c lib/pidfile.c
lib/utils.c
src/conf.c src/conf.c
src/encr.c
src/genauth.c src/genauth.c
src/meta.c
src/net.c src/net.c
src/netutl.c src/netutl.c
src/protocol.c src/protocol.c
src/subnet.c
src/tincd.c src/tincd.c

1142
po/es.po

File diff suppressed because it is too large Load diff

985
po/nl.po

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: conf.c,v 1.9.4.13 2000/10/14 17:04:12 guus Exp $ $Id: conf.c,v 1.9.4.14 2000/10/15 00:59:34 guus Exp $
*/ */
@ -41,10 +41,11 @@
#include "connlist.h" #include "connlist.h"
#include "system.h" #include "system.h"
config_t *config; config_t *config = NULL;
int debug_lvl = 0; int debug_lvl = 0;
int timeout = 0; /* seconds before timeout */ int timeout = 0; /* seconds before timeout */
char *confbase = NULL; /* directory in which all config files are */ char *confbase = NULL; /* directory in which all config files are */
char *netname = NULL; /* name of the vpn network */
/* Will be set if HUP signal is received. It will be processed when it is safe. */ /* Will be set if HUP signal is received. It will be processed when it is safe. */
int sighup = 0; int sighup = 0;
@ -58,6 +59,7 @@ static internal_config_t hazahaza[] = {
{ "ConnectTo", connectto, TYPE_NAME }, { "ConnectTo", connectto, TYPE_NAME },
{ "PingTimeout", pingtimeout, TYPE_INT }, { "PingTimeout", pingtimeout, TYPE_INT },
{ "TapDevice", tapdevice, TYPE_NAME }, { "TapDevice", tapdevice, TYPE_NAME },
{ "TapSubnet", tapsubnet, TYPE_IP },
{ "PrivateKey", privatekey, TYPE_NAME }, { "PrivateKey", privatekey, TYPE_NAME },
{ "KeyExpire", keyexpire, TYPE_INT }, { "KeyExpire", keyexpire, TYPE_INT },
{ "Hostnames", resolve_dns, TYPE_BOOL }, { "Hostnames", resolve_dns, TYPE_BOOL },
@ -116,22 +118,17 @@ cp
if(p->data.val) if(p->data.val)
{ {
if(*cfg) p->next = *cfg;
{ *cfg = p;
r = *cfg; cp
while(r->next)
r = r->next;
r->next = p;
}
else
*cfg = p;
p->next = NULL;
return p; return p;
} }
else
free(p); {
free(p);
cp cp
return NULL; return NULL;
}
} }
/* /*
@ -215,7 +212,7 @@ int read_server_config()
char *fname; char *fname;
int x; int x;
cp cp
asprintf(fname, "%s/tinc.conf", confbase); asprintf(&fname, "%s/tinc.conf", confbase);
x = read_config_file(&config, fname); x = read_config_file(&config, fname);
free(fname); free(fname);
cp cp
@ -230,10 +227,9 @@ const config_t *get_config_val(config_t *p, which_t type)
cp cp
for(p = config; p != NULL; p = p->next) for(p = config; p != NULL; p = p->next)
if(p->which == type) if(p->which == type)
return p; break;
cp cp
/* Not found */ return p;
return NULL;
} }
/* /*
@ -246,10 +242,9 @@ cp
for(p = config; p != NULL; p = p->next) for(p = config; p != NULL; p = p->next)
if(p->which == type) if(p->which == type)
if(--index < 0) if(--index < 0)
return p; break;
cp cp
/* Not found */ return p;
return NULL;
} }
/* /*

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: conf.h,v 1.6.4.12 2000/10/14 17:04:13 guus Exp $ $Id: conf.h,v 1.6.4.13 2000/10/15 00:59:34 guus Exp $
*/ */
#ifndef __TINC_CONF_H__ #ifndef __TINC_CONF_H__
@ -35,6 +35,7 @@ typedef enum which_t {
connectto, connectto,
pingtimeout, pingtimeout,
tapdevice, tapdevice,
tapsubnet,
privatekey, privatekey,
keyexpire, keyexpire,
resolve_dns, resolve_dns,
@ -88,6 +89,7 @@ extern int timeout;
extern int upstreamindex; extern int upstreamindex;
extern int sighup; extern int sighup;
extern char *confbase; extern char *confbase;
extern char *netname;
extern config_t *add_config_val(config_t **, int, char *); extern config_t *add_config_val(config_t **, int, char *);
extern int read_config_file(config_t **, const char *); extern int read_config_file(config_t **, const char *);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: connlist.c,v 1.1.2.3 2000/10/14 17:04:13 guus Exp $ $Id: connlist.c,v 1.1.2.4 2000/10/15 00:59:34 guus Exp $
*/ */
#include <syslog.h> #include <syslog.h>
@ -53,7 +53,7 @@ cp
destroy_queue(p->sq); destroy_queue(p->sq);
if(p->rq) if(p->rq)
destroy_queue(p->rq); destroy_queue(p->rq);
if(p->name) if(p->name && p->name!=unknown)
free(p->name); free(p->name);
if(p->hostname) if(p->hostname)
free(p->hostname); free(p->hostname);
@ -61,6 +61,8 @@ cp
RSA_free(p->public_key); RSA_free(p->public_key);
if(p->cipher_pktkey) if(p->cipher_pktkey)
free(p->cipher_pktkey); free(p->cipher_pktkey);
if(p->buffer)
free(p->buffer);
free(p); free(p);
cp cp
} }
@ -214,7 +216,7 @@ int read_host_config(conn_list_t *cl)
char *fname; char *fname;
int x; int x;
cp cp
asprintf(fname, "%s/hosts/%s", confbase, cl->name); asprintf(&fname, "%s/hosts/%s", confbase, cl->name);
x = read_config_file(&cl->config, fname); x = read_config_file(&cl->config, fname);
free(fname); free(fname);
cp cp

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: genauth.c,v 1.7.4.1 2000/10/11 12:07:27 guus Exp $ $Id: genauth.c,v 1.7.4.2 2000/10/15 00:59:34 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -98,7 +98,8 @@ int main(int argc, char **argv)
fprintf(stderr, _("Done.\n")); fprintf(stderr, _("Done.\n"));
printf("Public key:\t%s\nPrivate key:\t%s\n", BN_bn2hex(key->n), BN_bn2hex(key->d)); printf(_("Public key: %s\n"), BN_bn2hex(key->n));
printf(_("Private key: %s\n"), BN_bn2hex(key->d));
return 0; return 0;
} }

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: meta.c,v 1.1.2.3 2000/10/11 22:00:58 guus Exp $ $Id: meta.c,v 1.1.2.4 2000/10/15 00:59:34 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -42,6 +42,8 @@ cp
syslog(LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s): %s"), length, syslog(LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s): %s"), length,
cl->name, cl->hostname, buffer); cl->name, cl->hostname, buffer);
buffer[length-1]='\n';
if(cl->status.encryptout) if(cl->status.encryptout)
{ {
EVP_EncryptUpdate(cl->cipher_outctx, outbuf, &outlen, buffer, length); EVP_EncryptUpdate(cl->cipher_outctx, outbuf, &outlen, buffer, length);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net.c,v 1.35.4.35 2000/10/14 17:04:13 guus Exp $ $Id: net.c,v 1.35.4.36 2000/10/15 00:59:34 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -37,6 +37,10 @@
#include <syslog.h> #include <syslog.h>
#include <unistd.h> #include <unistd.h>
/* Next two includes are for tun/tap support */
#include <net/if.h>
#include "/usr/src/linux/include/linux/if_tun.h"
#include <utils.h> #include <utils.h>
#include <xalloc.h> #include <xalloc.h>
@ -59,6 +63,8 @@ int total_socket_out = 0;
int upstreamindex = 0; int upstreamindex = 0;
static int seconds_till_retry; static int seconds_till_retry;
char *unknown = NULL;
/* /*
strip off the MAC adresses of an ethernet frame strip off the MAC adresses of an ethernet frame
*/ */
@ -326,19 +332,38 @@ int setup_tap_fd(void)
int nfd; int nfd;
const char *tapfname; const char *tapfname;
config_t const *cfg; config_t const *cfg;
struct ifreq ifr;
cp cp
if((cfg = get_config_val(config, tapdevice)) == NULL) if((cfg = get_config_val(config, tapdevice)))
tapfname = "/dev/tap0";
else
tapfname = cfg->data.ptr; tapfname = cfg->data.ptr;
else
tapfname = "/dev/misc/net/tun";
cp
if((nfd = open(tapfname, O_RDWR | O_NONBLOCK)) < 0) if((nfd = open(tapfname, O_RDWR | O_NONBLOCK)) < 0)
{ {
syslog(LOG_ERR, _("Could not open %s: %m"), tapfname); syslog(LOG_ERR, _("Could not open %s: %m"), tapfname);
return -1; return -1;
} }
cp
tap_fd = nfd; tap_fd = nfd;
/* Ok now check if this is an old ethertap or a new tun/tap thingie */
memset(&ifr, 0, sizeof(ifr));
cp
ifr.ifr_flags = IFF_TAP;
if (netname)
strncpy(ifr.ifr_name, netname, IFNAMSIZ);
cp
if (!ioctl(tap_fd, TUNSETIFF, (void *) &ifr))
{
syslog(LOG_INFO, _("%s is a new style tun/tap device"), tapfname);
if((cfg = get_config_val(config, tapsubnet)) == NULL)
syslog(LOG_INFO, _("tun/tap device will be left unconfigured"));
else
/* Setup inetaddr/netmask etc */;
}
cp cp
return 0; return 0;
} }
@ -554,6 +579,7 @@ cp
asprintf(&myself->hostname, "MYSELF"); /* FIXME? Do hostlookup on ourselves? */ asprintf(&myself->hostname, "MYSELF"); /* FIXME? Do hostlookup on ourselves? */
myself->flags = 0; myself->flags = 0;
myself->protocol_version = PROT_CURRENT;
if(!(cfg = get_config_val(config, tincname))) /* Not acceptable */ if(!(cfg = get_config_val(config, tincname))) /* Not acceptable */
{ {
@ -590,13 +616,13 @@ cp
if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0) if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0)
{ {
syslog(LOG_ERR, _("Unable to set up a listening socket")); syslog(LOG_ERR, _("Unable to set up a listening socket!"));
return -1; return -1;
} }
if((myself->socket = setup_vpn_in_socket(myself->port)) < 0) if((myself->socket = setup_vpn_in_socket(myself->port)) < 0)
{ {
syslog(LOG_ERR, _("Unable to set up an incoming vpn data socket")); syslog(LOG_ERR, _("Unable to set up an incoming vpn data socket!"));
close(myself->meta_socket); close(myself->meta_socket);
return -1; return -1;
} }
@ -773,10 +799,12 @@ cp
return NULL; return NULL;
} }
p->name = unknown;
p->address = ntohl(ci.sin_addr.s_addr); p->address = ntohl(ci.sin_addr.s_addr);
p->hostname = hostlookup(ci.sin_addr.s_addr); p->hostname = hostlookup(ci.sin_addr.s_addr);
p->meta_socket = sfd; p->meta_socket = sfd;
p->status.meta = 1; p->status.meta = 1;
p->buffer = xmalloc(MAXBUFSIZE);
p->buflen = 0; p->buflen = 0;
p->last_ping_time = time(NULL); p->last_ping_time = time(NULL);
p->want_ping = 0; p->want_ping = 0;

View file

@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net.h,v 1.9.4.16 2000/10/14 17:04:15 guus Exp $ $Id: net.h,v 1.9.4.17 2000/10/15 00:59:35 guus Exp $
*/ */
#ifndef __TINC_NET_H__ #ifndef __TINC_NET_H__
@ -44,7 +44,7 @@
((unsigned char*)&(x))[1],((unsigned char*)&(x))[0] ((unsigned char*)&(x))[1],((unsigned char*)&(x))[0]
#endif #endif
#define MAXBUFSIZE 2048 /* Probably way too much, but it must fit every possible request. */ #define MAXBUFSIZE 4096 /* Probably way too much, but it must fit every possible request. */
/* flags */ /* flags */
#define INDIRECTDATA 0x0001 /* Used to indicate that this host has to be reached indirect */ #define INDIRECTDATA 0x0001 /* Used to indicate that this host has to be reached indirect */
@ -124,6 +124,8 @@ extern int total_tap_out;
extern int total_socket_in; extern int total_socket_in;
extern int total_socket_out; extern int total_socket_out;
extern char *unknown;
extern char *request_name[256]; extern char *request_name[256];
extern char *status_text[10]; extern char *status_text[10];

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol.c,v 1.28.4.39 2000/10/14 17:04:15 guus Exp $ $Id: protocol.c,v 1.28.4.40 2000/10/15 00:59:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -52,40 +52,40 @@ int check_id(char *id)
int i; int i;
for (i = 0; i < strlen(id); i++) for (i = 0; i < strlen(id); i++)
{ if(!isalnum(id[i]) && id[i] != '_')
if(!isalpha(id[i]) && id[i] != '_') return -1;
{
return 0;
}
}
return 1; return 0;
} }
/* Generic request routines - takes care of logging and error detection as well */ /* Generic request routines - takes care of logging and error detection as well */
int send_request(conn_list_t *cl, const char *format, int request, /*args*/ ...) int send_request(conn_list_t *cl, const char *format, ...)
{ {
va_list args; va_list args;
char buffer[MAXBUFSIZE+1]; char buffer[MAXBUFSIZE];
int len; int len, request;
cp cp
/* Use vsnprintf instead of vasprintf: faster, no memory fragmentation, cleanup is automatic, /* Use vsnprintf instead of vasprintf: faster, no memory fragmentation, cleanup is automatic,
and there is a limit on the input buffer anyway */ and there is a limit on the input buffer anyway */
va_start(args, request); va_start(args, format);
len = vsnprintf(buffer, MAXBUFSIZE+1, format, args); len = vsnprintf(buffer, MAXBUFSIZE, format, args);
request = va_arg(args, int);
va_end(args); va_end(args);
if(len < 0 || len > MAXBUFSIZE) if(len < 0 || len > MAXBUFSIZE-1)
{ {
syslog(LOG_ERR, _("Output buffer overflow while sending %s to %s (%s)"), request_name[request], cl->name, cl->hostname); syslog(LOG_ERR, _("Output buffer overflow while sending %s to %s (%s)"), request_name[request], cl->name, cl->hostname);
return -1; return -1;
} }
len++;
if(debug_lvl >= DEBUG_PROTOCOL) if(debug_lvl >= DEBUG_PROTOCOL)
syslog(LOG_DEBUG, _("Sending %s to %s (%s)"), request_name[request], cl->name, cl->hostname); syslog(LOG_DEBUG, _("Sending %s to %s (%s)"), request_name[request], cl->name, cl->hostname);
cp cp
return send_meta(cl, buffer, len); return send_meta(cl, buffer, len);
} }
@ -179,7 +179,7 @@ cp
/* Check if identity is a valid name */ /* Check if identity is a valid name */
if(!check_id(cl->name)) if(check_id(cl->name))
{ {
syslog(LOG_ERR, _("Peer %s uses invalid identity name"), cl->hostname); syslog(LOG_ERR, _("Peer %s uses invalid identity name"), cl->hostname);
return -1; return -1;
@ -227,14 +227,14 @@ cp
if(!cl->hischallenge) if(!cl->hischallenge)
cl->hischallenge = xmalloc(CHAL_LENGTH); cl->hischallenge = xmalloc(CHAL_LENGTH);
cp
/* Copy random data to the buffer */ /* Copy random data to the buffer */
RAND_bytes(cl->hischallenge, CHAL_LENGTH); RAND_bytes(cl->hischallenge, CHAL_LENGTH);
cp
/* Convert the random data to a hexadecimal formatted string */ /* Convert the random data to a hexadecimal formatted string */
bin2hex(cl->hischallenge,buffer,CHAL_LENGTH); bin2hex(cl->hischallenge, buffer, CHAL_LENGTH);
buffer[CHAL_LENGTH*2] = '\0'; buffer[CHAL_LENGTH*2] = '\0';
/* Send the challenge */ /* Send the challenge */
@ -442,7 +442,7 @@ cp
/* Check if owner name is a valid */ /* Check if owner name is a valid */
if(!check_id(name)) if(check_id(name))
{ {
syslog(LOG_ERR, _("Got bad ADD_SUBNET from %s (%s): invalid identity name"), cl->name, cl->hostname); syslog(LOG_ERR, _("Got bad ADD_SUBNET from %s (%s): invalid identity name"), cl->name, cl->hostname);
free(name); free(subnetstr); free(name); free(subnetstr);
@ -510,7 +510,7 @@ cp
/* Check if owner name is a valid */ /* Check if owner name is a valid */
if(!check_id(name)) if(check_id(name))
{ {
syslog(LOG_ERR, _("Got bad DEL_SUBNET from %s (%s): invalid identity name"), cl->name, cl->hostname); syslog(LOG_ERR, _("Got bad DEL_SUBNET from %s (%s): invalid identity name"), cl->name, cl->hostname);
free(name); free(subnetstr); free(name); free(subnetstr);
@ -580,7 +580,7 @@ cp
/* Check if identity is a valid name */ /* Check if identity is a valid name */
if(!check_id(new->name) || !check_id(sender)) if(check_id(new->name) || check_id(sender))
{ {
syslog(LOG_ERR, _("Got bad ADD_HOST from %s (%s): invalid identity name"), cl->name, cl->hostname); syslog(LOG_ERR, _("Got bad ADD_HOST from %s (%s): invalid identity name"), cl->name, cl->hostname);
free(sender); free(sender);
@ -687,7 +687,7 @@ cp
/* Check if identity is a valid name */ /* Check if identity is a valid name */
if(!check_id(name) || !check_id(sender)) if(check_id(name) || check_id(sender))
{ {
syslog(LOG_ERR, _("Got bad DEL_HOST from %s (%s): invalid identity name"), cl->name, cl->hostname); syslog(LOG_ERR, _("Got bad DEL_HOST from %s (%s): invalid identity name"), cl->name, cl->hostname);
free(name); free(sender); free(name); free(sender);
@ -804,12 +804,12 @@ int error_h(conn_list_t *cl)
cp cp
if(sscanf(cl->buffer, "%*d %d %as", &errno, &errorstring) != 2) if(sscanf(cl->buffer, "%*d %d %as", &errno, &errorstring) != 2)
{ {
syslog(LOG_ERR, _("Got bad error from %s (%s)"), syslog(LOG_ERR, _("Got bad ERROR from %s (%s)"),
cl->name, cl->hostname); cl->name, cl->hostname);
return -1; return -1;
} }
if(debug_lvl > DEBUG_error) if(debug_lvl > DEBUG_ERROR)
{ {
syslog(LOG_NOTICE, _("Error message from %s (%s): %s: %s"), syslog(LOG_NOTICE, _("Error message from %s (%s): %s: %s"),
cl->name, cl->hostname, strerror(errno), errorstring); cl->name, cl->hostname, strerror(errno), errorstring);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol.h,v 1.5.4.10 2000/10/11 22:01:02 guus Exp $ $Id: protocol.h,v 1.5.4.11 2000/10/15 00:59:36 guus Exp $
*/ */
#ifndef __TINC_PROTOCOL_H__ #ifndef __TINC_PROTOCOL_H__
@ -37,7 +37,7 @@
quite large. quite large.
*/ */
#define CHAL_LENGTH 2048 #define CHAL_LENGTH 1024 /* Okay, this is probably waaaaaaaaaaay too large */
/* Request numbers */ /* Request numbers */

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: subnet.c,v 1.1.2.3 2000/10/11 22:01:02 guus Exp $ $Id: subnet.c,v 1.1.2.4 2000/10/15 00:59:37 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -145,7 +145,7 @@ cp
switch(subnet->type) switch(subnet->type)
{ {
case SUBNET_MAC: case SUBNET_MAC:
asprintf(netstr, "%d,%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", subnet->type, asprintf(&netstr, "%d,%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", subnet->type,
subnet->net.mac.address.x[0], subnet->net.mac.address.x[0],
subnet->net.mac.address.x[1], subnet->net.mac.address.x[1],
subnet->net.mac.address.x[2], subnet->net.mac.address.x[2],
@ -153,9 +153,9 @@ cp
subnet->net.mac.address.x[4], subnet->net.mac.address.x[4],
subnet->net.mac.address.x[5]); subnet->net.mac.address.x[5]);
case SUBNET_IPV4: case SUBNET_IPV4:
asprintf(netstr, "%d,%lx:%lx", subnet->type, subnet->net.ipv4.address, subnet->net.ipv4.mask); asprintf(&netstr, "%d,%lx:%lx", subnet->type, subnet->net.ipv4.address, subnet->net.ipv4.mask);
case SUBNET_IPV6: case SUBNET_IPV6:
asprintf(netstr, "%d,%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", asprintf(&netstr, "%d,%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx",
subnet->net.ipv6.address.x[0], subnet->net.ipv6.address.x[0],
subnet->net.ipv6.address.x[1], subnet->net.ipv6.address.x[1],
subnet->net.ipv6.address.x[2], subnet->net.ipv6.address.x[2],

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: tincd.c,v 1.10.4.11 2000/10/14 17:04:16 guus Exp $ $Id: tincd.c,v 1.10.4.12 2000/10/15 00:59:37 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -64,7 +64,6 @@ static int kill_tincd = 0;
static int do_detach = 1; static int do_detach = 1;
char *identname; /* program name for syslog */ char *identname; /* program name for syslog */
char *netname = NULL; /* name of the vpn network */
char *pidfilename; /* pid file location */ char *pidfilename; /* pid file location */
static pid_t ppid; /* pid of non-detached part */ static pid_t ppid; /* pid of non-detached part */
char **g_argv; /* a copy of the cmdline arguments */ char **g_argv; /* a copy of the cmdline arguments */
@ -180,7 +179,7 @@ int detach(void)
if(pid) /* parent process */ if(pid) /* parent process */
{ {
signal(SIGTERM, parent_exit); signal(SIGTERM, parent_exit);
sleep(600); /* wait 10 minutes */ // sleep(600); /* wait 10 minutes */
exit(1); exit(1);
} }
} }
@ -302,6 +301,7 @@ void make_names(void)
} }
else else
{ {
netname = "bla";
if(!pidfilename) if(!pidfilename)
pidfilename = "/var/run/tinc.pid"; pidfilename = "/var/run/tinc.pid";
if(!confbase) if(!confbase)
@ -320,17 +320,20 @@ main(int argc, char **argv, char **envp)
bindtextdomain (PACKAGE, LOCALEDIR); bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE); textdomain (PACKAGE);
/* Do some intl stuff right now */
unknown = _("unknown");
parse_options(argc, argv, envp); parse_options(argc, argv, envp);
if(show_version) if(show_version)
{ {
printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE, VERSION, __DATE__, __TIME__, PROT_CURRENT); printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE, VERSION, __DATE__, __TIME__, PROT_CURRENT);
printf(_("Copyright (C) 1998,1999,2000 Ivo Timmermans and others,\n" printf(_("Copyright (C) 1998,1999,2000 Ivo Timmermans, Guus Sliepen and others.\n"
"see the AUTHORS file for a complete list.\n\n" "See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n" "and you are welcome to redistribute it under certain conditions;\n"
"see the file COPYING for details.\n\n")); "see the file COPYING for details.\n"));
printf(_("This product includes software developed by Eric Young (eay@mincom.oz.au)\n"));
return 0; return 0;
} }
@ -365,14 +368,25 @@ main(int argc, char **argv, char **envp)
*/ */
for(;;) for(;;)
{ {
setup_network_connections(); if(!setup_network_connections())
{
main_loop();
cleanup_and_exit(1);
}
main_loop(); syslog(LOG_ERR, _("Unrecoverable error"));
cp_trace();
cleanup_and_exit(1); if(do_detach)
{
syslog(LOG_ERR, _("Unrecoverable error, restarting in %d seconds!"), MAXTIMEOUT); syslog(LOG_NOTICE, _("Restarting in %d seconds!"), MAXTIMEOUT);
sleep(MAXTIMEOUT); sleep(MAXTIMEOUT);
}
else
{
syslog(LOG_ERR, _("Aieee! Not restarting."));
exit(0);
}
} }
} }
@ -395,23 +409,30 @@ sigquit_handler(int a)
RETSIGTYPE RETSIGTYPE
sigsegv_square(int a) sigsegv_square(int a)
{ {
syslog(LOG_NOTICE, _("Got another SEGV signal: not restarting")); syslog(LOG_ERR, _("Got another SEGV signal: not restarting"));
exit(0); exit(0);
} }
RETSIGTYPE RETSIGTYPE
sigsegv_handler(int a) sigsegv_handler(int a)
{ {
if(cp_file) syslog(LOG_ERR, _("Got SEGV signal"));
syslog(LOG_NOTICE, _("Got SEGV signal after %s line %d, trying to re-execute"), cp_trace();
cp_file, cp_line);
else
syslog(LOG_NOTICE, _("Got SEGV signal, trying to re-execute"));
signal(SIGSEGV, sigsegv_square); if(do_detach)
close_network_connections(); {
remove_pid(pidfilename); syslog(LOG_NOTICE, _("Trying to re-execute in 5 seconds..."));
execvp(g_argv[0], g_argv); signal(SIGSEGV, sigsegv_square);
close_network_connections();
sleep(5);
remove_pid(pidfilename);
execvp(g_argv[0], g_argv);
}
else
{
syslog(LOG_NOTICE, _("Aieee! Not restarting."));
exit(0);
}
} }
RETSIGTYPE RETSIGTYPE
@ -449,11 +470,8 @@ sigusr2_handler(int a)
RETSIGTYPE RETSIGTYPE
sighuh(int a) sighuh(int a)
{ {
if(cp_file) syslog(LOG_WARNING, _("Got unexpected signal %d (%s)"), a, strsignal(a));
syslog(LOG_NOTICE, _("Got unexpected %s after %s line %d"), cp_trace();
strsignal(a), cp_file, cp_line);
else
syslog(LOG_NOTICE, _("Got unexpected %s"), strsignal(a));
} }
void void