X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fmisc-progs%2Fopenvpnctrl.c;h=d20cced7743b80bdfc91c1875b54c2e33d0ca337;hb=aa2e56a531a44a932ea7c379fd7834043cc3e407;hp=462ce77cce0b99019a09cc8c3df75161b5e94924;hpb=5c3de120aabfaf150aa7303c4c3c92e3072da809;p=ipfire-2.x.git diff --git a/src/misc-progs/openvpnctrl.c b/src/misc-progs/openvpnctrl.c index 462ce77cce..d20cced774 100644 --- a/src/misc-progs/openvpnctrl.c +++ b/src/misc-progs/openvpnctrl.c @@ -73,6 +73,9 @@ void usage(void) printf(" -kn2n --kill-net-2-net\n"); printf(" kills all net2net connections\n"); printf(" you may pass a connection name to the switch to only start a specific one\n"); + printf(" -drrd --delete-rrd\n"); + printf(" Deletes the RRD data for a specific client\n"); + printf(" you need to pass a connection name (RW) to the switch to delete the directory (case sensitive)\n"); printf(" -d --display\n"); printf(" displays OpenVPN status to syslog\n"); printf(" -fwr --firewall-rules\n"); @@ -466,6 +469,10 @@ void startDaemon(void) { executeCommand(command); snprintf(command, STRING_SIZE-1, "/usr/sbin/openvpn --config /var/ipfire/ovpn/server.conf"); executeCommand(command); + snprintf(command, STRING_SIZE-1, "/bin/chown root.nobody /var/run/ovpnserver.log"); + executeCommand(command); + snprintf(command, STRING_SIZE-1, "/bin/chmod 644 /var/run/ovpnserver.log"); + executeCommand(command); } } @@ -565,6 +572,28 @@ int killNet2Net(char *name) { return 0; } +int deleterrd(char *name) { + connection *conn = getConnections(); + + char rrd_file[STRING_SIZE]; + snprintf(rrd_file, STRING_SIZE - 1, "/var/log/rrd/collectd/localhost/openvpn-%s/if_octets.rrd", name); + + char rrd_dir[STRING_SIZE]; + snprintf(rrd_dir, STRING_SIZE - 1, "/var/log/rrd/collectd/localhost/openvpn-%s", name); + + while(conn) { + /* Find only RW-Connections with the given name. */ + if (((strcmp(conn->type, "host") == 0) && (strcmp(conn->name, name) == 0))) { + remove(rrd_file); + remove(rrd_dir); + return 0; + } + conn = conn->next; + } + + return 1; +} + void startAllNet2Net() { int exitcode = 0, _exitcode = 0; @@ -634,6 +663,10 @@ int main(int argc, char *argv[]) { else if( (strcmp(argv[1], "-kn2n") == 0) || (strcmp(argv[1], "--kill-net-2-net") == 0) ) { killNet2Net(argv[2]); return 0; + } + else if( (strcmp(argv[1], "-drrd") == 0) || (strcmp(argv[1], "--delete-rrd") == 0) ) { + deleterrd(argv[2]); + return 0; } else { usage(); return 1;