]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
teuthology/orchestra: store temporaries in tmp subdir i51169 1655/head
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 10 Jun 2021 18:23:11 +0000 (11:23 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 29 Jun 2021 15:47:39 +0000 (08:47 -0700)
Due to protections turned on in Ubuntu 20.04 from [1], files created by
other users (e.g. ubuntu) can not be manipulated by other users, even
root.

Instead of using /tmp as the parent directory for `mktemp` files, use a
sub-directory under it instead.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=30aba6656f61ed44cba445a3c0d38b296fa9e8f5

Fixes: https://tracker.ceph.com/issues/51169
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
teuthology/misc.py
teuthology/orchestra/remote.py

index d88d19b6c7924595d1756f0729621cd200a765ad..a670fbedbb80ff73502dace8d91b806d6b994b79 100644 (file)
@@ -154,6 +154,16 @@ def get_testdir(ctx=None):
     )
 
 
+def get_tmpdir():
+    """
+    :returns: A temporary directory for use by tests on the test node.
+    """
+    return config.get(
+        'test_tmpdir',
+        '/tmp/cephtest'
+    )
+
+
 def get_test_user(ctx=None):
     """
     :param ctx: Unused; accepted for compatibility
index 1b5cb6fda79ddb970a56818b1cb6b5637bfe93aa..677968790fa8404125c2822adb81c40ef5b274eb 100644 (file)
@@ -53,8 +53,10 @@ class RemoteShell(object):
 
         if suffix:
             args.append('--suffix=%s' % suffix)
-        if parentdir:
-            args.append('--tmpdir=%s' % parentdir)
+        if parentdir is None:
+            parentdir = misc.get_tmpdir()
+            self.sh(f"mkdir -p {parentdir}")
+        args.append('--tmpdir=%s' % parentdir)
 
         return self.sh(args).strip()
 
@@ -69,10 +71,13 @@ class RemoteShell(object):
         Returns: the path of the temp file created.
         """
         args = ['mktemp']
+
         if suffix:
             args.append('--suffix=%s' % suffix)
-        if parentdir:
-            args.append('--tmpdir=%s' % parentdir)
+        if parentdir is None:
+            parentdir = misc.get_tmpdir()
+            self.sh(f"mkdir -p {parentdir}")
+        args.append('--tmpdir=%s' % parentdir)
 
         path = self.sh(args).strip()