public inbox for ipfire-scm@lists.ipfire.org
 help / color / mirror / Atom feed
From: git@ipfire.org
To: ipfire-scm@lists.ipfire.org
Subject: [IPFire-SCM] [git.ipfire.org] IPFire 2.x development tree branch, next, updated. 99b01b84851bcdba605e9d73f727b62b9edde7a7
Date: Sat, 07 Jan 2012 22:22:18 +0100	[thread overview]
Message-ID: <20120107212218.C933B200BA@argus.ipfire.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 5225 bytes --]

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, next has been updated
       via  99b01b84851bcdba605e9d73f727b62b9edde7a7 (commit)
      from  1bafefd5fb6ad91c5d2aeed3122d45e98139f5a5 (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 99b01b84851bcdba605e9d73f727b62b9edde7a7
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date:   Sat Jan 7 22:21:08 2012 +0100

    openvpn: Fix starting/stopping errors in the control binary.
    
    net2net connection were not started when roadwarrior connections
    were existant.

-----------------------------------------------------------------------

Summary of changes:
 src/misc-progs/openvpnctrl.c |   65 +++++++++++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 14 deletions(-)

Difference in files:
diff --git a/src/misc-progs/openvpnctrl.c b/src/misc-progs/openvpnctrl.c
index 5207c24..e7b128a 100644
--- a/src/misc-progs/openvpnctrl.c
+++ b/src/misc-progs/openvpnctrl.c
@@ -25,12 +25,13 @@ char enableorange[STRING_SIZE] = "off";
 char OVPNRED[STRING_SIZE] = "OVPN";
 char OVPNBLUE[STRING_SIZE] = "OVPN_BLUE_";
 char OVPNORANGE[STRING_SIZE] = "OVPN_ORANGE_";
-char WRAPPERVERSION[STRING_SIZE] = "ipfire-2.2.1";
+char WRAPPERVERSION[STRING_SIZE] = "ipfire-2.2.2";
 
 struct connection_struct {
 	char name[STRING_SIZE];
 	char type[STRING_SIZE];
 	char proto[STRING_SIZE];
+	char status[STRING_SIZE];
 	int port;
 	struct connection_struct *next;
 };
@@ -125,7 +126,9 @@ connection *getConnections() {
 			}
 			*resultptr = '\0';
 
-			if (count == 2) {
+			if (count == 1) {
+				strcpy(conn_curr->status, result);
+			} else if (count == 2) {
 				strcpy(conn_curr->name, result);
 			} else if (count == 4) {
 				strcpy(conn_curr->type, result);
@@ -423,7 +426,7 @@ void startDaemon(void) {
 	}
 }
 
-void startNet2Net(char *name) {
+int startNet2Net(char *name) {
 	connection *conn = NULL;
 	connection *conn_iter;
 
@@ -439,9 +442,16 @@ void startNet2Net(char *name) {
 
 	if (conn == NULL) {
 		fprintf(stderr, "Connection not found.\n");
-		exit(1);
+		return 1;
+	}
+
+	if (strcmp(conn->status, "on") != 0) {
+		fprintf(stderr, "Connection '%s' is not enabled.\n", conn->name);
+		return 1;
 	}
 
+	fprintf(stderr, "Starting connection %s...\n", conn->name);
+
 	char configfile[STRING_SIZE];
 	snprintf(configfile, STRING_SIZE - 1, CONFIG_ROOT "/ovpn/n2nconf/%s/%s.conf",
 		conn->name, conn->name);
@@ -450,7 +460,7 @@ void startNet2Net(char *name) {
 	if (fp == NULL) {
 		fprintf(stderr, "Could not find configuration file for connection '%s' at '%s'.\n",
 			conn->name, configfile);
-		exit(2);
+		return 2;
 	}
 	fclose(fp);
 
@@ -462,9 +472,11 @@ void startNet2Net(char *name) {
 	executeCommand(command);
 	snprintf(command, STRING_SIZE-1, "/usr/sbin/openvpn --config %s", configfile);
 	executeCommand(command);
+
+	return 0;
 }
 
-void killNet2Net(char *name) {
+int killNet2Net(char *name) {
 	connection *conn = NULL;
 	connection *conn_iter;
 
@@ -480,7 +492,7 @@ void killNet2Net(char *name) {
 
 	if (conn == NULL) {
 		fprintf(stderr, "Connection not found.\n");
-		exit(1);
+		return 1;
 	}
 
 	char pidfile[STRING_SIZE];
@@ -488,39 +500,64 @@ void killNet2Net(char *name) {
 
 	int pid = readPidFile(pidfile);
 	if (!pid > 0) {
-		exit(1);
+		fprintf(stderr, "Could not read pid file of connection %s.", conn->name);
+		return 1;
 	}
 
-	fprintf(stderr, "Killing PID %d.\n", pid);
+	fprintf(stderr, "Killing connection %s (PID %d)...\n", conn->name, pid);
 	kill(pid, SIGTERM);
 
 	char command[STRING_SIZE];
 	snprintf(command, STRING_SIZE - 1, "/bin/rm -f %s", pidfile);
 	executeCommand(command);
 
-	exit(0);
+	return 0;
 }
 
 void startAllNet2Net() {
+	int exitcode = 0, _exitcode = 0;
+
 	connection *conn = getConnections();
 
 	while(conn) {
-		startNet2Net(conn->name);
+		/* Skip all connections that are not of type "net" or disabled. */
+		if ((strcmp(conn->type, "net") != 0) || (strcmp(conn->status, "on") != 0)) {
+			conn = conn->next;
+			continue;
+		}
+
+		_exitcode = startNet2Net(conn->name);
 		conn = conn->next;
+
+		if (_exitcode > exitcode) {
+			exitcode = _exitcode;
+		}
 	}
 
-	exit(0);
+	exit(exitcode);
 }
 
 void killAllNet2Net() {
+	int exitcode = 0, _exitcode = 0;
+
 	connection *conn = getConnections();
 
 	while(conn) {
-		killNet2Net(conn->name);
+		/* Skip all connections that are not of type "net". */
+		if (strcmp(conn->type, "net") != 0) {
+			conn = conn->next;
+			continue;
+		}
+
+		_exitcode = killNet2Net(conn->name);
 		conn = conn->next;
+
+		if (_exitcode > exitcode) {
+			exitcode = _exitcode;
+		}
 	}
 
-	exit(0);
+	exit(exitcode);
 }
 
 void displayopenvpn(void) {


hooks/post-receive
--
IPFire 2.x development tree

                 reply	other threads:[~2012-01-07 21:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120107212218.C933B200BA@argus.ipfire.org \
    --to=git@ipfire.org \
    --cc=ipfire-scm@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox