ssh backend does not work with folders containing 'open' (lp:#933388)

[Original report](https://bugs.launchpad.net/bugs/933388) created by **Peter Meier (peter-meier)**
```
I'm not able to use duplicity on folders containing the word open.

It looks like the client is cutting of everything from open on:

Does not work:
sftp command: 'mkdir "open@example.com"'
State = sftp, Before = 'mkdir "' <- folder name is missing

Works:
sftp command: 'mkdir "foo@example.com"'
State = sftp, Before = 'mkdir "foo@example.com" <- folder name is here

Does not work:
sftp command: 'mkdir "foopenbar@example.com"'
State = sftp, Before = 'mkdir "fo' <- folder name is only partially
present.

It does also not work on a folder just called fooopenbar or simply open.

Full debug runs attached.

1st does not work
2nd works
3rd does not work

This started to appear after upgrading from 0.6.11 to 0.6.17.

Other folders, not containing the word open, work fine.

# ssh sndsite@10.x.x rm -rf /tmp/open@example.com
# PASSPHRASE="foobar" duplicity cleanup --extra-clean --force
ssh://sndsite@10.x.x.x//tmp/open@example.com -v9
Using archive dir: /root/.cache/duplicity/fc444e6ac9d9df55ca0cb73588b1a453
Using backup name: fc444e6ac9d9df55ca0cb73588b1a453
Import of duplicity.backends.tahoebackend Succeeded
Import of duplicity.backends.imapbackend Succeeded
Import of duplicity.backends.botobackend Failed: No module named py
Import of duplicity.backends.rsyncbackend Succeeded
Import of duplicity.backends.giobackend Failed: No module named gio
Import of duplicity.backends.ftpbackend Succeeded
Import of duplicity.backends.localbackend Succeeded
Import of duplicity.backends.sshbackend Succeeded
Import of duplicity.backends.ftpsbackend Succeeded
Import of duplicity.backends.hsibackend Succeeded
Import of duplicity.backends.cloudfilesbackend Succeeded
Import of duplicity.backends.webdavbackend Succeeded
Import of duplicity.backends.u1backend Succeeded
Import of duplicity.backends.gdocsbackend Succeeded
Main action: cleanup
================================================================================
duplicity 0.6.17 (November 25, 2011)
Args: /usr/bin/duplicity cleanup --extra-clean --force
ssh://sndsite@10.x.x.x//tmp/open@example.com -v9
Linux foo.example.com 2.6.18-274.17.1.el5xen #1 SMP Tue Jan 10 18:06:37 EST
2012 x86_64 x86_64
/usr/bin/python 2.4.3 (#1, Sep 21 2011, 19:55:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)]
================================================================================
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #1)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "open@example.com"'
State = sftp, Before = 'mkdir "open@example.com"'
sftp command: 'cd "open@example.com"'
State = sftp, Before = 'cd "open@example.com"'
sftp command: 'ls -1'
State = sftp, Before = 'ls -1'
State = sftp, Before = 'quit'
finished sftp command: 'quit'
Local and Remote metadata are synchronized, no sync needed.
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #1)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "open@example.com"'
State = sftp, Before = 'mkdir "'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "open@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #1)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #2)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "open@example.com"'
State = sftp, Before = 'mkdir "'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "open@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #2)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #3)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "open@example.com"'
State = sftp, Before = 'mkdir "'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "open@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #3)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #4)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "open@example.com"'
State = sftp, Before = 'mkdir "'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "open@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #4)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #5)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "open@example.com"'
State = sftp, Before = 'mkdir "'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "open@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #5)
Giving up trying to execute 'sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x' after 5 attempts
Using temporary directory /tmp/duplicity-yyyhfe-tempdir
Backend error detail: Traceback (most recent call last):
  File "/usr/bin/duplicity", line 1377, in ?
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1370, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1250, in main
    globals.archive_dir).set_values()
  File "/usr/lib64/python2.4/site-packages/duplicity/collections.py", line
673, in set_values
    backend_filename_list = self.backend.list()
  File "/usr/lib64/python2.4/site-
packages/duplicity/backends/sshbackend.py", line 296, in list
    l = self.run_sftp_command(commandline, commands).split('\n')[1:]
  File "/usr/lib64/python2.4/site-
packages/duplicity/backends/sshbackend.py", line 214, in run_sftp_command
    raise BackendException("Error running '%s'" % commandline)
BackendException: Error running 'sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'

BackendException: Error running 'sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'

---------------------------------

# ssh sndsite@10.x.x.x rm -rf /tmp/foo@example.com
# PASSPHRASE="foo" duplicity cleanup --extra-clean --force
ssh://sndsite@10.x.x.x//tmp/foo@example.com -v9
Using archive dir: /root/.cache/duplicity/146f6826f86449fc656e5f1778130372
Using backup name: 146f6826f86449fc656e5f1778130372
Import of duplicity.backends.tahoebackend Succeeded
Import of duplicity.backends.imapbackend Succeeded
Import of duplicity.backends.botobackend Failed: No module named py
Import of duplicity.backends.rsyncbackend Succeeded
Import of duplicity.backends.giobackend Failed: No module named gio
Import of duplicity.backends.ftpbackend Succeeded
Import of duplicity.backends.localbackend Succeeded
Import of duplicity.backends.sshbackend Succeeded
Import of duplicity.backends.ftpsbackend Succeeded
Import of duplicity.backends.hsibackend Succeeded
Import of duplicity.backends.cloudfilesbackend Succeeded
Import of duplicity.backends.webdavbackend Succeeded
Import of duplicity.backends.u1backend Succeeded
Import of duplicity.backends.gdocsbackend Succeeded
Main action: cleanup
================================================================================
duplicity 0.6.17 (November 25, 2011)
Args: /usr/bin/duplicity cleanup --extra-clean --force
ssh://sndsite@10.x.x.x//tmp/foo@example.com -v9
Linux foo.example.com 2.6.18-274.17.1.el5xen #1 SMP Tue Jan 10 18:06:37 EST
2012 x86_64 x86_64
/usr/bin/python 2.4.3 (#1, Sep 21 2011, 19:55:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)]
================================================================================
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #1)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foo@example.com"'
State = sftp, Before = 'mkdir "foo@example.com"'
sftp command: 'cd "foo@example.com"'
State = sftp, Before = 'cd "foo@example.com"'
sftp command: 'ls -1'
State = sftp, Before = 'ls -1'
State = sftp, Before = 'quit'
finished sftp command: 'quit'
Local and Remote metadata are synchronized, no sync needed.
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #1)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foo@example.com"'
State = sftp, Before = 'mkdir "foo@example.com"
Couldn't create directory: Failure'
sftp command: 'cd "foo@example.com"'
State = sftp, Before = 'cd "foo@example.com"'
sftp command: 'ls -1'
State = sftp, Before = 'ls -1'
State = sftp, Before = 'quit'
finished sftp command: 'quit'
0 files exist on backend
0 files exist in cache
Extracting backup chains from list of files: []
Last full backup date: none
Collection Status
-----------------
Connecting with backend: SSHBackend
Archive dir: /root/.cache/duplicity/146f6826f86449fc656e5f1778130372

Found 0 secondary backup chains.
No backup chains with active signatures found
No orphaned or incomplete backup sets found.
No extraneous files found, nothing deleted in cleanup.
Using temporary directory /tmp/duplicity-5qFONA-tempdir

---------


# ssh sndsite@10.x.x.x rm -rf /tmp/foopenbar@example.com
# PASSPHRASE="foo" duplicity cleanup --extra-clean --force
ssh://sndsite@10.x.x.x//tmp/foopenbar@example.com -v9
Using archive dir: /root/.cache/duplicity/3ffaa9979263a074b0e8a8869a91a549
Using backup name: 3ffaa9979263a074b0e8a8869a91a549
Import of duplicity.backends.tahoebackend Succeeded
Import of duplicity.backends.imapbackend Succeeded
Import of duplicity.backends.botobackend Failed: No module named py
Import of duplicity.backends.rsyncbackend Succeeded
Import of duplicity.backends.giobackend Failed: No module named gio
Import of duplicity.backends.ftpbackend Succeeded
Import of duplicity.backends.localbackend Succeeded
Import of duplicity.backends.sshbackend Succeeded
Import of duplicity.backends.ftpsbackend Succeeded
Import of duplicity.backends.hsibackend Succeeded
Import of duplicity.backends.cloudfilesbackend Succeeded
Import of duplicity.backends.webdavbackend Succeeded
Import of duplicity.backends.u1backend Succeeded
Import of duplicity.backends.gdocsbackend Succeeded
Main action: cleanup
================================================================================
duplicity 0.6.17 (November 25, 2011)
Args: /usr/bin/duplicity cleanup --extra-clean --force
ssh://sndsite@10.x.x.x//tmp/foopenbar@example.com -v9
Linux foo.example.com 2.6.18-274.17.1.el5xen #1 SMP Tue Jan 10 18:06:37 EST
2012 x86_64 x86_64
/usr/bin/python 2.4.3 (#1, Sep 21 2011, 19:55:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)]
================================================================================
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #1)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foopenbar@example.com"'
State = sftp, Before = 'mkdir "foopenbar@example.com"'
sftp command: 'cd "foopenbar@example.com"'
State = sftp, Before = 'cd "foopenbar@example.com"'
sftp command: 'ls -1'
State = sftp, Before = 'ls -1'
State = sftp, Before = 'quit'
finished sftp command: 'quit'
Local and Remote metadata are synchronized, no sync needed.
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #1)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foopenbar@example.com"'
State = sftp, Before = 'mkdir "fo'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "foopenbar@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #1)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #2)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foopenbar@example.com"'
State = sftp, Before = 'mkdir "fo'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "foopenbar@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #2)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #3)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foopenbar@example.com"'
State = sftp, Before = 'mkdir "fo'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "foopenbar@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #3)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #4)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foopenbar@example.com"'
State = sftp, Before = 'mkdir "fo'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "foopenbar@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #4)
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' (attempt #5)
State = sftp, Before = 'Connecting to 10.x.x.x...'
sftp command: 'mkdir "/tmp"'
State = sftp, Before = 'mkdir "/tmp"
Couldn't create directory: Failure'
sftp command: 'cd "/tmp"'
State = sftp, Before = 'cd "/tmp"'
sftp command: 'mkdir "foopenbar@example.com"'
State = sftp, Before = 'mkdir "fo'
Could not open file in command='sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
finished sftp command: 'mkdir "foopenbar@example.com"'
Running 'sftp  -oServerAliveInterval=15 -oServerAliveCountMax=2
sndsite@10.x.x.x' failed (attempt #5)
Giving up trying to execute 'sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x' after 5 attempts
Using temporary directory /tmp/duplicity-EjrBlY-tempdir
Backend error detail: Traceback (most recent call last):
  File "/usr/bin/duplicity", line 1377, in ?
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1370, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1250, in main
    globals.archive_dir).set_values()
  File "/usr/lib64/python2.4/site-packages/duplicity/collections.py", line
673, in set_values
    backend_filename_list = self.backend.list()
  File "/usr/lib64/python2.4/site-
packages/duplicity/backends/sshbackend.py", line 296, in list
    l = self.run_sftp_command(commandline, commands).split('\n')[1:]
  File "/usr/lib64/python2.4/site-
packages/duplicity/backends/sshbackend.py", line 214, in run_sftp_command
    raise BackendException("Error running '%s'" % commandline)
BackendException: Error running 'sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'

BackendException: Error running 'sftp  -oServerAliveInterval=15
-oServerAliveCountMax=2 sndsite@10.x.x.x'
```

Story points: 6.0