Koozali.org: home of the SME Server
Obsolete Releases => SME 7.x Contribs => Topic started by: ghorst352 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.
-
please, post the output of
config show SquidGuard
I don't use squidguard, so you'd try other cases (i.e. squidguard, Squidguard)
-
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:
-
bhay3s
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
-
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
\}
-
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
-
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.
-
Thanks for both of your responses.