diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-12-03 11:58:13 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-12-03 11:58:13 +0000 |
commit | eb025622c6e08ab766935e837849a2eb5afa5595 (patch) | |
tree | c01a9663bc634a66783d992e03da774d3e5260ad /perl-install/security | |
parent | f13d6e7d9e9fc11a04dabab5cb86486aaec500c6 (diff) | |
download | drakx-backup-do-not-use-eb025622c6e08ab766935e837849a2eb5afa5595.tar drakx-backup-do-not-use-eb025622c6e08ab766935e837849a2eb5afa5595.tar.gz drakx-backup-do-not-use-eb025622c6e08ab766935e837849a2eb5afa5595.tar.bz2 drakx-backup-do-not-use-eb025622c6e08ab766935e837849a2eb5afa5595.tar.xz drakx-backup-do-not-use-eb025622c6e08ab766935e837849a2eb5afa5595.zip |
(get_value): cleanup
Diffstat (limited to 'perl-install/security')
-rw-r--r-- | perl-install/security/msec.pm | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/perl-install/security/msec.pm b/perl-install/security/msec.pm index ca9d0ac9a..16774228b 100644 --- a/perl-install/security/msec.pm +++ b/perl-install/security/msec.pm @@ -84,17 +84,13 @@ sub get_default { } elsif ($category eq "checks") { $default_file = "$::prefix/var/lib/msec/security.conf" } - local *F; - open F, $default_file; - local $_; - while (<F>) { + foreach (cat_($default_file)) { if ($category eq 'functions') { (undef, $default_value) = split(/ /, $_) if /^$option/; } elsif ($category eq 'checks') { (undef, $default_value) = split(/=/, $_) if /^$option/; } } - close F; chop $default_value; $default_value; } @@ -102,36 +98,26 @@ sub get_default { sub get_value { my ($item, $category) = @_; my $value = ''; - my $found = 0; - my $item_file; - $item_file = "$::prefix/etc/security/msec/level.local" if $category eq 'functions'; - $item_file = $check_file if $category eq 'checks'; - - if (-e $item_file) { - local *F; - open F, $item_file; - local $_; - while (<F>) { - if (/^$item/) { - if ($category eq 'functions') { - my $i = $_; - (undef, $_) = split /\(/; - tr/()//d; - $value = $_; - $_ = $i; - } elsif ($category eq 'checks') { - (undef, $value) = split(/=/, $_); - } - chop $value; - $found = 1; - close F; - } - } - close F; - $value = "default" if $found == 0; + my $item_file = + $category eq 'functions' ? "$::prefix/etc/security/msec/level.local" : + $category eq 'checks' ? $check_file : ''; + + foreach (cat_($item_file)) { + /^$item/ or next; + + if ($category eq 'functions') { + my $i = $_; + (undef, $_) = split /\(/; + s/[()]//g; + $value = $_; + $_ = $i; + } elsif ($category eq 'checks') { + (undef, $value) = split(/=/, $_); + } + chop $value; + return $value; } - else { $value = "default" } - $value; + "default"; } # *********************************************** |