[Patches] Avoid selftest/autobuild interaction with /tmp

Stefan Metzmacher metze at samba.org
Fri Dec 16 21:44:14 UTC 2016


Hi,

here're some patches from my master3-libsmb-ok branch:
https://git.samba.org/?p=metze/samba/wip.git;a=shortlog;h=refs/heads/master3-libsmb-ok

The work towards passing cli_credentials from the command line handling
through the source3/libsmb code down to gensec revealed some strange
problems which are triggered by using the default krb5 ccache under
/tmp/krb5cc_*, while I was there I added some more code to export
TMPDIR so that more tests parts don't pollute /tmp.

Please review and push.

Thanks!
metze
-------------- next part --------------
From 1f5f73a1a691589305925a17ef1ed9c6e5933a38 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 16 Dec 2016 13:30:57 +0100
Subject: [PATCH 1/6] script/autobuild.py: don't add subdirs of testbase to
 cleanup_list

We already have testbase in there.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 script/autobuild.py | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/script/autobuild.py b/script/autobuild.py
index 356b7fa..8ed6742 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -278,8 +278,6 @@ class builder(object):
         self.sdir = "%s/%s" % (testbase, self.tag)
         self.prefix = "%s/prefix/%s" % (testbase, self.tag)
         run_cmd("rm -rf %s" % self.sdir)
-        cleanup_list.append(self.sdir)
-        cleanup_list.append(self.prefix)
         os.makedirs(self.sdir)
         run_cmd("rm -rf %s" % self.sdir)
         if cp:
@@ -734,7 +732,6 @@ start_time = time.time()
 while True:
     try:
         run_cmd("rm -rf %s" % test_master)
-        cleanup_list.append(test_master)
         run_cmd("git clone --recursive --shared %s %s" % (gitroot, test_master), show=True, dir=gitroot)
     except Exception:
         cleanup()
-- 
1.9.1


From a44021c6abf3cbf1eb564a5a0328bbdbdd317940 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 16 Dec 2016 13:33:42 +0100
Subject: [PATCH 2/6] script/autobuild.py: remove pointless mkdir/rmdir
 commands

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 script/autobuild.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/script/autobuild.py b/script/autobuild.py
index 8ed6742..396cb6a 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -278,8 +278,6 @@ class builder(object):
         self.sdir = "%s/%s" % (testbase, self.tag)
         self.prefix = "%s/prefix/%s" % (testbase, self.tag)
         run_cmd("rm -rf %s" % self.sdir)
-        os.makedirs(self.sdir)
-        run_cmd("rm -rf %s" % self.sdir)
         if cp:
             run_cmd("cp --recursive --link --archive %s %s" % (test_master, self.sdir), dir=test_master, show=True)
         else:
-- 
1.9.1


From a62bb097814d9dafe5fb45981b1e096545e71437 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 16 Dec 2016 13:35:01 +0100
Subject: [PATCH 3/6] script/autobuild.py: cleanup testbase/prefix before each
 retry

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 script/autobuild.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/script/autobuild.py b/script/autobuild.py
index 396cb6a..9fc5c90 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -276,7 +276,7 @@ class builder(object):
         self.stderr = open(self.stderr_path, 'w')
         self.stdin  = open("/dev/null", 'r')
         self.sdir = "%s/%s" % (testbase, self.tag)
-        self.prefix = "%s/prefix/%s" % (testbase, self.tag)
+        self.prefix = "%s/%s" % (test_prefix, self.tag)
         run_cmd("rm -rf %s" % self.sdir)
         if cp:
             run_cmd("cp --recursive --link --archive %s %s" % (test_master, self.sdir), dir=test_master, show=True)
@@ -708,6 +708,7 @@ if options.retry:
 
 testbase = "%s/b%u" % (options.testbase, os.getpid())
 test_master = "%s/master" % testbase
+test_prefix = "%s/prefix" % testbase
 
 # get the top commit message, for emails
 top_commit_msg = run_cmd("git log -1", dir=gitroot, output=True)
@@ -730,6 +731,7 @@ start_time = time.time()
 while True:
     try:
         run_cmd("rm -rf %s" % test_master)
