mirror of
https://github.com/ceph/ceph
synced 2025-03-06 08:20:12 +00:00
qa/cephfs: don't use sudo to write files in /tmp
Files in /tmp cannot be written by any user( including the root user) other than the file owner even if the permission mode on the file is 777. Fixes: https://tracker.ceph.com/issues/49466 Signed-off-by: Rishabh Dave <ridave@redhat.com>
This commit is contained in:
parent
e05959de8d
commit
e213849581
qa/tasks
@ -4,12 +4,10 @@ import os
|
||||
import re
|
||||
|
||||
from shlex import split as shlex_split
|
||||
from io import StringIO
|
||||
|
||||
from tasks.ceph_test_case import CephTestCase
|
||||
|
||||
from teuthology import contextutil
|
||||
from teuthology.misc import sudo_write_file
|
||||
from teuthology.orchestra import run
|
||||
from teuthology.orchestra.run import CommandFailedError
|
||||
|
||||
@ -446,11 +444,4 @@ class CephFSTestCase(CephTestCase):
|
||||
return self.run_cluster_cmd(f'auth get {self.client_name}')
|
||||
|
||||
def create_keyring_file(self, remote, keyring):
|
||||
keyring_path = remote.run(args=['mktemp'], stdout=StringIO()).\
|
||||
stdout.getvalue().strip()
|
||||
sudo_write_file(remote, keyring_path, keyring)
|
||||
|
||||
# required when triggered using vstart_runner.py.
|
||||
remote.run(args=['chmod', '644', keyring_path])
|
||||
|
||||
return keyring_path
|
||||
return remote.mktemp(data=keyring)
|
||||
|
@ -306,14 +306,23 @@ class LocalRemote(object):
|
||||
# None
|
||||
return mkdtemp(suffix=suffix, prefix='', dir=parentdir)
|
||||
|
||||
def mktemp(self, suffix=None, parentdir=None):
|
||||
def mktemp(self, suffix='', parentdir='', path=None, data=None,
|
||||
owner=None, mode=None):
|
||||
"""
|
||||
Make a remote temporary file
|
||||
|
||||
Returns: the path of the temp file created.
|
||||
"""
|
||||
from tempfile import mktemp
|
||||
return mktemp(suffix=suffix, dir=parentdir)
|
||||
if not path:
|
||||
path = mktemp(suffix=suffix, dir=parentdir)
|
||||
|
||||
if data:
|
||||
# sudo is set to False since root user can't write files in /tmp
|
||||
# owned by other users.
|
||||
self.write_file(path=path, data=data, sudo=False)
|
||||
|
||||
return path
|
||||
|
||||
def write_file(self, path, data, sudo=False, mode=None, owner=None,
|
||||
mkdir=False, append=False):
|
||||
|
Loading…
Reference in New Issue
Block a user