]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/misc-progs/wirelessctrl.c
Merge branch 'master' into fifteen
[people/teissler/ipfire-2.x.git] / src / misc-progs / wirelessctrl.c
index 101661386aa8e3975f4d17dfc887010aa6a336d0..e3a1107c2bff927bb2aa6e6b4d49bcb0e51ff8db 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <signal.h>
-#include "setuid.h"
 #include <errno.h>
 
+#include "setuid.h"
+#include "netutil.h"
+
 FILE *fd = NULL;
 char blue_dev[STRING_SIZE] = "";
 char command[STRING_SIZE];
@@ -97,7 +99,7 @@ int main(void) {
        }
 
        /* restrict blue access tp the proxy port */
-       if (findkey(kv, "DROPPROXY", buffer) && strcmp(buffer,"off") == 0) {
+       if (findkey(kv, "DROPPROXY", buffer) && strcmp(buffer, "on") == 0) {
                /* Read the proxy values */
                if (!readkeyvalues(kv, CONFIG_ROOT "/proxy/settings") || !(findkey(kv, "PROXY_PORT", buffer))) {
                        fprintf(stderr, "Cannot read proxy settings\n");
@@ -111,7 +113,7 @@ int main(void) {
        }
 
        /* not allow blue to acces a samba server running on local fire*/
-       if(findkey(kv, "DROPSAMBA", buffer) && strcmp(buffer,"off")){
+       if (findkey(kv, "DROPSAMBA", buffer) && strcmp(buffer, "on") == 0) {
                snprintf(command, STRING_SIZE-1, "/sbin/iptables -A WIRELESSFORWARD -i %s -p tcp -m multiport --ports 135,137,138,139,445,1025 -j DROP -m comment --comment 'DROP_Wirelessforward'", blue_dev);
                safe_system(command);
                snprintf(command, STRING_SIZE-1, "/sbin/iptables -A WIRELESSINPUT -i %s -p tcp -m multiport --ports 135,137,138,139,445,1025 -j DROP -m comment --comment 'DROP_Wirelessinput'", blue_dev);
@@ -130,7 +132,7 @@ int main(void) {
                macaddress = strtok(NULL, ",");
                enabled = strtok(NULL, ",");
 
-               if (strncmp(enabled, "on", 2) != 0) {
+               if (strcmp(enabled, "on") == 0) {
                        /* both specified, added security */
                        if ((strlen(macaddress) == 17) && (VALID_IP_AND_MASK(ipaddress))) {
                                snprintf(command, STRING_SIZE-1, "/sbin/iptables -A WIRELESSINPUT -m mac --mac-source %s -s %s -i %s -j ACCEPT", macaddress, ipaddress, blue_dev);
@@ -157,13 +159,13 @@ int main(void) {
        }
 
        /* with this rule you can disable the logging of the dropped wireless input packets*/
-       if (!findkey(kv, "DROPWIRELESSINPUT", buffer) || strcmp(buffer,"off") == 0) {
+       if (findkey(kv, "DROPWIRELESSINPUT", buffer) && strcmp(buffer, "on") == 0) {
                snprintf(command, STRING_SIZE-1, "/sbin/iptables -A WIRELESSINPUT -i %s -j LOG --log-prefix 'DROP_Wirelessinput'", blue_dev);
                safe_system(command);
        }
 
        /* with this rule you can disable the logging of the dropped wireless forward packets*/
-       if (!findkey(kv, "DROPWIRELESSFORWARD", buffer) || strcmp(buffer,"off") == 0) {
+       if (findkey(kv, "DROPWIRELESSFORWARD", buffer) && strcmp(buffer, "on") == 0) {
                snprintf(command, STRING_SIZE-1, "/sbin/iptables -A WIRELESSFORWARD -i %s -j LOG --log-prefix 'DROP_Wirelessforward'", blue_dev);
                safe_system(command);
        }