1 # Unix SMB/CIFS implementation
3 # Backend code for provisioning a Samba AD server
5 # Copyright (c) 2015 Andreas Schneider <asn@samba.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from samba.provision.kerberos_implementation import (
23 kdc_default_config_dir)
24 from samba import _glue
27 def make_kdcconf(realm, domain, kdcconfdir, logdir):
29 if _glue.is_heimdal_built:
32 # Do nothing if kdc.conf has been set
33 if 'KRB5_KDC_PROFILE' in os.environ:
37 if 'SAMBA_SELFTEST' in os.environ and 'MITKRB5' in os.environ:
40 # If not specified use the default
41 if kdcconfdir is None:
42 kdcconfdir = kdc_default_config_dir
44 kdcconf = "%s/kdc.conf" % kdcconfdir
46 assert domain is not None
47 domain = domain.upper()
49 assert realm is not None
52 f = open(kdcconf, 'w')
54 f.write("[kdcdefaults]\n")
56 f.write("\tkdc_ports = 88\n")
57 f.write("\tkdc_tcp_ports = 88\n")
58 f.write("\tkadmind_port = 464\n")
63 f.write("\t%s = {\n" % realm)
67 f.write("\t%s = {\n" % realm.lower())
71 f.write("\t%s = {\n" % domain)
75 f.write("[dbmodules]\n")
77 f.write("\tdb_modules_dir = %s\n" % kdb_modules_dir)
80 f.write("\t%s = {\n" % realm)
81 f.write("\t\tdb_library = samba\n")
85 f.write("\t%s = {\n" % realm.lower())
86 f.write("\t\tdb_library = samba\n")
90 f.write("\t%s = {\n" % domain)
91 f.write("\t\tdb_library = samba\n")
95 f.write("[logging]\n")
97 f.write("\tkdc = FILE:%s/mit_kdc.log\n" % logdir)
98 f.write("\tadmin_server = FILE:%s/mit_kadmin.log\n" % logdir)