summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/security/level.pm43
-rwxr-xr-xperl-install/standalone/draksec2
2 files changed, 12 insertions, 33 deletions
diff --git a/perl-install/security/level.pm b/perl-install/security/level.pm
index 36d5d19cf..368ab4c5a 100644
--- a/perl-install/security/level.pm
+++ b/perl-install/security/level.pm
@@ -2,6 +2,8 @@ package security::level;
use strict;
use common;
+use run_program;
+
my %level_list = (
0 => N("Welcome To Crackers"),
@@ -12,16 +14,13 @@ my %level_list = (
5 => N("Paranoid"),
);
-my @sec_levels = map { $level_list{$_} } (0..5); # enforce order
-
-
-sub get_common_list {
- map { $level_list{$_} } (2, 3, 4);
-}
-
-sub get_full_list {
-
+sub to_string { $level_list{$_[0]} }
+sub from_string {
+ my %sec_levels = reverse %level_list;
+ $sec_levels{$_[0]} || 2;
}
+sub get_string { to_string(get() || 2) }
+sub get_common_list { map { to_string($_) } (2, 3, 4) }
sub get {
cat_("$::prefix/etc/profile") =~ /export SECURE_LEVEL=(\d+)/ && $1 || #- 8.0 msec
@@ -30,30 +29,9 @@ sub get {
$ENV{SECURE_LEVEL};
}
-
-sub get_string {
- return $sec_levels[get()] || 2
-}
-
sub set {
- my %sec_levels = reverse %level_list;
- my $run_level = $sec_levels{$_[0]};
- print "set level: $_[0] -> $run_level\n";
- print $::prefix, "/usr/sbin/msec ", $run_level || 3, "\n";
- require run_program;
- run_program::rooted($::prefix, "/usr/sbin/msec", $run_level || 3);
-}
-
-sub to_string {
- my %l = (
- 0 => N("Welcome To Crackers"),
- 1 => N("Poor"),
- 2 => N("Standard"),
- 3 => N("High"),
- 4 => N("Higher"),
- 5 => N("Paranoid"),
- );
- $l{$_[0]};
+ my ($security) = @_;
+ run_program::rooted($::prefix, 'msec', '-o', 'run_commands=0', '-o', 'log=stderr', $security || 3);
}
sub level_choose {
@@ -88,4 +66,5 @@ connections from many clients. Note: if your machine is only a client on the Int
);
}
+
1;
diff --git a/perl-install/standalone/draksec b/perl-install/standalone/draksec
index d82a9d361..8ec8d4dda 100755
--- a/perl-install/standalone/draksec
+++ b/perl-install/standalone/draksec
@@ -213,7 +213,7 @@ my $bok = gtksignal_connect(new Gtk2::Button(N("Ok")),
if ($seclevel_value ne security::level::get_string()) {
$w = wait_msg(N("Please wait, setting security level..."));
log::explanations("Setting security level to $seclevel_value");
- security::level::set($seclevel_value);
+ security::level::set(security::level::from_string($seclevel_value));
remove_wait_msg($w);
}