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 80ca8bd0f52b61accecc4d66296ec7d7648ee990 (commit)
via 858d8d9092dae3839e9129448d8a51937aebc909 (commit)
from 2bcff894ac444f5b8d5d6ab7d8c243974526d332 (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 80ca8bd0f52b61accecc4d66296ec7d7648ee990
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date: Wed Jun 29 19:58:01 2011 +0200
openvpnctrl: Fix some compiler warnings.
(Hopefully) no functional changes.
commit 858d8d9092dae3839e9129448d8a51937aebc909
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date: Wed Jun 29 19:51:24 2011 +0200
openvpnctrl: Create firewall rules properly if roadwarrior server is disabled.
-----------------------------------------------------------------------
Summary of changes:
src/misc-progs/openvpnctrl.c | 97 ++++++++++++++++++-----------------------
1 files changed, 43 insertions(+), 54 deletions(-)
Difference in files:
diff --git a/src/misc-progs/openvpnctrl.c b/src/misc-progs/openvpnctrl.c
index 68bbe2f..1a40c9a 100644
--- a/src/misc-progs/openvpnctrl.c
+++ b/src/misc-progs/openvpnctrl.c
@@ -122,6 +122,20 @@ connection *getConnections() {
return conn_first;
}
+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 = 0;
+ fscanf(fp, "%d", &pid);
+ fclose(fp);
+
+ return pid;
+}
+
void ovpnInit(void) {
// Read OpenVPN configuration
@@ -268,39 +282,34 @@ void createChain(char *chain) {
}
void createAllChains(void) {
- if (!((strcmp(enablered, "on")==0) || (strcmp(enableblue, "on")==0) || (strcmp(enableorange, "on")==0))){
- fprintf(stderr, "OpenVPN is not enabled on any interface\n");
- exit(1);
- } else {
- // create chain and chain references
- if (!strcmp(enableorange, "on")) {
- if (strlen(orangeif)) {
- createChain(OVPNORANGE);
- createChainReference(OVPNORANGE);
- } else {
- fprintf(stderr, "OpenVPN enabled on orange but no orange interface found\n");
- //exit(1);
- }
+ // create chain and chain references
+ if (!strcmp(enableorange, "on")) {
+ if (strlen(orangeif)) {
+ createChain(OVPNORANGE);
+ createChainReference(OVPNORANGE);
+ } else {
+ fprintf(stderr, "OpenVPN enabled on orange but no orange interface found\n");
+ //exit(1);
}
-
- if (!strcmp(enableblue, "on")) {
- if (strlen(blueif)) {
- createChain(OVPNBLUE);
- createChainReference(OVPNBLUE);
- } else {
- fprintf(stderr, "OpenVPN enabled on blue but no blue interface found\n");
- //exit(1);
- }
+ }
+
+ if (!strcmp(enableblue, "on")) {
+ if (strlen(blueif)) {
+ createChain(OVPNBLUE);
+ createChainReference(OVPNBLUE);
+ } else {
+ fprintf(stderr, "OpenVPN enabled on blue but no blue interface found\n");
+ //exit(1);
}
-
- if (!strcmp(enablered, "on")) {
- if (strlen(redif)) {
- createChain(OVPNRED);
- createChainReference(OVPNRED);
- } else {
- fprintf(stderr, "OpenVPN enabled on red but no red interface found\n");
- //exit(1);
- }
+ }
+
+ if (!strcmp(enablered, "on")) {
+ if (strlen(redif)) {
+ createChain(OVPNRED);
+ createChainReference(OVPNRED);
+ } else {
+ fprintf(stderr, "OpenVPN enabled on red but no red interface found\n");
+ //exit(1);
}
}
}
@@ -310,12 +319,6 @@ void setFirewallRules(void) {
char dport[STRING_SIZE] = "";
char dovpnip[STRING_SIZE] = "";
- /* check if it makes sence to proceed further */
- if (!((strcmp(enablered, "on")==0) || (strcmp(enableblue, "on")==0) || (strcmp(enableorange, "on")==0))){
- fprintf(stderr, "Config error, at least one device must be enabled\n");
- exit(1);
- }
-
kv = initkeyvalues();
if (!readkeyvalues(kv, CONFIG_ROOT "/ovpn/settings"))
{
@@ -369,7 +372,7 @@ void stopDaemon(void) {
char command[STRING_SIZE];
int pid = readPidFile("/var/run/openvpn.pid");
- if (pid == NULL) {
+ if (!pid > 0) {
exit(1);
}
@@ -433,20 +436,6 @@ 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;
@@ -467,10 +456,10 @@ void killNet2Net(char *name) {
}
char pidfile[STRING_SIZE];
- snprintf(&pidfile, STRING_SIZE - 1, "/var/run/%sn2n.pid", conn->name);
+ snprintf(pidfile, STRING_SIZE - 1, "/var/run/%sn2n.pid", conn->name);
int pid = readPidFile(pidfile);
- if (pid == NULL) {
+ if (!pid > 0) {
exit(1);
}
hooks/post-receive
--
IPFire 2.x development tree