From eb025622c6e08ab766935e837849a2eb5afa5595 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 3 Dec 2002 11:58:13 +0000 Subject: (get_value): cleanup --- perl-install/security/msec.pm | 54 ++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 34 deletions(-) (limited to 'perl-install/security') 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 () { + 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 () { - 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"; } # *********************************************** -- cgit v1.2.1