selftest: setup information of new samba.example.com CA in the client environment
authorStefan Metzmacher <metze@samba.org>
Sat, 9 Jan 2016 20:21:25 +0000 (21:21 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 28 Mar 2016 22:41:35 +0000 (00:41 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11804

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
(cherry picked from commit b00c38afc6203f1e1f566db31a63cedba632dfab)

selftest/selftest.pl

index 1d5826da5eac26f6b4ec3afad2a804e6a7c92c91..2707f727e37add598490f4fa017a5861200fc348 100755 (executable)
@@ -27,6 +27,7 @@ use Cwd qw(abs_path);
 use lib "$RealBin";
 use Subunit;
 use SocketWrapper;
+use target::Samba;
 
 eval {
 require Time::HiRes;
@@ -505,6 +506,42 @@ sub write_clientconf($$$)
        mkdir("$clientdir/ncalrpcdir", 0755);
        umask $mask;
 
+       my $cadir = "$ENV{SRCDIR_ABS}/selftest/manage-ca/CA-samba.example.com";
+       my $cacert = "$cadir/Public/CA-samba.example.com-cert.pem";
+       my $cacrl_pem = "$cadir/Public/CA-samba.example.com-crl.pem";
+       my $ca_users_dir = "$cadir/Users";
+
+       if ( -d "$clientdir/pkinit" ) {
+               unlink <$clientdir/pkinit/*>;
+       } else {
+               mkdir("$clientdir/pkinit", 0700);
+       }
+
+       # each user has a USER-${USER_PRINCIPAL_NAME}-cert.pem and
+       # USER-${USER_PRINCIPAL_NAME}-private-key.pem symlink
+       # We make a copy here and make the certificated easily
+       # accessable in the client environment.
+       my $mask = umask;
+       umask 0077;
+       opendir USERS, "${ca_users_dir}" or die "Could not open dir '${ca_users_dir}': $!";
+       for my $d (readdir USERS) {
+               my $user_dir = "${ca_users_dir}/${d}";
+               next if ${d} =~ /^\./;
+               next if (! -d "${user_dir}");
+               opendir USER, "${user_dir}" or die "Could not open dir '${user_dir}': $!";
+               for my $l (readdir USER) {
+                       my $user_link = "${user_dir}/${l}";
+                       next if ${l} =~ /^\./;
+                       next if (! -l "${user_link}");
+
+                       my $dest = "${clientdir}/pkinit/${l}";
+                       Samba::copy_file_content(${user_link}, ${dest});
+               }
+               closedir USER;
+       }
+       closedir USERS;
+       umask $mask;
+
        open(CF, ">$conffile");
        print CF "[global]\n";
        print CF "\tnetbios name = client\n";
@@ -538,6 +575,8 @@ sub write_clientconf($$$)
 #We don't want to run 'speed' tests for very long
         torture:timelimit = 1
         winbind separator = /
+       tls cafile = ${cacert}
+       tls crlfile = ${cacrl_pem}
 ";
        close(CF);
 }