The branch, v4-14-test has been updated via cc1568be4d4 script/autobuild.py: let cleanup() ignore errors from rmdir_force() by default via c933135969b script/autobuild.py: split out a rmdir_force() helper function via c1a4cb97d1d selftest: make/use a copy of GNUPGHOME via 81b36b389cb s4:selftest: use plansmbtorture4testsuite() for 'rpc.echo' via 3eba14718dd s3:selftest: run test_smbclient_tarmode.pl with a fixed subdirectory name via f1c7967b568 selftest/Samba4: allow get_cmd_env_vars() to take an overwrite dictionary via 85800df9035 selftest/Samba4: correctly pass KRB5CCNAME to provision via 9d5f5e821cb selftest/Samba4: make more use of get_cmd_env_vars() via 56c2c0f651e selftest:Samba4: avoid File::Path 'make_path' in setup_dns_hub_internal() via f480161b754 selftest: allow a prefix under /m/username/ via 9fed2749c03 Makefile: add support for 'make testonly' from 99673b77b06 s3:idmap_hash: reliable return ID_TYPE_BOTH
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-14-test - Log ----------------------------------------------------------------- commit cc1568be4d4250390a9ad03c84f5e260fc7acffd Author: Stefan Metzmacher <me...@samba.org> Date: Fri Nov 20 09:20:14 2020 +0000 script/autobuild.py: let cleanup() ignore errors from rmdir_force() by default It's not useful to generate a python backtrace from within the cleanup code. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 9883ac45939f253a63f3ff312fc3912c5f02cdac) Autobuild-User(v4-14-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-14-test): Tue Feb 2 10:29:44 UTC 2021 on sn-devel-184 commit c933135969be29072971f96481b05f499fd48b57 Author: Stefan Metzmacher <me...@samba.org> Date: Fri Nov 20 09:20:14 2020 +0000 script/autobuild.py: split out a rmdir_force() helper function That also tries to re-add write permissions before removing. In future we'll have jobs changing there directory to read-only. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 7a5df2deaaf62a7edd7c64251f75ab15abe94c07) commit c1a4cb97d1d71b974eed2ecb5f34bb1425f36294 Author: Stefan Metzmacher <me...@samba.org> Date: Sun Nov 22 23:28:31 2020 +0100 selftest: make/use a copy of GNUPGHOME That makes it possible to run tests from a read only source tree. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 86343125a55d184c15aa94cd01f4c8893a5a0917) commit 81b36b389cb01eca9b2f0a2a452d290e21f31394 Author: Stefan Metzmacher <me...@samba.org> Date: Sun Nov 22 22:43:36 2020 +0100 s4:selftest: use plansmbtorture4testsuite() for 'rpc.echo' This makes sure "--basedir=$SELFTEST_TMPDIR" is passed to smbtorture. Tests should not create files in the build nor the source directory! BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit d06f2c22d726a5ec7bd804d89154ee272ab1a679) commit 3eba14718dd6269fe1657de15a2f47c848b60518 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Dec 17 06:38:14 2020 +0100 s3:selftest: run test_smbclient_tarmode.pl with a fixed subdirectory name $PREFIX is the the value from --with-selftest-prefix. The result of the test should not depend on --with-selftest-prefix, the 'long_path' test in particular. If the path is to long smbclient (via libarchive) will only put the full path into a PAX HEADER as 'path' keyword, that's fine in general, modern tools handle it just fine. But Perl's Archive::Tar don't handle it and only seems truncated file names. I have a fix for Archive::Tar, see: https://git.samba.org/?p=metze/samba/wip.git;a=shortlog;h=c75037d0a06a96cdaca3f3b20a6d237e768b075b But finishing that is a task for another day, for now I just want to remove the dependency to --with-selftest-prefix. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit e0d9b656452ba6277cdc7f0abb2a06d3d284ef3a) commit f1c7967b568034da2707ccc4bd1f64358d55eacc Author: Stefan Metzmacher <me...@samba.org> Date: Mon Nov 23 11:35:33 2020 +0100 selftest/Samba4: allow get_cmd_env_vars() to take an overwrite dictionary This way we can use it on even in some special cases, where we combine variables from multiple environments. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 568c7d38debaa5ccd90d6ea33c683de512de7005) commit 85800df90358f3a76b6b86f8414582178fe50946 Author: Stefan Metzmacher <me...@samba.org> Date: Mon Nov 23 11:35:33 2020 +0100 selftest/Samba4: correctly pass KRB5CCNAME to provision BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit dce0bdc39ebb01ef4f5e35af0552451cfc29fd1b) commit 9d5f5e821cbe23cc2e64f201e7409aaec4b50387 Author: Stefan Metzmacher <me...@samba.org> Date: Mon Nov 23 11:35:33 2020 +0100 selftest/Samba4: make more use of get_cmd_env_vars() This simplifies the code a lot and makes it much easier to add new environment variables in future. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 15b39160406c3ef49c5f074793d3a55b3bf12e0e) commit 56c2c0f651e1c038ecf87a14a7dbe478e5e58d8d Author: Stefan Metzmacher <me...@samba.org> Date: Thu Dec 17 10:42:03 2020 +0100 selftest:Samba4: avoid File::Path 'make_path' in setup_dns_hub_internal() While spliting the build and test stages I hit strange permission problems, when a parent directory is missing, which can be avoided by using plain mkdir() on each level. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 719eccd445e9cc56a1c2988c4deeb39d301bcbff) commit f480161b754aade6c1af2d05f3ce742466b28026 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Nov 19 16:19:53 2020 +0000 selftest: allow a prefix under /m/username/ We only want to match/replace only a '.' pathname component not any single character pathname compoment! BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 02301222386f2f08631d48d6e88c03cd1439325d) commit 9fed2749c039164794faadef71aa83cfd360d130 Author: Stefan Metzmacher <me...@samba.org> Date: Mon Nov 23 10:38:49 2020 +0100 Makefile: add support for 'make testonly' That skips any attempt to recompile before running the tests. Some times that's useful for debugging and we'll use it to split the build and test stages in autobuild and gitlab-ci later. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14628 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 1e4714940211b10ae6574770f15b7c6ed95f5f59) ----------------------------------------------------------------------- Summary of changes: Makefile | 3 + script/autobuild.py | 38 +++++++--- selftest/selftest.pl | 7 +- selftest/target/Samba.pm | 26 +++++++ selftest/target/Samba4.pm | 183 +++++++++++++++++++--------------------------- source3/selftest/tests.py | 4 +- source4/selftest/tests.py | 3 +- 7 files changed, 143 insertions(+), 121 deletions(-) Changeset truncated at 500 lines: diff --git a/Makefile b/Makefile index 0b7b0ae8866..7f5960d5191 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,9 @@ uninstall: test: $(WAF) test $(TEST_OPTIONS) +testonly: + $(WAF) testonly $(TEST_OPTIONS) + perftest: $(WAF) test --perf-test $(TEST_OPTIONS) diff --git a/script/autobuild.py b/script/autobuild.py index 444bc156f48..dded5c9dec9 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -4,7 +4,7 @@ # released under GNU GPL v3 or later from __future__ import print_function -from subprocess import call, check_call, check_output, Popen, PIPE +from subprocess import call, check_call, check_output, Popen, PIPE, CalledProcessError import os import tarfile import sys @@ -846,6 +846,17 @@ def run_cmd(cmd, dir=".", show=None, output=False, checkfail=True): else: return call(cmd, shell=True, cwd=dir) +def rmdir_force(dirname, re_raise=True): + try: + run_cmd("test -d %s && chmod -R +w %s; rm -rf %s" % ( + dirname, dirname, dirname), output=True, show=True) + except CalledProcessError as e: + do_print("Failed: '%s'" % (str(e))) + run_cmd("tree %s" % dirname, output=True, show=True) + if re_raise: + raise + return False + return True class builder(object): '''handle build of one directory''' @@ -868,8 +879,8 @@ class builder(object): self.test_source_dir = "%s/%s" % (testbase, self.tag) self.cwd = "%s/%s" % (self.test_source_dir, self.dir) self.prefix = "%s/%s" % (test_prefix, self.tag) - run_cmd("rm -rf %s" % self.test_source_dir) - run_cmd("rm -rf %s" % self.prefix) + rmdir_force(self.test_source_dir) + rmdir_force(self.prefix) if cp: run_cmd("cp -R -a -l %s %s" % (test_master, self.test_source_dir), dir=test_master, show=True) else: @@ -879,8 +890,8 @@ class builder(object): def start_next(self): if self.next == len(self.sequence): if not options.nocleanup: - run_cmd("rm -rf %s" % self.test_source_dir) - run_cmd("rm -rf %s" % self.prefix) + rmdir_force(self.test_source_dir) + rmdir_force(self.prefix) do_print('%s: Completed OK' % self.name) self.done = True return @@ -1004,7 +1015,7 @@ class buildlist(object): 'df -m %s' % testbase]: try: out = run_cmd(cmd, output=True, checkfail=False) - except subprocess.CalledProcessError as e: + except CalledProcessError as e: out = "<failed: %s>" % str(e) print('### %s' % cmd, file=f) print(out, file=f) @@ -1034,14 +1045,23 @@ class buildlist(object): self.tail_proc = Popen(cmd, close_fds=True) -def cleanup(): +def cleanup(do_raise=False): if options.nocleanup: return run_cmd("stat %s || true" % test_tmpdir, show=True) run_cmd("stat %s" % testbase, show=True) do_print("Cleaning up %r" % cleanup_list) for d in cleanup_list: - run_cmd("rm -rf %s" % d) + ok = rmdir_force(d, re_raise=False) + if ok: + continue + if os.path.isdir(d): + do_print("Killing, waiting and retry") + run_cmd("killbysubdir %s > /dev/null 2>&1" % d, checkfail=False) + else: + do_print("Waiting and retry") + time.sleep(1) + rmdir_force(d, re_raise=do_raise) def daemonize(logfile): @@ -1307,7 +1327,7 @@ while True: (status, failed_task, failed_stage, failed_tag, errstr) = blist.run() if status != 0 or errstr != "retry": break - cleanup() + cleanup(do_raise=True) except Exception: cleanup() raise diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 6ea21fa6bfe..4c27edd2969 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -281,7 +281,7 @@ my $bindir_abs = abs_path($bindir); my $torture_maxtime = ($ENV{TORTURE_MAXTIME} or 1200); $prefix =~ s+//+/+; -$prefix =~ s+/./+/+; +$prefix =~ s+/\./+/+; $prefix =~ s+/$++; die("using an empty prefix isn't allowed") unless $prefix ne ""; @@ -313,7 +313,6 @@ $ENV{PREFIX} = $prefix; $ENV{PREFIX_ABS} = $prefix_abs; $ENV{SRCDIR} = $srcdir; $ENV{SRCDIR_ABS} = $srcdir_abs; -$ENV{GNUPGHOME} = "$srcdir_abs/selftest/gnupg"; $ENV{BINDIR} = $bindir_abs; my $tls_enabled = not $opt_quick; @@ -667,6 +666,9 @@ $ENV{RESOLV_CONF} = "${selftest_resolv_conf_path}.global"; my $selftest_krbt_ccache_path = "$tmpdir_abs/selftest.krb5_ccache"; $ENV{KRB5CCNAME} = "FILE:${selftest_krbt_ccache_path}.global"; +my $selftest_gnupghome_path = "$tmpdir_abs/selftest.no.gnupg"; +$ENV{GNUPGHOME} = "${selftest_gnupghome_path}.global"; + my @available = (); foreach my $fn (@testlists) { foreach (read_testlist($fn)) { @@ -803,6 +805,7 @@ sub setup_env($$) $ENV{RESOLV_CONF} = "${selftest_resolv_conf_path}.${envname}/ignore"; $ENV{KRB5CCNAME} = "FILE:${selftest_krbt_ccache_path}.${envname}/ignore"; + $ENV{GNUPGHOME} = "${selftest_gnupghome_path}.${envname}/ignore"; if (defined(get_running_env($envname))) { $testenv_vars = get_running_env($envname); diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 0d7e13b7e66..5a7efa9c280 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -280,6 +280,30 @@ EOF umask $oldumask; } +sub copy_gnupg_home($) +{ + my ($ctx) = @_; + + my $gnupg_srcdir = "$ENV{SRCDIR_ABS}/selftest/gnupg"; + my @files = ( + "gpg.conf", + "pubring.gpg", + "secring.gpg", + "trustdb.gpg", + ); + + my $oldumask = umask; + umask 0077; + mkdir($ctx->{gnupghome}, 0777); + umask 0177; + foreach my $file (@files) { + my $srcfile = "${gnupg_srcdir}/${file}"; + my $dstfile = "$ctx->{gnupghome}/${file}"; + copy_file_content(${srcfile}, ${dstfile}); + } + umask $oldumask; +} + sub mk_krb5_conf($$) { my ($ctx) = @_; @@ -682,6 +706,7 @@ sub get_env_for_process RESOLV_CONF => $env_vars->{RESOLV_CONF}, KRB5_CONFIG => $env_vars->{KRB5_CONFIG}, KRB5CCNAME => "$env_vars->{KRB5_CCACHE}.$proc_name", + GNUPGHOME => $env_vars->{GNUPGHOME}, SELFTEST_WINBINDD_SOCKET_DIR => $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR}, NMBD_SOCKET_DIR => $env_vars->{NMBD_SOCKET_DIR}, NSS_WRAPPER_PASSWD => $env_vars->{NSS_WRAPPER_PASSWD}, @@ -867,6 +892,7 @@ my @exported_envvars = ( # misc stuff "KRB5_CONFIG", "KRB5CCNAME", + "GNUPGHOME", "SELFTEST_WINBINDD_SOCKET_DIR", "NMBD_SOCKET_DIR", "LOCAL_PATH", diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 1ebdf2a5484..1ae9fb9d996 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -17,7 +17,6 @@ use SocketWrapper; use target::Samba; use target::Samba3; use Archive::Tar; -use File::Path 'make_path'; sub new($$$$$) { my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_; @@ -161,19 +160,7 @@ sub wait_for_start($$) my $max_wait = 60; # Add hosts file for name lookups - my $cmd = "NSS_WRAPPER_HOSTS='$testenv_vars->{NSS_WRAPPER_HOSTS}' "; - if (defined($testenv_vars->{RESOLV_WRAPPER_CONF})) { - $cmd .= "RESOLV_WRAPPER_CONF='$testenv_vars->{RESOLV_WRAPPER_CONF}' "; - } else { - $cmd .= "RESOLV_WRAPPER_HOSTS='$testenv_vars->{RESOLV_WRAPPER_HOSTS}' "; - } - $cmd .= "RESOLV_CONF='$testenv_vars->{RESOLV_CONF}' "; - if (defined($testenv_vars->{GNUTLS_FORCE_FIPS_MODE})) { - $cmd .= "GNUTLS_FORCE_FIPS_MODE=$testenv_vars->{GNUTLS_FORCE_FIPS_MODE} "; - } - if (defined($testenv_vars->{OPENSSL_FORCE_FIPS_MODE})) { - $cmd .= "OPENSSL_FORCE_FIPS_MODE=$testenv_vars->{OPENSSL_FORCE_FIPS_MODE} "; - } + my $cmd = $self->get_cmd_env_vars($testenv_vars); $cmd .= "$ldbsearch "; $cmd .= "$testenv_vars->{CONFIGURATION} "; @@ -281,7 +268,7 @@ sub setup_dns_hub_internal($$$) my ($self, $hostname, $prefix) = @_; my $STDIN_READER; - unless(-d $prefix or make_path($prefix, 0777)) { + unless(-d $prefix or mkdir($prefix, 0777)) { warn("Unable to create $prefix"); return undef; } @@ -356,6 +343,10 @@ sub setup_dns_hub my $hostname = "rootdnsforwarder"; + unless(-d $prefix or mkdir($prefix, 0777)) { + warn("Unable to create $prefix"); + return undef; + } my $env = $self->setup_dns_hub_internal("$hostname", "$prefix/$hostname"); $self->{dns_hub_env} = $env; @@ -375,10 +366,44 @@ sub get_dns_hub_env($) return undef; } +sub return_env_value +{ + my ($env, $overwrite, $key) = @_; + + if (defined($overwrite) and defined($overwrite->{$key})) { + return $overwrite->{$key}; + } + + if (defined($env->{$key})) { + return $env->{$key}; + } + + return undef; +} + # Returns the environmental variables that we pass to samba-tool commands sub get_cmd_env_vars { - my ($self, $localenv) = @_; + my ($self, $givenenv, $overwrite) = @_; + + my @keys = ( + "NSS_WRAPPER_HOSTS", + "SOCKET_WRAPPER_DEFAULT_IFACE", + "RESOLV_CONF", + "RESOLV_WRAPPER_CONF", + "RESOLV_WRAPPER_HOSTS", + "GNUTLS_FORCE_FIPS_MODE", + "OPENSSL_FORCE_FIPS_MODE", + "KRB5_CONFIG", + "KRB5_CCACHE", + "GNUPGHOME", + ); + + my $localenv = undef; + foreach my $key (@keys) { + my $v = return_env_value($givenenv, $overwrite, $key); + $localenv->{$key} = $v if defined($v); + } my $cmd_env = "NSS_WRAPPER_HOSTS='$localenv->{NSS_WRAPPER_HOSTS}' "; $cmd_env .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$localenv->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; @@ -393,9 +418,10 @@ sub get_cmd_env_vars if (defined($localenv->{OPENSSL_FORCE_FIPS_MODE})) { $cmd_env .= "OPENSSL_FORCE_FIPS_MODE=$localenv->{OPENSSL_FORCE_FIPS_MODE} "; } - $cmd_env .= " KRB5_CONFIG=\"$localenv->{KRB5_CONFIG}\" "; + $cmd_env .= "KRB5_CONFIG=\"$localenv->{KRB5_CONFIG}\" "; $cmd_env .= "KRB5CCNAME=\"$localenv->{KRB5_CCACHE}\" "; $cmd_env .= "RESOLV_CONF=\"$localenv->{RESOLV_CONF}\" "; + $cmd_env .= "GNUPGHOME=\"$localenv->{GNUPGHOME}\" "; return $cmd_env; } @@ -565,6 +591,7 @@ sub provision_raw_prepare($$$$$$$$$$$$$$) $ctx->{krb5_conf} = "$ctx->{etcdir}/krb5.conf"; $ctx->{krb5_ccache} = "$prefix_abs/krb5_ccache"; $ctx->{mitkdc_conf} = "$ctx->{etcdir}/mitkdc.conf"; + $ctx->{gnupghome} = "$prefix_abs/gnupg"; $ctx->{privatedir} = "$prefix_abs/private"; $ctx->{binddnsdir} = "$prefix_abs/bind-dns"; $ctx->{ncalrpcdir} = "$prefix_abs/ncalrpc"; @@ -608,8 +635,9 @@ sub provision_raw_prepare($$$$$$$$$$$$$$) $ctx->{smb_conf_extra_options} = ""; my @provision_options = (); + push (@provision_options, "GNUPGHOME=\"$ctx->{gnupghome}\""); push (@provision_options, "KRB5_CONFIG=\"$ctx->{krb5_conf}\""); - push (@provision_options, "KRB5_CCACHE=\"$ctx->{krb5_ccache}\""); + push (@provision_options, "KRB5CCNAME=\"$ctx->{krb5_ccache}\""); push (@provision_options, "NSS_WRAPPER_PASSWD=\"$ctx->{nsswrap_passwd}\""); push (@provision_options, "NSS_WRAPPER_GROUP=\"$ctx->{nsswrap_group}\""); push (@provision_options, "NSS_WRAPPER_HOSTS=\"$ctx->{nsswrap_hosts}\""); @@ -700,6 +728,7 @@ sub provision_raw_step1($$) return undef; } + Samba::copy_gnupg_home($ctx); Samba::prepare_keyblobs($ctx); my $crlfile = "$ctx->{tlsdir}/crl.pem"; $crlfile = "" unless -e ${crlfile}; @@ -843,6 +872,7 @@ nogroup:x:65534:nobody # Note that we have SERVER_X and DC_SERVER_X variables (which have the same # value initially). In a 2 DC setup, $DC_SERVER_X will always be the PDC. my $ret = { + GNUPGHOME => $ctx->{gnupghome}, KRB5_CONFIG => $ctx->{krb5_conf}, KRB5_CCACHE => $ctx->{krb5_ccache}, MITKDC_CONFIG => $ctx->{mitkdc_conf}, @@ -922,11 +952,10 @@ sub provision_raw_step2($$$) return undef; } + my $cmd_env = $self->get_cmd_env_vars($ret); + my $testallowed_account = "testallowed"; - my $samba_tool_cmd = ""; - $samba_tool_cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + my $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " user create --configfile=$ctx->{smb_conf} $testallowed_account $ctx->{password}"; unless (system($samba_tool_cmd) == 0) { @@ -935,10 +964,7 @@ sub provision_raw_step2($$$) } my $srv_account = "srv_account"; - $samba_tool_cmd = ""; - $samba_tool_cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " user create --configfile=$ctx->{smb_conf} $srv_account $ctx->{password}"; unless (system($samba_tool_cmd) == 0) { @@ -946,10 +972,7 @@ sub provision_raw_step2($$$) return undef; } - $samba_tool_cmd = ""; - $samba_tool_cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " spn add HOST/$srv_account --configfile=$ctx->{smb_conf} $srv_account"; unless (system($samba_tool_cmd) == 0) { @@ -957,10 +980,7 @@ sub provision_raw_step2($$$) return undef; } - my $ldbmodify = ""; - $ldbmodify .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $ldbmodify .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $ldbmodify .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + my $ldbmodify = ${cmd_env}; $ldbmodify .= Samba::bindir_path($self, "ldbmodify"); $ldbmodify .= " --configfile=$ctx->{smb_conf}"; my $base_dn = "DC=".join(",DC=", split(/\./, $ctx->{realm})); @@ -991,10 +1011,7 @@ servicePrincipalName: host/testallowed "; close(LDIF); - $samba_tool_cmd = ""; - $samba_tool_cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " user create --configfile=$ctx->{smb_conf} testdenied $ctx->{password}"; unless (system($samba_tool_cmd) == 0) { @@ -1012,10 +1029,7 @@ userPrincipalName: testdenied_upn\@$ctx->{realm}.upn "; close(LDIF); - $samba_tool_cmd = ""; - $samba_tool_cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " user create --configfile=$ctx->{smb_conf} testupnspn $ctx->{password}"; unless (system($samba_tool_cmd) == 0) { @@ -1035,10 +1049,7 @@ servicePrincipalName: http/testupnspn.$ctx->{dnsname} "; close(LDIF); - $samba_tool_cmd = ""; - $samba_tool_cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " group addmembers --configfile=$ctx->{smb_conf} 'Allowed RODC Password Replication Group' '$testallowed_account' -d10"; unless (system($samba_tool_cmd) == 0) { @@ -1050,11 +1061,8 @@ servicePrincipalName: http/testupnspn.$ctx->{dnsname} my $user_account_array = ["alice", "bob", "jane", "joe"]; foreach my $user_account (@{$user_account_array}) { - my $samba_tool_cmd = ""; + my $samba_tool_cmd = ${cmd_env}; - $samba_tool_cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " user create --configfile=$ctx->{smb_conf} $user_account Secret007"; unless (system($samba_tool_cmd) == 0) { @@ -1066,10 +1074,8 @@ servicePrincipalName: http/testupnspn.$ctx->{dnsname} my $group_array = ["Samba Users"]; foreach my $group (@{$group_array}) { - my $samba_tool_cmd = ""; + my $samba_tool_cmd = ${cmd_env}; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " group add --configfile=$ctx->{smb_conf} \"$group\""; unless (system($samba_tool_cmd) == 0) { @@ -1079,12 +1085,10 @@ servicePrincipalName: http/testupnspn.$ctx->{dnsname} } # Add user joe to group "Samba Users" - $samba_tool_cmd = ""; my $group = "Samba Users"; my $user_account = "joe"; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " group addmembers --configfile=$ctx->{smb_conf} \"$group\" $user_account"; unless (system($samba_tool_cmd) == 0) { @@ -1092,12 +1096,10 @@ servicePrincipalName: http/testupnspn.$ctx->{dnsname} return undef; } - $samba_tool_cmd = ""; $group = "Samba Users"; $user_account = "joe"; - $samba_tool_cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $samba_tool_cmd .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $samba_tool_cmd = ${cmd_env}; $samba_tool_cmd .= Samba::bindir_path($self, "samba-tool") . " user setprimarygroup --configfile=$ctx->{smb_conf} $user_account \"$group\""; unless (system($samba_tool_cmd) == 0) { @@ -1106,10 +1108,7 @@ servicePrincipalName: http/testupnspn.$ctx->{dnsname} } # Change the userPrincipalName for jane - $ldbmodify = ""; - $ldbmodify .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" "; - $ldbmodify .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $ldbmodify .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" "; + $ldbmodify = ${cmd_env}; $ldbmodify .= Samba::bindir_path($self, "ldbmodify"); $ldbmodify .= " --configfile=$ctx->{smb_conf}"; $base_dn = "DC=".join(",DC=", split(/\./, $ctx->{realm})); @@ -1409,12 +1408,13 @@ sub provision_rpc_proxy($$$) -- Samba Shared Repository