]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/misc-progs/ipsecctrl.c
OpenVPN gefixt.
[people/pmueller/ipfire-2.x.git] / src / misc-progs / ipsecctrl.c
index 63e042a91121a1ecf785e09cb1e2a2acc6e66ac5..50d49bac357d41668071df4721695eb51e1dedd4 100644 (file)
@@ -121,7 +121,7 @@ void add_alias_interfaces(char *configtype,
 
        /* Check for CONFIG_TYPE=2 or 3 i.e. RED ethernet present. If not,
        * exit gracefully.  This is not an error... */
-       if (!((strcmp(configtype, "2")==0) || (strcmp(configtype, "3")==0) || (strcmp(configtype, "6")==0) || (strcmp(configtype, "7")==0)))
+       if (!((strcmp(configtype, "1")==0) || (strcmp(configtype, "2")==0) || (strcmp(configtype, "3")==0) || (strcmp(configtype, "4")==0)))
                return;
 
         /* Now check the RED_TYPE - aliases only work with STATIC. */
@@ -278,7 +278,17 @@ int main(int argc, char *argv[]) {
        }
        if (!(initsetuid()))
                exit(1);
-
+               
+ FILE *file = NULL;
+               
+ /* Get vpnwatch pid */
+
+ if (file = fopen("/var/run/vpn-watch.pid", "r")) {
+ safe_system("kill -9 $(cat /var/run/vpn-watch.pid)");
+ safe_system("unlink /var/run/vpn-watch.pid)");
+ }
+ close(file);
        /* FIXME: workaround for pclose() issue - still no real idea why
         * this is happening */
        signal(SIGCHLD, SIG_DFL);
@@ -286,13 +296,12 @@ int main(int argc, char *argv[]) {
        /* handle operations that doesn't need start the ipsec system */
        if (argc == 2) {
                if (strcmp(argv[1], "D") == 0) {
-                       safe_system("/usr/local/bin/vpn-watch --stop");
                        ipsec_norules();
                        /* Only shutdown pluto if it really is running */
                        int fd;
                        /* Get pluto pid */
                        if ((fd = open("/var/run/pluto.pid", O_RDONLY)) != -1) {
-                               safe_system("/etc/rc.d/ipsec stop 2> /dev/null >/dev/null");
+                               safe_system("/etc/rc.d/init.d/ipsec stop 2> /dev/null >/dev/null");
                                close(fd);
                        }
                        exit(0);
@@ -304,9 +313,6 @@ int main(int argc, char *argv[]) {
                }
        }
 
-       /* stop the watch script as soon as possible */
-       safe_system("/usr/local/bin/vpn-watch --stop");
-
        /* clear iptables vpn rules */
        ipsec_norules();
 
@@ -352,7 +358,6 @@ int main(int argc, char *argv[]) {
        char if_orange[STRING_SIZE] = "";
        char if_blue[STRING_SIZE] = "";
        char s[STRING_SIZE];
-       FILE *file = NULL;
 
        if (!(file = fopen(CONFIG_ROOT "/vpn/config", "r"))) {
                fprintf(stderr, "Couldn't open vpn settings file");
@@ -441,9 +446,8 @@ int main(int argc, char *argv[]) {
        if ((argc == 2) && strcmp(argv[1], "S") == 0) {
                load_modules();
                safe_system("/usr/sbin/ipsec tncfg --clear >/dev/null");
-               safe_system("/etc/rc.d/ipsec restart >/dev/null");
+               safe_system("/etc/rc.d/init.d/ipsec restart >/dev/null");
                add_alias_interfaces(configtype, redtype, if_red, (enable_red+enable_green+enable_orange+enable_blue) >>1 );
-               safe_system("/usr/local/bin/vpn-watch --start");
                exit(0);
        }
 
@@ -494,6 +498,6 @@ int main(int argc, char *argv[]) {
                }
        }
        fclose(file);
-       safe_system("/usr/local/bin/vpn-watch --start");
+       safe_system("/usr/local/bin/vpn-watch &");
        return 0;
 }