Koozali.org: home of the SME Server

How to edit /etc/squid/squidguard.conf

Offline ghorst352

  • ****
  • 180
  • +0/-0
How to edit /etc/squid/squidguard.conf
« on: May 25, 2012, 05:47:40 PM »
Hi,

I am trying to figure out how to edit my squidguard.conf file but I am having trouble since this is under the template system.  Here is my dilemma:

I need to revise the last section of the squidguard.conf file which is the following:


 default {

        pass trusted !aggressive !drugs !gamble !hacking !porn !sex !untrusted !violence !warez all
        redirect http://192.168.1.23/cgi-bin/blocked.cgi?clientaddr=%a&clientname=%n&clientident=%i&clientgroup=%s&targetclass=%t&url=%u
    }


I need to add '!adult' to the list so it should look like this:


 default {

        pass trusted !adult !aggressive !drugs !gamble !hacking !porn !sex !untrusted !violence !warez all
        redirect http://192.168.1.23/cgi-bin/blocked.cgi?clientaddr=%a&clientname=%n&clientident=%i&clientgroup=%s&targetclass=%t&url=%u
    }


However this file cannot be edited as there is nice disclaimer on the top of this file which advises to read the Development Manual.  I do have the development manual and its referring to the template system which is fine and dandy.  I don't know how or what command to use to change this.  Now I did fine the exact file in the templates directory that is responsible I guess for this section of the file:

/etc/e-smith/templates/etc/squid/squidguard.conf/80-acl-default


Which looks like this:

    # default policy
    default \{
{
    my $googlesafe = $squidguard{googlesafe} || "disabled";

    if (defined $googlesafe && $googlesafe eq 'enabled')
    {
         $OUT .= "        # for google to be in \"safe mode\"\n";
         $OUT .= "        rewrite google\n";
    }
}
{
    my @sga = split(',', $squidguard{Squidguard_Allow} || '');
    my @sgb = split(',', $squidguard{Squidguard_Block} || '');
    my @sgf = split(',', $squidguard{ Squidguard_FullAccess} || '');

    return "none" unless (scalar @sga);
    return "none" unless (scalar @sgb);

    $OUT = '        pass ';
    $OUT .= join (' ', @sga);
    $OUT .= ' ';
    $OUT .= "!". join (' !', @sgb);
    $OUT .= " ". join (' ', @sgf);
}
        redirect http://{ "$LocalIP" }/cgi-bin/blocked.cgi?clientaddr=%a&clientname=%n&clientident=%i&clientgroup=%s&targetclass=%t&url=%u
    \}


I have absolutely know clue what I am suppose to do here?  Please help.
« Last Edit: May 25, 2012, 06:02:16 PM by bhay3s »

Offline Stefano

  • *
  • 10,836
  • +2/-0
Re: How to edit /etc/squid/squidguard.conf
« Reply #1 on: May 25, 2012, 06:40:24 PM »
please, post the output of

Code: [Select]
config show SquidGuard

I don't use squidguard, so you'd try other cases (i.e. squidguard, Squidguard)

Offline ghorst352

  • ****
  • 180
  • +0/-0
Re: How to edit /etc/squid/squidguard.conf
« Reply #2 on: May 25, 2012, 07:28:10 PM »
I figured it out, as follows:

config show squidguard

squidguard=service
    Blacklist=http://squidguard.shalla.de/Downloads/shallalist.tar.gz
    Squidguard_Allow=trusted
    Squidguard_Block=aggressive,drugs,gamble,hacking,porn,sex,untrusted,violence,warez
    Squidguard_FullAccess=all
    Squidguard_NoAccess=none
    status=enabled
[root@dixieprox ~]#


Now I know what the prop1 value is, which is Squidguard_Block

[root@dixieprox ~]# config setprop
/sbin/e-smith/db dbfile setprop key prop1 val1 [prop2 val2] [prop3 val3] ...


So now I issue the following command:

