From 3acc2aff19b571d9d1bf05126e1bd19d1b6a8bb8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 7 May 2020 12:54:31 +0800 Subject: [PATCH] teuthology/orchestra/remote.py: write remote file without sudo the remote file is created using "ubuntu" user. in ubuntu xenial, superuser is able to write to that file using tar, it seems that "tar" starts another process when writing to the dest file specified by "-f", and that process does not have the privilege for writing that file. so when we are trying to archive a directory on ubuntu/focal test node, we have following error: ``` tar (child): /tmp/tmp.vkl0kAtc06: Cannot open: Permission denied tar (child): Error is not recoverable: exiting now tar: /tmp/tmp.vkl0kAtc06: Cannot write: Broken pipe tar: Child returned status 2 tar: Error is not recoverable: exiting now ``` and this is reproduciable with tar 1.30: ``` $ touch /tmp/helloworld $ mkdir /tmp/foobar $ sudo tar czf /tmp/helloworld -C /tmp/foobar -- . tar (child): /tmp/helloworld: Cannot open: Permission denied tar (child): Error is not recoverable: exiting now tar: /tmp/helloworld: Cannot write: Broken pipe tar: Child returned status 2 tar: Error is not recoverable: exiting now ``` but we can workaround this by writing the temp file using "ubuntu" user, like ``` sudo tar czf - -C /tmp/foobar -- . > /tmp/helloworld ``` Signed-off-by: Kefu Chai --- teuthology/orchestra/remote.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 6bddcc94..aa57b8ed 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -415,10 +415,11 @@ class Remote(object): args.extend([ 'tar', 'cz', - '-f', remote_temp_path, + '-f', '-', '-C', path, '--', '.', + run.Raw('>'), remote_temp_path ]) self.run(args=args) if sudo: -- 2.47.3