This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree".
The branch, openvpn-n2n has been updated via 2bcff894ac444f5b8d5d6ab7d8c243974526d332 (commit) from 39877197d6f99832c9732edcf72a11fbddf43a30 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 2bcff894ac444f5b8d5d6ab7d8c243974526d332 Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jun 25 17:57:57 2011 +0200
openvpnctrl: Support killing only the roadwarrior server.
-----------------------------------------------------------------------
Summary of changes: src/misc-progs/openvpnctrl.c | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-)
Difference in files: diff --git a/src/misc-progs/openvpnctrl.c b/src/misc-progs/openvpnctrl.c index 847a3e2..68bbe2f 100644 --- a/src/misc-progs/openvpnctrl.c +++ b/src/misc-progs/openvpnctrl.c @@ -368,12 +368,16 @@ void setFirewallRules(void) { void stopDaemon(void) { char command[STRING_SIZE];
- snprintf(command, STRING_SIZE - 1, "/bin/killall openvpn"); - executeCommand(command); + int pid = readPidFile("/var/run/openvpn.pid"); + if (pid == NULL) { + exit(1); + } + + fprintf(stderr, "Killing PID %d.\n", pid); + kill(pid, SIGTERM); + snprintf(command, STRING_SIZE - 1, "/bin/rm -f /var/run/openvpn.pid"); executeCommand(command); - snprintf(command, STRING_SIZE-1, "/sbin/modprobe -r tun"); - executeCommand(command); }
void startDaemon(void) { @@ -429,6 +433,20 @@ void startNet2Net(char *name) { executeCommand(command); }
+int readPidFile(const char *pidfile) { + FILE *fp = fopen(pidfile, "r"); + if (fp == NULL) { + fprintf(stderr, "PID file not found: '%s'\n", pidfile); + exit(1); + } + + int pid = NULL; + fscanf(fp, "%d", &pid); + fclose(fp); + + return pid; +} + void killNet2Net(char *name) { connection *conn = NULL; connection *conn_iter; @@ -451,17 +469,11 @@ void killNet2Net(char *name) { char pidfile[STRING_SIZE]; snprintf(&pidfile, STRING_SIZE - 1, "/var/run/%sn2n.pid", conn->name);
- FILE *fp = fopen(pidfile, "r"); - if (fp == NULL) { - fprintf(stderr, "Could not determine PID for connection '%s'.\n", conn->name); - fprintf(stderr, "PID file not found: '%s'\n", pidfile); + int pid = readPidFile(pidfile); + if (pid == NULL) { exit(1); }
- int pid; - fscanf(fp, "%d", &pid); - fclose(fp); - fprintf(stderr, "Killing PID %d.\n", pid); kill(pid, SIGTERM);
hooks/post-receive -- IPFire 2.x development tree