Skip to content

Commit

Permalink
Fix issue with ssh flags used with scp.
Browse files Browse the repository at this point in the history
As the '-p' flag attempt to preserve file attributes
with scp, it was making the scp command fail in
contexts where preserving attributes is not possible
(this is without mentionning the '22' argument that
followed and which seems to be accepted silently).
  • Loading branch information
jraygauthier committed Sep 8, 2016
1 parent 90e23a3 commit 605c09f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nixops/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ def get_ssh_flags(self, scp=False):
else:
return ["-p", str(self.ssh_port)]

def adapt_ssh_flag_for_use_with_scp(self, flags):
# For scp, the "-P" flag is used to specify the port. "-p"
# attempt to preserve file attributes.
return (map (lambda x: '-P' if x == '-p' else x, flags))

def get_ssh_password(self):
return None
Expand Down Expand Up @@ -353,15 +357,15 @@ def generate_vpn_key(self, check=False):

def upload_file(self, source, target, recursive=False):
master = self.ssh.get_master()
cmdline = ["scp"] + self.get_ssh_flags(True) + master.opts
cmdline = ["scp"] + self.adapt_ssh_flag_for_use_with_scp(master.opts)
if recursive:
cmdline += ['-r']
cmdline += [source, "root@" + self.get_ssh_name() + ":" + target]
return self._logged_exec(cmdline)

def download_file(self, source, target, recursive=False):
master = self.ssh.get_master()
cmdline = ["scp"] + self.get_ssh_flags(True) + master.opts
cmdline = ["scp"] + self.adapt_ssh_flag_for_use_with_scp(master.opts)
if recursive:
cmdline += ['-r']
cmdline += ["root@" + self.get_ssh_name() + ":" + source, target]
Expand Down

0 comments on commit 605c09f

Please sign in to comment.