mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
Quote any file paths that we have to use with dd to copy.
This is because we pass the whole dd command string into the shell that's running on the contained environment rather than running it directly from python via subprocess without a shell.
This commit is contained in:
parent
b83988d9fb
commit
10a4a4e986
5 changed files with 14 additions and 8 deletions
|
@ -22,6 +22,7 @@ __metaclass__ = type
|
|||
import distutils.spawn
|
||||
import os
|
||||
import os.path
|
||||
import pipes
|
||||
import subprocess
|
||||
import traceback
|
||||
|
||||
|
@ -117,7 +118,7 @@ class Connection(ConnectionBase):
|
|||
super(Connection, self).put_file(in_path, out_path)
|
||||
self._display.vvv("PUT %s TO %s" % (in_path, out_path), host=self.chroot)
|
||||
|
||||
out_path = self._prefix_login_path(out_path)
|
||||
out_path = pipes.quote(self._prefix_login_path(out_path))
|
||||
try:
|
||||
with open(in_path, 'rb') as in_file:
|
||||
try:
|
||||
|
@ -139,7 +140,7 @@ class Connection(ConnectionBase):
|
|||
super(Connection, self).fetch_file(in_path, out_path)
|
||||
self._display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self.chroot)
|
||||
|
||||
in_path = self._prefix_login_path(in_path)
|
||||
in_path = pipes.quote(self._prefix_login_path(in_path))
|
||||
try:
|
||||
p = self._buffered_exec_command('dd if=%s bs=%s' % (in_path, BUFSIZE))
|
||||
except OSError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue