summaryrefslogtreecommitdiffstats
path: root/perl-install/security
diff options
context:
space:
mode:
authorChristian Belisle <cbelisle@mandriva.com>2002-06-10 15:44:56 +0000
committerChristian Belisle <cbelisle@mandriva.com>2002-06-10 15:44:56 +0000
commitec73b15db1d1a7ea5c77e67847e0521b4e61d22e (patch)
tree4ae6190f6a387070eabacc4ef7c0ecd8c70d4cec /perl-install/security
parentfe986507167101d7fb0c31100f52de65e80ec4f4 (diff)
downloaddrakx-backup-do-not-use-ec73b15db1d1a7ea5c77e67847e0521b4e61d22e.tar
drakx-backup-do-not-use-ec73b15db1d1a7ea5c77e67847e0521b4e61d22e.tar.gz
drakx-backup-do-not-use-ec73b15db1d1a7ea5c77e67847e0521b4e61d22e.tar.bz2
drakx-backup-do-not-use-ec73b15db1d1a7ea5c77e67847e0521b4e61d22e.tar.xz
drakx-backup-do-not-use-ec73b15db1d1a7ea5c77e67847e0521b4e61d22e.zip
Initial commit
Diffstat (limited to 'perl-install/security')
-rw-r--r--perl-install/security/msec.pm76
1 files changed, 76 insertions, 0 deletions
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(<PASSWD>) {
+ 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(<TMP_CONFIG>) { print CONFIG_FILE $_; }
+ }
+ else {
+ open(CONFIG_FILE, $config_file);
+ while(<CONFIG_FILE>) {
+ if($_ =~ /\(/) {
+ ($config_option, undef) = split(/\(/, $_);
+ (undef, $config_data{$config_option}) = split(/\(/, $_);
+ }
+ }
+ close CONFIG_FILE;
+
+ while(<TMP_CONFIG>) {
+ ($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;