From: Michael Tremer Date: Fri, 10 Apr 2015 11:27:32 +0000 (+0200) Subject: openvpn: Move remving files in /var/run to openvpnctrl X-Git-Tag: v2.17-core89~3^2~4 X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff_plain;h=187590f791bc7b96da5d70469783dae4a5bd00df;hp=831a5ef6ad5bbdc158a5fb40a4db78a7d419f082 openvpn: Move remving files in /var/run to openvpnctrl --- diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 5ab183bbbf..2d93304195 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -1237,9 +1237,6 @@ SETTINGS_ERROR: while ($file = glob("${General::swroot}/ovpn/n2nconf/*")) { system ("rm -rf $file"); } - while ($file = glob("/var/run/openvpn/*-n2n")) { - unlink $file; - } # Remove everything from the collectd configuration &writecollectdconf(); @@ -2362,8 +2359,6 @@ else if (-e "${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{'KEY'}}[1]") { rmdir ("${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{'KEY'}}[1]") || die "Kann Verzeichnis nicht loeschen: $!"; } - - unlink("/var/run/openvpn/$confighash{$cgiparams{'KEY'}}[1]-n2n"); } unlink ("${General::swroot}/ovpn/certs/$confighash{$cgiparams{'KEY'}}[1]cert.pem"); diff --git a/src/misc-progs/openvpnctrl.c b/src/misc-progs/openvpnctrl.c index 5d3f8af73b..bba84ca7cf 100644 --- a/src/misc-progs/openvpnctrl.c +++ b/src/misc-progs/openvpnctrl.c @@ -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) {