Handle hostnames with upper-case letters
[webmin.git] / krb5 / krb5-lib.pl
1 # krb5-lib.pl
2 # Common functions for the krb5 config
3
4 BEGIN { push(@INC, ".."); };
5 use WebminCore;
6 &init_config();
7
8 # get_config()
9 # Returns the krb5 config
10 sub get_config {
11     local (%conf, $section, $realm);
12     $section = $realm = "";
13     open(FILE, $config{'krb5_conf'});
14     while(<FILE>) {
15         chomp;
16         s/#.*//;
17         s/^\s+//;
18         s/\s+$//;
19         if (/^\[/) { # section name
20             $section = $_;
21             $section =~ s/^\[([^\]]*)\]/\1/;
22         }
23         s/^\[.*$//;
24         next unless length;
25         my ($var, $value) = split(/\s*=\s*/, $_, 2);
26         if ($section eq "logging") {
27             if ($value =~ /^FILE:/) { $value =~ s/^FILE://; }
28             $var = $var . "_log";
29         }
30         if (($section eq "domain_realm") and ($value eq $realm)) {
31             $value = $var;
32             $var = "domain";
33         }
34         if ($section eq "realms") {
35             if ($value =~ /\{/ ) {
36                 $realm = $var;
37                 $value = $var;
38                 $var = "realm";
39             }
40             if ($var eq "admin_server") {
41                 my $port;
42                 ($value, $port) = split(':', $value, 2);
43                 $conf{'admin_port'} = $port;
44             }
45             if ($var eq "kdc") {
46                 my $port;
47                 ($value, $port) = split(':', $value, 2);
48                 $conf{'kdc_port'} = $port;
49             }
50         }
51         $conf{$var} = $value;
52     }
53     close(FILE);
54     return %conf;
55 }
56
57 1;