Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scp filenames with spaces doesnt work #1077

Closed
staabm opened this issue Mar 9, 2017 · 6 comments
Closed

scp filenames with spaces doesnt work #1077

staabm opened this issue Mar 9, 2017 · 6 comments
Labels

Comments

@staabm
Copy link
Contributor

staabm commented Mar 9, 2017

Q A
Issue Type Bug
Deployer Version 4.2.1
Local Machine OS ubuntu16.04 lts
Remote Machine OS ubuntu16.04 lts
php -v
PHP 7.0.16-4+deb.sury.org~xenial+1 (cli) (built: Mar  2 2017 10:36:04) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.16-4+deb.sury.org~xenial+1, Copyright (c) 1999-2017, by Zend Technologies
    with blackfire v1.15.0~linux-x64-non_zts70, https://blackfire.io, by Blackfireio Inc.

Description

the copy using scp fails, as arguments are not properly escaped.

Steps to reproduce

copy a directory which contains file, containing a space in the filename with the following task

task('deploy:update_code', function () {
    upload('.', '{{release_path}}');
});

Output log

 [Symfony\Component\Process\Exception\ProcessFailedException]
  The command "scp -P '22' -i '/home/mstaab/.ssh/id_rsa' -o ControlMaster=auto -o ControlPersist=5 -o ControlPath='~/.ssh/YYY@XX:22' '/my/local/path/vendor/filp/whoops/docs/Framework Integration.md' 'mstaab@XYX:/my/remote/path/test123/releases/1/vendor/filp/whoops/docs/Framework Integration.md'" failed.
  Exit Code: 1(General error)
  Working directory: /my/local/path/
  Output:
  ================
  Error Output:
  ================
  scp: ambiguous target
@staabm
Copy link
Contributor Author

staabm commented Mar 9, 2017

not 100% sure, but it seem escapeshellarg() is not enough and we also need to escape the space separately

@staabm
Copy link
Contributor Author

staabm commented Mar 9, 2017

maybe this is also a symfony-process related problem @nicolas-grekas ?

@nicolas-grekas
Copy link

I really don't know sorry...

@staabm
Copy link
Contributor Author

staabm commented Mar 9, 2017

the minimal repro is

scp -P '22' -i '/home/mstaab/.ssh/id_rsa' -o ControlMaster=auto -o ControlPersist=5 -o ControlPath='~/.ssh/deployer_mux_mstaab@mst16:22' '/deploy/xx/stage/rocket/vendor/filp/whoops/docs/Framework Integration.md' 'mstaab@mst16:/www/test123/releases/1/vendor/filp/whoops/docs/Framework Integration.md'

scp: ambiguous target

@staabm
Copy link
Contributor Author

staabm commented Mar 9, 2017

Per stackoverflow a solution would be to use double quotes arround the args and escape the spaces

http://stackoverflow.com/questions/19858176/how-to-escape-spaces-in-path-during-scp-copy-in-linux

Basically you need to escape it twice, because it's escaped locally and then on the remote end.

Seems to be the culprit

@staabm
Copy link
Contributor Author

staabm commented Mar 10, 2017

#1010 didn't fix it properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants