Spaces cause failures when using put and use_sudo #955

Closed
johnharris85 opened this Issue Aug 13, 2013 · 2 comments

Projects

None yet

2 participants

@johnharris85

sftp.py (line 109):

def mkdir(self, path, use_sudo):
    from fabric.api import sudo, hide
    if use_sudo:
        with hide('everything'):
            sudo('mkdir %s' % path)

The issue here is that if use_sudo=True then mkdir will break if path contains spaces. I changed it to:

def mkdir(self, path, use_sudo):
    from fabric.api import sudo, hide
    if use_sudo:
        with hide('everything'):
            sudo('mkdir "%s"' % path)

Now it works OK. Untested but solved my issue, may cause problems for others.

@bitprophet
Member

I feel like this should cause issues for non-sudo invocation as well - have you tested that out? Either way, agree quoting is probably useful here; we quote a few other similar places IIRC so there's likely precedent.

@bitprophet
Member

Not sure why I said non sudo invocations would cause issues here, clearly the non sudo situation is handled natively by SFTP. Derp.

Wrote up an integration test proving this & applied the above fix. We may want to make this even more robust in the future for things like tilde escaping, but this suffices for now. Will merge into 1.7.x and 1.8.x momentarily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment