- 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
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
it under the terms of the GNU General Public License as published by
@ -23,9 +24,11 @@
#include "config.h"
#include <utils.h>
#include <syslog.h>
volatile int cp_line;
volatile char *cp_file;
volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0};
volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?"};
volatile int cp_index = 0;
char *charbin2hex = "0123456789ABCDEF";
@ -37,19 +40,33 @@ int charhex2bin(char c)
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++)
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--)
{
dst[i*2+1] = charbin2hex[src[i] & 15];
dst[i*2] = charbin2hex[src[i]>>4];
dst[i*2+1] = charbin2hex[(unsigned char)src[i] & 15];
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
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
it under the terms of the GNU General Public License as published by
@ -26,18 +27,21 @@ enum {
DEBUG_CONNECTIONS = 0,
DEBUG_PROTOCOL,
DEBUG_STATUS,
DEBUG_error,
DEBUG_ERROR,
DEBUG_META
};
#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;
extern volatile char *cp_file;
#define cp { cp_line[cp_index] = __LINE__; cp_file[cp_index] = __FILE__; cp_index++; cp_index %= 8; }
#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 bin2hex(char *src, char *dst, size_t length);
extern void hex2bin(char *src, char *dst, int length);
extern void bin2hex(char *src, char *dst, int length);
extern char *cp_trace(void);
#endif /* __TINC_UTILS_H__ */

View file

@ -4,10 +4,12 @@
# Package source files
lib/pidfile.c
lib/utils.c
src/conf.c
src/encr.c
src/genauth.c
src/meta.c
src/net.c
src/netutl.c
src/protocol.c
src/subnet.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
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 "system.h"
config_t *config;
config_t *config = NULL;
int debug_lvl = 0;
int timeout = 0; /* seconds before timeout */
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. */
int sighup = 0;
@ -58,6 +59,7 @@ static internal_config_t hazahaza[] = {
{ "ConnectTo", connectto, TYPE_NAME },
{ "PingTimeout", pingtimeout, TYPE_INT },
{ "TapDevice", tapdevice, TYPE_NAME },
{ "TapSubnet", tapsubnet, TYPE_IP },
{ "PrivateKey", privatekey, TYPE_NAME },
{ "KeyExpire", keyexpire, TYPE_INT },
{ "Hostnames", resolve_dns, TYPE_BOOL },
@ -116,22 +118,17 @@ cp
if(p->data.val)
{
if(*cfg)
{
r = *cfg;
while(r->next)
r = r->next;
r->next = p;
}
else
p->next = *cfg;
*cfg = p;
p->next = NULL;
cp
return p;
}
else
{
free(p);
cp
return NULL;
}
}
/*
@ -215,7 +212,7 @@ int read_server_config()
char *fname;
int x;
cp
asprintf(fname, "%s/tinc.conf", confbase);
asprintf(&fname, "%s/tinc.conf", confbase);
x = read_config_file(&config, fname);
free(fname);
cp
@ -230,10 +227,9 @@ const config_t *get_config_val(config_t *p, which_t type)
cp
for(p = config; p != NULL; p = p->next)
if(p->which == type)
return p;
break;
cp
/* Not found */
return NULL;
return p;
}
/*
@ -246,10 +242,9 @@ cp
for(p = config; p != NULL; p = p->next)
if(p->which == type)
if(--index < 0)
return p;
break;
cp
/* Not found */
return NULL;
return p;
}
/*

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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__
@ -35,6 +35,7 @@ typedef enum which_t {
connectto,
pingtimeout,
tapdevice,
tapsubnet,
privatekey,
keyexpire,
resolve_dns,
@ -88,6 +89,7 @@ extern int timeout;
extern int upstreamindex;
extern int sighup;
extern char *confbase;
extern char *netname;
extern config_t *add_config_val(config_t **, int, 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
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>
@ -53,7 +53,7 @@ cp
destroy_queue(p->sq);
if(p->rq)
destroy_queue(p->rq);
if(p->name)
if(p->name && p->name!=unknown)
free(p->name);
if(p->hostname)
free(p->hostname);
@ -61,6 +61,8 @@ cp
RSA_free(p->public_key);
if(p->cipher_pktkey)
free(p->cipher_pktkey);
if(p->buffer)
free(p->buffer);
free(p);
cp
}
@ -214,7 +216,7 @@ int read_host_config(conn_list_t *cl)
char *fname;
int x;
cp
asprintf(fname, "%s/hosts/%s", confbase, cl->name);
asprintf(&fname, "%s/hosts/%s", confbase, cl->name);
x = read_config_file(&cl->config, fname);
free(fname);
cp

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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"
@ -98,7 +98,8 @@ int main(int argc, char **argv)
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;
}

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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"
@ -42,6 +42,8 @@ cp
syslog(LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s): %s"), length,
cl->name, cl->hostname, buffer);
buffer[length-1]='\n';
if(cl->status.encryptout)
{
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
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"
@ -37,6 +37,10 @@
#include <syslog.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 <xalloc.h>
@ -59,6 +63,8 @@ int total_socket_out = 0;
int upstreamindex = 0;
static int seconds_till_retry;
char *unknown = NULL;
/*
strip off the MAC adresses of an ethernet frame
*/
@ -326,19 +332,38 @@ int setup_tap_fd(void)
int nfd;
const char *tapfname;
config_t const *cfg;
struct ifreq ifr;
cp
if((cfg = get_config_val(config, tapdevice)) == NULL)
tapfname = "/dev/tap0";
else
if((cfg = get_config_val(config, tapdevice)))
tapfname = cfg->data.ptr;
else
tapfname = "/dev/misc/net/tun";
cp
if((nfd = open(tapfname, O_RDWR | O_NONBLOCK)) < 0)
{
syslog(LOG_ERR, _("Could not open %s: %m"), tapfname);
return -1;
}
cp
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
return 0;
}
@ -554,6 +579,7 @@ cp
asprintf(&myself->hostname, "MYSELF"); /* FIXME? Do hostlookup on ourselves? */
myself->flags = 0;
myself->protocol_version = PROT_CURRENT;
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)
{
syslog(LOG_ERR, _("Unable to set up a listening socket"));
syslog(LOG_ERR, _("Unable to set up a listening socket!"));
return -1;
}
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);
return -1;
}
@ -773,10 +799,12 @@ cp
return NULL;
}
p->name = unknown;
p->address = ntohl(ci.sin_addr.s_addr);
p->hostname = hostlookup(ci.sin_addr.s_addr);
p->meta_socket = sfd;
p->status.meta = 1;
p->buffer = xmalloc(MAXBUFSIZE);
p->buflen = 0;
p->last_ping_time = time(NULL);
p->want_ping = 0;

View file

@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
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__
@ -44,7 +44,7 @@
((unsigned char*)&(x))[1],((unsigned char*)&(x))[0]
#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 */
#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_out;
extern char *unknown;
extern char *request_name[256];
extern char *status_text[10];

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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"
@ -52,40 +52,40 @@ int check_id(char *id)
int i;
for (i = 0; i < strlen(id); i++)
{
if(!isalpha(id[i]) && id[i] != '_')
{
return 0;
}
}
if(!isalnum(id[i]) && id[i] != '_')
return -1;
return 1;
return 0;
}
/* 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;
char buffer[MAXBUFSIZE+1];
int len;
char buffer[MAXBUFSIZE];
int len, request;
cp
/* Use vsnprintf instead of vasprintf: faster, no memory fragmentation, cleanup is automatic,
and there is a limit on the input buffer anyway */
va_start(args, request);
len = vsnprintf(buffer, MAXBUFSIZE+1, format, args);
va_start(args, format);
len = vsnprintf(buffer, MAXBUFSIZE, format, args);
request = va_arg(args, int);
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);
return -1;
}
len++;
if(debug_lvl >= DEBUG_PROTOCOL)
syslog(LOG_DEBUG, _("Sending %s to %s (%s)"), request_name[request], cl->name, cl->hostname);
cp
return send_meta(cl, buffer, len);
}
@ -179,7 +179,7 @@ cp
/* 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);
return -1;
@ -227,14 +227,14 @@ cp
if(!cl->hischallenge)
cl->hischallenge = xmalloc(CHAL_LENGTH);
cp
/* Copy random data to the buffer */
RAND_bytes(cl->hischallenge, CHAL_LENGTH);
cp
/* 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';
/* Send the challenge */
@ -442,7 +442,7 @@ cp
/* 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);
free(name); free(subnetstr);
@ -510,7 +510,7 @@ cp
/* 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);
free(name); free(subnetstr);
@ -580,7 +580,7 @@ cp
/* 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);
free(sender);
@ -687,7 +687,7 @@ cp
/* 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);
free(name); free(sender);
@ -804,12 +804,12 @@ int error_h(conn_list_t *cl)
cp
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);
return -1;
}
if(debug_lvl > DEBUG_error)
if(debug_lvl > DEBUG_ERROR)
{
syslog(LOG_NOTICE, _("Error message from %s (%s): %s: %s"),
cl->name, cl->hostname, strerror(errno), errorstring);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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__
@ -37,7 +37,7 @@
quite large.
*/
#define CHAL_LENGTH 2048
#define CHAL_LENGTH 1024 /* Okay, this is probably waaaaaaaaaaay too large */
/* Request numbers */

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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"
@ -145,7 +145,7 @@ cp
switch(subnet->type)
{
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[1],
subnet->net.mac.address.x[2],
@ -153,9 +153,9 @@ cp
subnet->net.mac.address.x[4],
subnet->net.mac.address.x[5]);
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:
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[1],
subnet->net.ipv6.address.x[2],

View file

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