diff options
Diffstat (limited to 'bin')
-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"; |