blob: 53ddefff1152442cfe6849e876fbdd9491178c2d (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/usr/bin/perl
#
# This program converts the old-style krb.conf and krb.realms files into the
# new-format krb5.conf file. It takes two arguments; the first is the krb.conf
# file, and the second is the krb.realms file. The krb5.conf file is output
# to stdout.
#
# Written by Theodore Ts'o, 4/25/95
#
if ($#ARGV >= 0) {
$krb_conf_file = $ARGV[0];
} else {
$krb_conf_file = "/etc/krb.conf";
}
if ($#ARGV >= 1) {
$krb_realms_file = $ARGV[1];
} else {
$krb_realms_file = "/etc/krb.realms";
}
open(FILE, "<$krb_conf_file") || die "Couldn't open the krb.conf file\n";
$_ = <FILE>;
strip;
$default_realm = $_;
while(<FILE>) {
strip;
($realm, $host, $admin) = split;
if (!defined($realmpt{$realm})) {
$realmpt{$realm} = 1;
}
$realmkdc{$realm . "##" . $realmpt{$realm}} = $host;
$realmpt{$realm}++;
if ($admin eq "admin") {
$realmadmin{$realm} = $host;
}
}
close(FILE);
open(FILE, "<$krb_realms_file") || die "Couldn't open krb.realms file";
while (<FILE>) {
strip;
($domain, $realm) = split;
$domain =~ s/\.$//;
$domain =~ tr/[A-Z]/[a-z]/;
$dom_realm{$domain} = $realm;
if ($domain =~ /^\./) {
$domain =~ s/^\.//;
$def_realm{$realm} = $domain;
}
}
print "[libdefaults]\n\tdefault_realm = $default_realm\n";
print "[realms]\n";
foreach $realm (sort(keys(%realmpt))) {
print "\t$realm = {\n";
for ($i = 1; $i < $realmpt{$realm}; $i++) {
printf("\t\tkdc = %s\n", $realmkdc{$realm . "##" . $i});
}
if (defined($realmadmin{$realm})) {
print "\t\tadmin_server = $realmadmin{$realm}\n";
}
if (defined($def_realm{$realm})) {
print "\t\tdefault_domain = $def_realm{$realm}\n";
}
print "\t}\n";
}
print "\n[domain_realm]\n";
foreach $domain (keys(%dom_realm)) {
print "\t$domain = $dom_realm{$domain}\n";
}
|