1.config setprop squidguard Squidguard_Block adult,aggressive,drugs,gamble,hacking,porn,sex,untrusted,violence,warez
2.expand-templates /etc/squid/squidguard.conf
3./etc/rc7.d/S90squid stop
4./etc/rc7.d/S90squid start

FINISHED.

I think I understand now how to interact with the SME template system.....  :grin:

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: How to edit /etc/squid/squidguard.conf
« Reply #3 on: May 25, 2012, 09:39:24 PM »
bhay3s

Quote
I think I understand now how to interact with the SME template system.....  :grin:

Yes well done. You were lucky to have db command support for the changes you wished to make, which does indeed make it very easy to do, which is indeed the whole point of having the db command and template system.

Remember for other situations where the template code does not support db commands to make changes, you can still edit the template fragment, but always do this by copying from the template tree to the custom template tree, and make changes to the custom template fragment(s).
Refer to this generic Howto for more details
http://wiki.contribs.org/Template_Tutorial
« Last Edit: May 25, 2012, 09:41:06 PM by mary »
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline ghorst352

  • ****
  • 180
  • +0/-0
Re: How to edit /etc/squid/squidguard.conf
« Reply #4 on: May 29, 2012, 03:41:29 PM »
Thanks Mary,

So let's assume that in this scenario that the db command was not supported with this particular instance.  How would you edit this fragment as seen below?

*Squidguard_Block is the property that needs to be updated, however where do you put the data??? in between || I would assume? Why is there no data in there now? 



    # default policy
    default \{
{
    my $googlesafe = $squidguard{googlesafe} || "disabled";

    if (defined $googlesafe && $googlesafe eq 'enabled')
    {
         $OUT .= "        # for google to be in \"safe mode\"\n";
         $OUT .= "        rewrite google\n";
    }
}
{
    my @sga = split(',', $squidguard{Squidguard_Allow} || '');
    my @sgb = split(',', $squidguard{Squidguard_Block} || '');
    my @sgf = split(',', $squidguard{ Squidguard_FullAccess} || '');

    return "none" unless (scalar @sga);
    return "none" unless (scalar @sgb);

    $OUT = '        pass ';
    $OUT .= join (' ', @sga);
    $OUT .= ' ';
    $OUT .= "!". join (' !', @sgb);
    $OUT .= " ". join (' ', @sgf);
}
        redirect http://{ "$LocalIP" }/cgi-bin/blocked.cgi?clientaddr=%a&clientname=%n&clientident=%i&clientgroup=%s&targetclass=%t&url=%u
    \}

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: How to edit /etc/squid/squidguard.conf
« Reply #5 on: May 29, 2012, 07:58:26 PM »
The general idea is that if you want to modify a template fragment you need to copy the tree to the -custom tree and model the path below that to the original path. Then you copy the fragment to this custom location and edit the copy. The copy will act as an override for the original template.

More information on the template system can be found in the wiki: http://wiki.contribs.org/Template_Tutorial

Or for more extensive information you can read the template section in the SME Server Developers Guide: http://wiki.contribs.org/SME_Server:Documentation:Developers_Manual#Configuration_file_templates
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: How to edit /etc/squid/squidguard.conf
« Reply #6 on: May 29, 2012, 08:44:16 PM »
bhay3s

You would not modify that particular template fragment code, because it is written to pull the data from the db settings and put that data into squidguard.conf
I'm not a coder so I may be wrong, but what that particular fragment code is saying is something like:
If disabled ignore, and disabled is the default setting in the absence of any db values, if enabled then read the db values.
So the settings in this case are put into the applicable db using the commands you determined.
When the template is expanded it reads the db values and builds squidguard.conf accordingly.

A template fragment that has values in it will look quite different as it does not get values from db's. Look at some other template fragments for examples.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline ghorst352

  • ****
  • 180
  • +0/-0
Re: How to edit /etc/squid/squidguard.conf
« Reply #7 on: May 29, 2012, 08:56:17 PM »
Thanks for both of your responses.