forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathkrb5-lib.pl
executable file
·57 lines (54 loc) · 1.14 KB
/
krb5-lib.pl
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
48
49
50
51
52
53
54
55
56
57
# krb5-lib.pl
# Common functions for the krb5 config
BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();
# get_config()
# Returns the krb5 config
sub get_config {
local (%conf, $section, $realm);
$section = $realm = "";
open(FILE, $config{'krb5_conf'});
while(<FILE>) {
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
if (/^\[/) { # section name
$section = $_;
$section =~ s/^\[([^\]]*)\]/\1/;
}
s/^\[.*$//;
next unless length;
my ($var, $value) = split(/\s*=\s*/, $_, 2);
if ($section eq "logging") {
if ($value =~ /^FILE:/) { $value =~ s/^FILE://; }
$var = $var . "_log";
}
if (($section eq "domain_realm") and ($value eq $realm)) {
$value = $var;
$var = "domain";
}
if ($section eq "realms") {
if ($value =~ /\{/ ) {
$realm = $var;
$value = $var;
$var = "realm";
}
if ($var eq "admin_server") {
my $port;
($value, $port) = split(':', $value, 2);
$conf{'admin_port'} = $port;
}
if ($var eq "kdc") {
my $port;
($value, $port) = split(':', $value, 2);
$conf{'kdc_port'} = $port;
}
}
$conf{$var} = $value;
}
close(FILE);
return %conf;
}
1;