From ec73b15db1d1a7ea5c77e67847e0521b4e61d22e Mon Sep 17 00:00:00 2001 From: Christian Belisle Date: Mon, 10 Jun 2002 15:44:56 +0000 Subject: Initial commit --- perl-install/security/msec.pm | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 perl-install/security/msec.pm (limited to 'perl-install/security') diff --git a/perl-install/security/msec.pm b/perl-install/security/msec.pm new file mode 100644 index 000000000..da134217d --- /dev/null +++ b/perl-install/security/msec.pm @@ -0,0 +1,76 @@ +package security::msec; + +use common; +use log; + +sub get_user_list { + my @user_list = (); + + open(PASSWD, "/etc/passwd"); + while() { + my ($login_name, undef, $uid) = split(/:/,$_); + if($uid >= 500) { push(@user_list, $login_name); } + } + @user_list; +} + +sub add_config { + my ($prefix, $config_option, @values) = @_; + my $tmp_file = "$prefix/etc/security/msec/level.local.tmp"; + my $result = ""; + + $result = $config_option.'('; + foreach $value (@values) { + $result .= $value.','; + } + chop $result; + $result .= ')'; + + print "result is $result"; + open(TMP_CONFIG, '>>'.$tmp_file); + print TMP_CONFIG "$result\n"; + close TMP_CONFIG; +} + +sub commit_changes { + my ($prefix) = $_; + my $tmp_file = "$prefix/etc/security/msec/level.local.tmp"; + my $config_file = "$prefix/etc/security/msec/level.local"; + my %config_data; + my $config_option = ""; + + open (TMP_CONFIG, $tmp_file); + + if (!(-x $config_file)) { + open(CONFIG_FILE, '>'.$config_file); + print CONFIG_FILE "from mseclib import *\n\n"; + while() { print CONFIG_FILE $_; } + } + else { + open(CONFIG_FILE, $config_file); + while() { + if($_ =~ /\(/) { + ($config_option, undef) = split(/\(/, $_); + (undef, $config_data{$config_option}) = split(/\(/, $_); + } + } + close CONFIG_FILE; + + while() { + ($config_option, undef) = split(/\(/, $_); + (undef, $config_data{$config_option}) = split(/\(/, $_); + } + + open(CONFIG_FILE, '>'.$config_file); + print CONFIG_FILE "from mseclib import *\n\n"; + foreach $config_option (keys %config_data) { + print CONFIG_FILE $config_option.'('.$config_data{$config_option}.'\n'; + } + } + + close CONFIG_FILE; + close TMP_CONFIG; + + standalone::rm_rf($tmp_file); +} +1; -- cgit v1.2.1