passdb: Add a function to expose loaded backend list.
[Samba.git] / selftest / target / Samba.pm
blob1b1eb53933618b4cacad712d3b1c2dfd7df62225
1 #!/usr/bin/perl
2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 package Samba;
8 use strict;
9 use target::Samba3;
10 use target::Samba4;
12 sub new($$$$$) {
13 my ($classname, $bindir, $binary_mapping,$ldap, $srcdir, $exeext, $server_maxtime) = @_;
15 my $self = {
16 samba3 => new Samba3($bindir,$binary_mapping, $srcdir, $exeext, $server_maxtime),
17 samba4 => new Samba4($bindir,$binary_mapping, $ldap, $srcdir, $exeext, $server_maxtime),
19 bless $self;
20 return $self;
23 sub setup_env($$$)
25 my ($self, $envname, $path) = @_;
27 $ENV{ENVNAME} = $envname;
29 my $env = $self->{samba4}->setup_env($envname, $path);
30 if (defined($env)) {
31 if (not defined($env->{target})) {
32 $env->{target} = $self->{samba4};
34 } else {
35 $env = $self->{samba3}->setup_env($envname, $path);
36 if (defined($env)) {
37 if (not defined($env->{target})) {
38 $env->{target} = $self->{samba3};
42 if (not defined $env) {
43 warn("Samba can't provide environment '$envname'");
44 return undef;
46 return $env;
49 sub bindir_path($$) {
50 my ($object, $path) = @_;
52 if (defined($object->{binary_mapping}->{$path})) {
53 $path = $object->{binary_mapping}->{$path};
56 my $valpath = "$object->{bindir}/$path$object->{exeext}";
58 return $valpath if (-f $valpath);
59 return $path;
62 sub mk_krb5_conf($)
64 my ($ctx) = @_;
66 unless (open(KRB5CONF, ">$ctx->{krb5_conf}")) {
67 warn("can't open $ctx->{krb5_conf}$?");
68 return undef;
70 print KRB5CONF "
71 #Generated krb5.conf for $ctx->{realm}
73 [libdefaults]
74 default_realm = $ctx->{realm}
75 dns_lookup_realm = false
76 dns_lookup_kdc = false
77 ticket_lifetime = 24h
78 forwardable = yes
79 allow_weak_crypto = yes
81 [realms]
82 $ctx->{realm} = {
83 kdc = $ctx->{kdc_ipv4}:88
84 admin_server = $ctx->{kdc_ipv4}:88
85 default_domain = $ctx->{dnsname}
87 $ctx->{dnsname} = {
88 kdc = $ctx->{kdc_ipv4}:88
89 admin_server = $ctx->{kdc_ipv4}:88
90 default_domain = $ctx->{dnsname}
92 $ctx->{domain} = {
93 kdc = $ctx->{kdc_ipv4}:88
94 admin_server = $ctx->{kdc_ipv4}:88
95 default_domain = $ctx->{dnsname}
98 [domain_realm]
99 .$ctx->{dnsname} = $ctx->{realm}
102 if (defined($ctx->{tlsdir})) {
103 print KRB5CONF "
105 [appdefaults]
106 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
108 [kdc]
109 enable-pkinit = true
110 pkinit_identity = FILE:$ctx->{tlsdir}/kdc.pem,$ctx->{tlsdir}/key.pem
111 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
115 close(KRB5CONF);