summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/cephadm/ssh.py
diff options
context:
space:
mode:
authorMichael Fritch <mfritch@suse.com>2021-10-07 18:18:00 +0200
committerMichael Fritch <mfritch@suse.com>2021-10-08 01:55:05 +0200
commit6c57113b1815c70cbe0844ffd1cbfb87d1f9d955 (patch)
tree87a44c3e02a27e30751d34ed518f09ebeaf1853d /src/pybind/mgr/cephadm/ssh.py
parentMerge pull request #43442 from linuxbox2/wip-rgwadmin-logfix (diff)
downloadceph-6c57113b1815c70cbe0844ffd1cbfb87d1f9d955.tar.xz
ceph-6c57113b1815c70cbe0844ffd1cbfb87d1f9d955.zip
mgr/cephadm: use `asyncssh.scp` to write remote files
`tee` via stdin happens to work when the file is a utf-8 byte encoded string, but won't work if the file happens to be binary data Signed-off-by: Michael Fritch <mfritch@suse.com>
Diffstat (limited to 'src/pybind/mgr/cephadm/ssh.py')
-rw-r--r--src/pybind/mgr/cephadm/ssh.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pybind/mgr/cephadm/ssh.py b/src/pybind/mgr/cephadm/ssh.py
index a9d83d7e168..57c3ecd7982 100644
--- a/src/pybind/mgr/cephadm/ssh.py
+++ b/src/pybind/mgr/cephadm/ssh.py
@@ -194,7 +194,12 @@ class SSHManager:
# shlex quote takes str or byte object, not int
await self._check_execute_command(host, ['chown', '-R', str(uid) + ':' + str(gid), tmp_path], addr=addr)
await self._check_execute_command(host, ['chmod', oct(mode)[2:], tmp_path], addr=addr)
- await self._check_execute_command(host, ['tee', '-', tmp_path], stdin=content, addr=addr)
+ with NamedTemporaryFile(prefix='cephadm-write-remote-file-') as f:
+ os.fchmod(f.fileno(), 0o600)
+ f.write(content)
+ f.flush()
+ conn = await self._remote_connection(host, addr)
+ await asyncssh.scp(f.name, (conn, tmp_path))
await self._check_execute_command(host, ['mv', tmp_path, path], addr=addr)
except Exception as e:
msg = f"Unable to write {host}:{path}: {e}"