diff options
author | Olivier Blin <oblin@mandriva.com> | 2008-03-26 17:42:02 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2008-03-26 17:42:02 +0000 |
commit | 0c20681119306b7e472b4d9eae07a2bd2cbb9c1e (patch) | |
tree | e0605dbe250b69ecd823f90df12510f27fd7e668 | |
parent | d0e748cb35047f3031cdc23a2fe5e7e3aaac5c87 (diff) | |
download | drakguard-0c20681119306b7e472b4d9eae07a2bd2cbb9c1e.tar drakguard-0c20681119306b7e472b4d9eae07a2bd2cbb9c1e.tar.gz drakguard-0c20681119306b7e472b4d9eae07a2bd2cbb9c1e.tar.bz2 drakguard-0c20681119306b7e472b4d9eae07a2bd2cbb9c1e.tar.xz drakguard-0c20681119306b7e472b4d9eae07a2bd2cbb9c1e.zip |
read and write dansguardian naughtyness setting
-rwxr-xr-x | bin/drakguard | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/drakguard b/bin/drakguard index e782589..c4bd699 100755 --- a/bin/drakguard +++ b/bin/drakguard @@ -172,6 +172,8 @@ sub unwhitelist { sub quit_gui() { Gtk2->main_quit } sub load() { + my $guardian = read_dansguardian(); + $level = {reverse %dansguardian_levels}->{$guardian->{naughtynesslimit}}; $level ||= {reverse %dansguardian_levels}->{"Normal"}; $enable = services::starts_on_boot('dansguardian'); } @@ -190,6 +192,7 @@ sub save() { apply_blacklist(); apply_whitelist(); + write_dansguardian(); enable_transparent_proxy($proxy_port); services::set_status($_, $enable) foreach qw(squid dansguardian); @@ -213,6 +216,28 @@ sub enable_transparent_proxy { } $network::squid::squid_conf_file; } +#- mostly duplicated for MDK::Common::System::getVarsFromSh +sub read_dansguardian() { + my $guardian = {}; + foreach (cat_($dansguardian_file)) { + s/#.*//; + s/^\s*//; + my ($v, $val) = /^(\w+)\s*=\s*(.*)/ or next; + $val = $1 if $val =~ /^"(.*)"$/ || $val =~ /^'(.*)'$/; + $guardian->{$v} = $val; + } + $guardian; +} + +sub write_dansguardian() { + my $done; + my $to_add = "naughtynesslimit = $level\n"; + substInFile { + $done = 1 if s|^\s*naughtynesslimit\b.*\n|$to_add|; + $_ .= $to_add if eof && !$done; + } $dansguardian_file; +} + sub include_guardian_file { my ($guardian_file, $external_file, $o_category) = @_; my $to_add = ".Include<$external_file>\n"; |