]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/misc-progs/openvpnctrl.c
openvpn: Move remving files in /var/run to openvpnctrl
[people/pmueller/ipfire-2.x.git] / src / misc-progs / openvpnctrl.c
index 5d3f8af73b43ba7b8c6f734ae74648c93bfae567..bba84ca7cf8972bf0a457b793738d7e1a9f31145 100644 (file)
@@ -46,6 +46,18 @@ struct connection_struct {
 
 typedef struct connection_struct connection;
 
+static int recursive_remove_callback(const char* fpath, const struct stat* sb, int typeflag, struct FTW* ftwbuf) {
+       int rv = remove(fpath);
+       if (rv)
+               perror(fpath);
+
+       return rv;
+}
+
+static int recursive_remove(const char* path) {
+       return nftw(path, recursive_remove_callback, 64, FTW_DEPTH | FTW_PHYS);
+}
+
 void exithandler(void)
 {
        if(kv)
@@ -539,6 +551,7 @@ int startNet2Net(char *name) {
 int killNet2Net(char *name) {
        connection *conn = NULL;
        connection *conn_iter;
+       int rc = 0;
 
        conn_iter = getConnections();
 
@@ -571,20 +584,13 @@ int killNet2Net(char *name) {
        snprintf(command, STRING_SIZE - 1, "/bin/rm -f %s", pidfile);
        executeCommand(command);
 
-       return 0;
-}
-
-
-static int recursive_remove_callback(const char* fpath, const struct stat* sb, int typeflag, struct FTW* ftwbuf) {
-       int rv = remove(fpath);
-       if (rv)
-               perror(fpath);
+       char runfile[STRING_SIZE];
+       snprintf(runfile, STRING_SIZE - 1, "/var/run/openvpn/%s-n2n", conn->name);
+       rc = recursive_remove(runfile);
+       if (rc)
+               perror(runfile);
 
-       return rv;
-}
-
-static int recursive_remove(const char* path) {
-       return nftw(path, recursive_remove_callback, 64, FTW_DEPTH | FTW_PHYS);
+       return 0;
 }
 
 int deleterrd(char *name) {