Project

General

Profile

Bug #4088 » squidguard-src-disabled-and-log-statements_1.9.15.diff

Fix for both problems, pfsense pkg 1.9.15. - Volker Kuhlmann, 09/28/2015 07:06 PM

View differences:

/usr/local/pkg/squidguard_configurator.inc.orig_5.2 2015-09-29 08:38:33.000000000 +1300
900 900
    }
901 901

  
902 902
    # --- Sources ---
903
    #$sgconf[] = "# # src begin";
903 904
    if ($squidguard_config[F_SOURCES]) {
904 905
        $temp_str = '';
905 906
        foreach($squidguard_config[F_SOURCES][F_ITEM] as $src) {
907
            # Don't write out the source if the ACL is disabled! Or comment it out.
908
            # Squidguard 1.4 treats the source as "always pass" otherwise!!
909
            $srclinepref = "";
910
            $srccomment = "";
911
            foreach($squidguard_config[F_ACLS][F_ITEM] as $acl) {
912
                if ($acl[F_NAME] == $src[F_NAME]) {
913
                    if ($acl[F_DISABLED]) {
914
                        $srclinepref = "## ";
915
                        $srccomment = "Commented out because it makes SquidGuard pass all!
916
" . $srclinepref;
917
                    }
918
                    break;
919
                }
920
            }
906 921
            $sg_tag->clear();
907
            $sg_tag->set("src", $src[F_NAME], "", $src[F_DESCRIPTION]);
922
            $sg_tag->set("src", $src[F_NAME], "", $srccomment . $src[F_DESCRIPTION], $srclinepref);
908 923

  
909 924
            # separate IP, domains, usernames
910 925
            if (strpos(trim($src[F_SOURCE]), 'ldapusersearch') === false) {
......
934 949
        $temp_str = !empty($temp_str) ? $temp_str : "Nothing.";
935 950
        sg_addlog("sg_create_config", "Add sources: $temp_str", SQUIDGUARD_INFO);
936 951
    }
952
    #$sgconf[] = "# # src end";
937 953

  
938 954
    # --- Blacklist ---
939 955
    # Note! Blacklist must be added to config permanently. It's need for rebuild DB now
......
1076 1092
        $temp_str = '';
1077 1093
        $log_entr_added = '';
1078 1094
        foreach($squidguard_config[F_ACLS][F_ITEM] as $acl) {
1079
            if (!$acl[F_DISABLED]) {
1095
            #if (!$acl[F_DISABLED]) {
1096
            $srclinepref = "";
1097
            if ($acl[F_DISABLED]) {
1098
                $srclinepref = "## ";
1099
            }
1080 1100
                $sg_acltag = new TSgTag;
1081
                $sg_acltag->set($acl[F_NAME], "", $acl[F_TIMENAME], $acl[F_DESCRIPTION]);
1101
                $sg_acltag->set($acl[F_NAME], "", $acl[F_TIMENAME], $acl[F_DESCRIPTION], $srclinepref);
1082 1102

  
1083 1103
                # delete blacklist entries from 'pass' if blacklist disabled
1084 1104
                if ($squidguard_config[F_BLACKLISTENABLED] !== 'on') {
......
1102 1122
                $sg_acltag->items[] = "redirect " . sg_redirector_base_url($acl[F_REDIRECT], $acl[F_RMOD]);
1103 1123
                if ($acl[F_REWRITENAME])
1104 1124
                    $sg_acltag->items[] = "rewrite {$acl[F_REWRITENAME]}";
1105
                if ($squidguard_config[F_ENABLELOG] == 'on' ) {
1106
                    if ($acl[F_LOG])
1107
                        $sg_acltag->items[] = "log " . SQUIDGUARD_LOGFILE;
1108
                }
1125
                # Squidguard 1.4 doesn't allow a log statement here.
1126
                #if ($squidguard_config[F_ENABLELOG] == 'on' ) {
1127
                #    if ($acl[F_LOG])
1128
                #        $sg_acltag->items[] = "log " . SQUIDGUARD_LOGFILE;
1129
                #}
1109 1130

  
1110 1131
                # overtime
1111 1132
                if ($acl[F_TIMENAME]) {
......
1115 1136
                        $sg_acltag->items[] = "redirect " . sg_redirector_base_url($acl[F_OVERREDIRECT], $acl[F_RMOD]);
1116 1137
                    if ($acl[F_OVERREWRITENAME])
1117 1138
                        $sg_acltag->items[] = "rewrite {$acl[F_OVERREWRITENAME]}";
1118
                    if ($squidguard_config[F_ENABLELOG] == 'on' ) {
1119
                        if ($acl[F_LOG])
1120
                            $sg_acltag->items[] = "log " . SQUIDGUARD_LOGFILE;
1121
                    }
1139
                # Squidguard 1.4 doesn't allow a log statement here.
1140
                #    if ($squidguard_config[F_ENABLELOG] == 'on' ) {
1141
                #        if ($acl[F_LOG])
1142
                #            $sg_acltag->items[] = "log " . SQUIDGUARD_LOGFILE;
1143
                #    }
1122 1144
                }
1123 1145
                $sg_tag->items[] = $sg_acltag;
1124
            }
1146
            #}
1125 1147
            $log_entr_added .= " {$acl[F_NAME]};";
1126 1148
        }
1127 1149
        # log
......
2447 2469
    var $time;
2448 2470
    var $items;
2449 2471
    var $desc;
2472
    var $linepref;
2450 2473

  
2451 2474
    function __construct() {
2452 2475
        $this->clear();
......
2458 2481
        $this->time   = '';
2459 2482
        $this->items  = array();
2460 2483
        $this->desc   = '';
2484
        $this->linepref = '';
2461 2485
    }
2462 2486

  
2463
    function set($tag, $name, $time, $desc) {
2487
    function set($tag, $name, $time, $desc, $linepref = "") {
2464 2488
        $this->tag    = $tag;
2465 2489
        $this->name   = $name;
2466 2490
        $this->time   = $time;
2467 2491
        $this->desc   = $desc;
2492
        $this->linepref = $linepref;
2468 2493
    }
2469 2494

  
2470 2495
    function tag_text($offset = 0) {
2471 2496
        $str = array();
2472
        $off = str_repeat("\t", $offset);
2497
        $off = $this->linepref . str_repeat("\t", $offset);
2473 2498

  
2474 2499
        $str[] = $off . "# {$this->desc}";
2475 2500
        if (empty($this->time))
(2-2/2)