]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
teuthology/orchestra/remote.py: write remote file without sudo 1465/head
authorKefu Chai <kchai@redhat.com>
Thu, 7 May 2020 04:54:31 +0000 (12:54 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 7 May 2020 05:02:45 +0000 (13:02 +0800)
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 <kchai@redhat.com>
teuthology/orchestra/remote.py

index 6bddcc947207df231126e4cb41981aff9af4b1fe..aa57b8ed28fe6d0ddab65a38024a04320f434c82 100644 (file)
@@ -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: