[vpnc-devel] Rekeying tweaks
Gary Benson
gbenson at redhat.com
Wed Aug 23 15:02:41 CEST 2006
Hi all,
I made these two patches while trying to debug a rekeying segfault.
They are made to be applied after Tomas Mraz's second rekeying patch
(http://lists.unix-ag.uni-kl.de/pipermail/vpnc-devel/2006-March/000867.html).
vpnc-0.3.3-rekeying-fix.patch stops vpnc from printing messages and
reopening the syslog at every rekey when --no-detach is specified.
vpnc-0.3.3-log-rekeying.patch makes vpnc log when it rekeys, the idea
being that if you get a random crash you can at least see whether it
happened during a rekey.
Cheers,
Gary
-------------- next part --------------
--- vpnc-0.3.3/tunip.c~ 2006-08-22 15:33:12.000000000 +0100
+++ vpnc-0.3.3/tunip.c 2006-08-22 15:33:48.000000000 +0100
@@ -1001,23 +1001,25 @@
chdir("/");
setsid();
- if (do_kill == 0 && !opt_nd) { /* do_kill != 0 -> rekeying */
- pid_t pid;
- if ((pid = fork()) < 0) {
- fprintf(stderr, "Warning, could not fork the child process!\n");
- } else if (pid == 0) {
- close(0); open("/dev/null", 0666, O_RDONLY);
- close(1); open("/dev/null", 0666, O_WRONLY);
- close(2); open("/dev/null", 0666, O_WRONLY);
- openlog("vpnc", LOG_PID, LOG_DAEMON);
- write_pidfile(pidfile);
+ if (do_kill == 0) { /* do_kill != 0 -> rekeying */
+ if (!opt_nd) {
+ pid_t pid;
+ if ((pid = fork()) < 0) {
+ fprintf(stderr, "Warning, could not fork the child process!\n");
+ } else if (pid == 0) {
+ close(0); open("/dev/null", 0666, O_RDONLY);
+ close(1); open("/dev/null", 0666, O_WRONLY);
+ close(2); open("/dev/null", 0666, O_WRONLY);
+ openlog("vpnc", LOG_PID, LOG_DAEMON);
+ write_pidfile(pidfile);
+ } else {
+ printf("VPNC started in background (pid: %d)...\n", (int)pid);
+ exit(0);
+ }
} else {
- printf("VPNC started in background (pid: %d)...\n", (int)pid);
- exit(0);
+ printf("VPNC started in foreground...\n");
+ openlog("vpnc", LOG_PID, LOG_DAEMON);
}
- } else {
- printf("VPNC started in foreground...\n");
- openlog("vpnc", LOG_PID, LOG_DAEMON);
}
do_kill = 0;
-------------- next part --------------
--- vpnc-0.3.3/tunip.c~ 2006-08-17 08:40:35.000000000 +0100
+++ vpnc-0.3.3/tunip.c 2006-08-17 10:46:55.000000000 +0100
@@ -878,6 +878,8 @@
if (pidfile)
unlink(pidfile); /* ignore errors */
syslog(LOG_NOTICE, "terminated");
+ } else {
+ syslog(LOG_NOTICE, "initiating rekey");
}
return rv;
}
@@ -1020,6 +1022,8 @@
printf("VPNC started in foreground...\n");
openlog("vpnc", LOG_PID, LOG_DAEMON);
}
+ } else {
+ syslog(LOG_NOTICE, "rekeying complete");
}
do_kill = 0;
More information about the vpnc-devel
mailing list