+        run_cmd("rm -rf %s" % test_prefix)
         run_cmd("git clone --recursive --shared %s %s" % (gitroot, test_master), show=True, dir=gitroot)
     except Exception:
         cleanup()
-- 
1.9.1


From e22603f5381762d89ae52d5a616b12a7a5b2ad9f Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 16 Dec 2016 13:35:36 +0100
Subject: [PATCH 4/6] script/autobuild.py: create tmpdir for each try and
 export it as TMPDIR

This way the compiler and other tools hopefully don't use /tmp
anymore.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 script/autobuild.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/script/autobuild.py b/script/autobuild.py
index 9fc5c90..3d76130 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -709,6 +709,8 @@ if options.retry:
 testbase = "%s/b%u" % (options.testbase, os.getpid())
 test_master = "%s/master" % testbase
 test_prefix = "%s/prefix" % testbase
+test_tmpdir = "%s/tmp" % testbase
+os.environ['TMPDIR'] = test_tmpdir
 
 # get the top commit message, for emails
 top_commit_msg = run_cmd("git log -1", dir=gitroot, output=True)
@@ -732,6 +734,8 @@ while True:
     try:
         run_cmd("rm -rf %s" % test_master)
         run_cmd("rm -rf %s" % test_prefix)
+        run_cmd("rm -rf %s" % test_tmpdir)
+        os.makedirs(test_tmpdir)
         run_cmd("git clone --recursive --shared %s %s" % (gitroot, test_master), show=True, dir=gitroot)
     except Exception:
         cleanup()
-- 
1.9.1


From 80b3cca21764e15b0077fad1b7b2e1e6a11fbd91 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 15 Dec 2016 10:31:50 +0100
Subject: [PATCH 5/6] selftest: also export TMPDIR

This should hopefully avoid usage of /tmp.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 selftest/selftest.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 7d71013..d707d25 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -654,6 +654,7 @@ if ($#testlists == -1) {
 
 $ENV{SELFTEST_PREFIX} = "$prefix_abs";
 $ENV{SELFTEST_TMPDIR} = "$tmpdir_abs";
+$ENV{TMPDIR} = "$tmpdir_abs";
 $ENV{TEST_DATA_PREFIX} = "$tmpdir_abs";
 if ($opt_socket_wrapper) {
 	$ENV{SELFTEST_INTERFACES} = $interfaces;
-- 
1.9.1


From 3ec43bb5fd304d5b381f959b8476b2fd4d432b65 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Fri, 16 Dec 2016 11:09:16 +0100
Subject: [PATCH 6/6] selftest: make sure we always export KRB5CCNAME

We should not risk the usage of the users global ccache!

This results in unpredictable effects for the user and
selftest itself.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 selftest/selftest.pl | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index d707d25..c54ea68 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -668,6 +668,9 @@ if ($opt_quick) {
 }
 $ENV{SELFTEST_MAXTIME} = $torture_maxtime;
 
+my $selftest_krbt_ccache_path = "$tmpdir_abs/selftest.krb5_ccache";
+$ENV{KRB5CCNAME} = "FILE:${selftest_krbt_ccache_path}.global";
+
 my @available = ();
 foreach my $fn (@testlists) {
 	foreach (read_testlist($fn)) {
@@ -886,6 +889,8 @@ sub setup_env($$)
 
 	$option = "client" if $option eq "";
 
+	$ENV{KRB5CCNAME} = "FILE:${selftest_krbt_ccache_path}.${envname}/ignore";
+
 	if (defined(get_running_env($envname))) {
 		$testenv_vars = get_running_env($envname);
 		if (not $testenv_vars->{target}->check_env($testenv_vars)) {
@@ -927,6 +932,9 @@ sub setup_env($$)
 		}
 	}
 
+	my $krb5_ccache_path = "${selftest_krbt_ccache_path}.${envname}.${option}";
+	unlink($krb5_ccache_path);
+	$ENV{KRB5CCNAME} = "FILE:${krb5_ccache_path}";
 	return $testenv_vars;
 }
 
-- 
1.9.1



More information about the samba-technical mailing list