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
(binary_mapping
, bindir
, path
):
11 """Find the executable to use.
13 :param binary_mapping: Dictionary mapping binary names
14 :param bindir: Directory with binaries
15 :param path: Name of the executable to run
16 :return: Full path to the executable to run
18 path
= binary_mapping
.get
(path
, path
)
19 valpath
= os
.path
.join(bindir
, path
)
20 if os
.path
.isfile
(valpath
):
25 def mk_realms_stanza
(realm
, dnsname
, domain
, kdc_ipv4
):
26 """Create a realms stanza for use in a krb5.conf file.
28 :param realm: Real name
29 :param dnsname: DNS name matching the realm
30 :param domain: Domain name
31 :param kdc_ipv4: IPv4 address of the KDC
32 :return: String with stanza
37 admin_server = %(kdc_ipv4)s:88
38 default_domain = %(dnsname)s
42 admin_server = %(kdc_ipv4)s:88
43 default_domain = %(dnsname)s
47 admin_server = %(kdc_ipv4)s:88
48 default_domain = %(dnsname)s
52 "kdc_ipv4": kdc_ipv4
, "dnsname": dnsname
, "realm": realm
, "domain": domain
}
55 def write_krb5_conf
(f
, realm
, dnsname
, domain
, kdc_ipv4
, tlsdir
=None
,
56 other_realms_stanza
=None
):
57 """Write a krb5.conf file.
59 :param f: File-like object to write to
61 :param dnsname: DNS domain name
62 :param domain: Domain name
63 :param kdc_ipv4: IPv4 address of KDC
64 :param tlsdir: Optional TLS directory
65 :param other_realms_stanza: Optional extra raw text for [realms] section
68 #Generated krb5.conf for %(realm)s
71 \tdefault_realm = %(realm)s
72 \tdns_lookup_realm = false
73 \tdns_lookup_kdc = false
74 \tticket_lifetime = 24h
76 \tallow_weak_crypto = yes
77 """ % {"realm": realm
})
79 f
.write("\n[realms]\n")
80 f
.write(mk_realms_stanza
(realm
, dnsname
, domain
, kdc_ipv4
))
81 if other_realms_stanza
:
82 f
.write(other_realms_stanza
)
87 pkinit_anchors = FILE:%(tlsdir)s/ca.pem
91 pkinit_identity = FILE:%(tlsdir)s/kdc.pem,%(tlsdir)s/key.pem
92 pkinit_anchors = FILE:%(tlsdir)s/ca.pem
94 """ % {"tlsdir": tlsdir
})
97 def cleanup_child
(pid
, name
, outf
=None
):
98 """Cleanup a child process.
100 :param pid: Parent pid process to be passed to waitpid()
101 :param name: Name to use when referring to process
102 :param outf: File-like object to write to (defaults to stderr)
107 (childpid
, status
) = os
.waitpid(pid
, os
.WNOHANG
)
111 outf
.write("%s child process %d isn't here any more.\n" % (name
, pid
))
117 core_status
= 'without'
118 outf
.write("%s child process %d, died with signal %d, %s coredump.\n" % (name
, childpid
, (status
& 127), core_status
))
120 outf
.write("%s child process %d exited with value %d.\n" % (name
, childpid
, status
>> 8))
124 def get_interface
(netbiosname
):
125 """Return interface id for a particular server.
127 netbiosname
= netbiosname
.lower
()
137 # 11-16 used by selftest.pl for client interfaces
139 "localvampiredc": 22,
152 # update lib/socket_wrapper/socket_wrapper.c
153 # #define MAX_WRAPPED_INTERFACES 32
154 # if you wish to have more than 32 interfaces
155 return interfaces
[netbiosname
]