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 from samba import is_heimdal_built
26 def create_kdc_conf(kdcconf, realm, domain, logdir):
28 if is_heimdal_built():
31 # Do nothing if kdc.conf has been set
32 if 'KRB5_KDC_PROFILE' in os.environ:
36 if 'SAMBA_SELFTEST' in os.environ and 'MITKRB5' in os.environ:
39 assert kdcconf is not None
41 assert domain is not None
42 domain = domain.upper()
44 assert realm is not None
47 f = open(kdcconf, 'w')
49 f.write("[kdcdefaults]\n")
51 f.write("\tkdc_ports = 88\n")
52 f.write("\tkdc_tcp_ports = 88\n")
53 f.write("\tkadmind_port = 464\n")
58 f.write("\t%s = {\n" % realm)
62 f.write("\t%s = {\n" % realm.lower())
66 f.write("\t%s = {\n" % domain)
70 f.write("[dbmodules]\n")
72 f.write("\tdb_module_dir = %s\n" % kdb_modules_dir)
75 f.write("\t%s = {\n" % realm)
76 f.write("\t\tdb_library = samba\n")
80 f.write("\t%s = {\n" % realm.lower())
81 f.write("\t\tdb_library = samba\n")
85 f.write("\t%s = {\n" % domain)
86 f.write("\t\tdb_library = samba\n")
90 f.write("[logging]\n")
92 f.write("\tkdc = FILE:%s/mit_kdc.log\n" % logdir)
93 f.write("\tadmin_server = FILE:%s/mit_kadmin.log\n" % logdir)