summaryrefslogtreecommitdiffstats
path: root/perl-install/security/level.pm
blob: 7ea08a52cb93bfc2c2214f1bc51584e765a5d28f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package security::level;

use strict;
use common;

my %level_list = (
                  0 => N("Welcome To Crackers"),
                  1 => N("Poor"),
                  2 => N("Standard"),
                  3 => N("High"),
                  4 => N("Higher"),
                  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 get {
    cat_("$::prefix/etc/profile")           =~ /export SECURE_LEVEL=(\d+)/ && $1 || #- 8.0 msec
    cat_("$::prefix/etc/profile.d/msec.sh") =~ /export SECURE_LEVEL=(\d+)/ && $1 || #- 8.1 msec
      ${{ getVarsFromSh("$::prefix/etc/sysconfig/msec") }}{SECURE_LEVEL}  || #- 8.2 msec
	$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 ? $run_level : 3, "\n";
    require run_program;
    run_program::rooted($::prefix, "/usr/sbin/msec", $run_level ? $run_level : 3);
}

1;