]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commit
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)
commit3acc2aff19b571d9d1bf05126e1bd19d1b6a8bb8
tree6658d0d3dfc06e5fe7303496eaa0f0e292821937
parent422bddb5b698605da39525661c76b73a08b5683e
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 <kchai@redhat.com>
teuthology/orchestra/remote.py