2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2012 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
10 def bindir_path
(bindir
, path
):
11 """Find the executable to use.
13 :param bindir: Directory with binaries
14 :param path: Name of the executable to run
15 :return: Full path to the executable to run
17 valpath
= os
.path
.join(bindir
, path
)
18 if os
.path
.isfile
(valpath
):
23 def mk_realms_stanza
(realm
, dnsname
, domain
, kdc_ipv4
):
24 """Create a realms stanza for use in a krb5.conf file.
26 :param realm: Real name
27 :param dnsname: DNS name matching the realm
28 :param domain: Domain name
29 :param kdc_ipv4: IPv4 address of the KDC
30 :return: String with stanza
35 admin_server = %(kdc_ipv4)s:88
36 default_domain = %(dnsname)s
40 admin_server = %(kdc_ipv4)s:88
41 default_domain = %(dnsname)s
45 admin_server = %(kdc_ipv4)s:88
46 default_domain = %(dnsname)s
50 "kdc_ipv4": kdc_ipv4
, "dnsname": dnsname
, "realm": realm
, "domain": domain
}
53 def write_krb5_conf
(f
, realm
, dnsname
, domain
, kdc_ipv4
, tlsdir
=None
,
54 other_realms_stanza
=None
):
55 """Write a krb5.conf file.
57 :param f: File-like object to write to
59 :param dnsname: DNS domain name
60 :param domain: Domain name
61 :param kdc_ipv4: IPv4 address of KDC
62 :param tlsdir: Optional TLS directory
63 :param other_realms_stanza: Optional extra raw text for [realms] section
66 #Generated krb5.conf for %(realm)s
69 \tdefault_realm = %(realm)s
70 \tdns_lookup_realm = false
71 \tdns_lookup_kdc = false
72 \tticket_lifetime = 24h
74 \tallow_weak_crypto = yes
75 """ % {"realm": realm
})
77 f
.write("\n[realms]\n")
78 f
.write(mk_realms_stanza
(realm
, dnsname
, domain
, kdc_ipv4
))
79 if other_realms_stanza
:
80 f
.write(other_realms_stanza
)
85 pkinit_anchors = FILE:%(tlsdir)s/ca.pem
89 pkinit_identity = FILE:%(tlsdir)s/kdc.pem,%(tlsdir)s/key.pem
90 pkinit_anchors = FILE:%(tlsdir)s/ca.pem
92 """ % {"tlsdir": tlsdir
})
95 def cleanup_child
(pid
, name
, outf
=None
):
96 """Cleanup a child process.
98 :param pid: Parent pid process to be passed to waitpid()
99 :param name: Name to use when referring to process
100 :param outf: File-like object to write to (defaults to stderr)
105 (childpid
, status
) = os
.waitpid(pid
, os
.WNOHANG
)
109 outf
.write("%s child process %d isn't here any more.\n" % (name
, pid
))
115 core_status
= 'without'
116 outf
.write("%s child process %d, died with signal %d, %s coredump.\n" % (name
, childpid
, (status
& 127), core_status
))
118 outf
.write("%s child process %d exited with value %d.\n" % (name
, childpid
, status
>> 8))
122 def get_interface
(netbiosname
):
123 """Return interface id for a particular server.
125 netbiosname
= netbiosname
.lower
()
129 "localnt4member3": 3,
135 # 11-16 used by selftest.pl for client interfaces
137 "localvampiredc": 22,
150 # update lib/socket_wrapper/socket_wrapper.c
151 # #define MAX_WRAPPED_INTERFACES 32
152 # if you wish to have more than 32 interfaces
153 return interfaces
[netbiosname
]