Permalink
Browse files

util/managedfile: use /tmp/labgrid-user instead of /tmp/labgrid/user

This change fixes possible permission errors when multiple users push
files to the same host via ManagedFile. The shared /tmp/labgrid
directory usually ends up with 755 permissions, so other users can't
create their own user dirs inside it.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information...
jluebbe committed Oct 18, 2018
1 parent 1e6dc6f commit 2071a82637402fdeb9d380c13ee000e5f259aad7
Showing with 4 additions and 4 deletions.
  1. +1 −1 doc/development.rst
  2. +1 −1 labgrid/util/managedfile.py
  3. +2 −2 tests/test_util.py
View
@@ -393,7 +393,7 @@ the file on the remote host with the following pattern:
.. code-block:: bash
/tmp/labgrid/<username>/<md5sum>/<filename>
/tmp/labgrid-<username>/<md5sum>/<filename>
Additionally it provides `get_remote_path()` to retrieve the complete file path,
to easily employ it for driver implementations.
@@ -42,7 +42,7 @@ def __attrs_post_init__(self):
for block in iter(lambda: f.read(1048576), b''):
hasher.update(block)
self.hash = hasher.hexdigest()
self.rpath = "/tmp/labgrid/{user}/{hash}/".format(
self.rpath = "/tmp/labgrid-{user}/{hash}/".format(
user=username, hash=self.hash
)
View
@@ -229,9 +229,9 @@ def test_remote_managedfile(target, tmpdir):
mf = ManagedFile(t, res)
mf.sync_to_resource()
assert os.path.isfile("/tmp/labgrid/{}/{}/test".format(getpass.getuser(), hash))
assert os.path.isfile("/tmp/labgrid-{}/{}/test".format(getpass.getuser(), hash))
assert hash == mf.get_hash()
assert "/tmp/labgrid/{}/{}/test".format(getpass.getuser(), hash) == mf.get_remote_path()
assert "/tmp/labgrid-{}/{}/test".format(getpass.getuser(), hash) == mf.get_remote_path()
def test_local_managedfile(target, tmpdir):
import hashlib

0 comments on commit 2071a82

Please sign in to comment.