summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-10-13 10:23:06 +0100
committerLars Wirzenius <liw@liw.fi>2013-10-13 10:23:06 +0100
commit225002076de1643a00a4a2763c08704ceb03e993 (patch)
tree7383e9cc46a581d1385564765fdb4625c0c7665a
parent91fbf31274715a62a1fe6d2f8278c29bda403ab7 (diff)
downloadobnam-225002076de1643a00a4a2763c08704ceb03e993.tar.gz
Fix /~/ path prefix in SFTP URLs
Reported-by: Lars Kruse
-rw-r--r--NEWS4
-rw-r--r--obnamlib/plugins/sftp_plugin.py2
-rwxr-xr-xtest-sftpfs18
3 files changed, 23 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 38470051..62e9a7ce 100644
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,10 @@ Bug fixes:
* Obnam's manual page now explains about breaking long logical lines
into multiple physical ones.
+* The `/~/` path prefix in SFTP URLs works again, at least with
+ sufficiently new versions of Paramiko (1.7.7.1 in Debian wheezy is
+ OK). Reported by Lars Kruse.
+
Version 1.5, released 2013-08-08
--------------------------------
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py
index 576ba7e8..b0b6e08b 100644
--- a/obnamlib/plugins/sftp_plugin.py
+++ b/obnamlib/plugins/sftp_plugin.py
@@ -147,7 +147,7 @@ class SftpFS(obnamlib.VirtualFileSystem):
self._connect_paramiko()
if self.create_path_if_missing:
self._create_root_if_missing()
- self.chdir(self.path)
+ self.chdir('.')
self._initial_dir = self.getcwd()
self.chdir(self.path)
diff --git a/test-sftpfs b/test-sftpfs
index ee725b70..52f7e369 100755
--- a/test-sftpfs
+++ b/test-sftpfs
@@ -28,6 +28,7 @@ ssh connections using the ssh agent.
import logging
import os
+import pwd
import shutil
import tempfile
import unittest
@@ -60,6 +61,23 @@ class SftpTests(unittest.TestCase, obnamlib.VfsTests):
def test_sets_path_to_absolute_path(self):
self.assert_(self.fs.path.startswith('/'))
+ def test_resolves_magic_homedir_prefix(self):
+ baseurl = 'sftp://localhost/~/'
+ settings = {
+ 'pure-paramiko': False,
+ 'create': True,
+ 'sftp-delay': 0,
+ 'ssh-key': '',
+ 'strict-ssh-host-keys': False,
+ 'ssh-known-hosts': os.path.expanduser('~/.ssh/known_hosts'),
+ }
+ fs = obnamlib.plugins.sftp_plugin.SftpFS(baseurl, settings=settings)
+ fs.connect()
+
+ homedir = pwd.getpwuid(os.getuid()).pw_dir
+ self.assertEqual(fs._initial_dir, homedir)
+ self.assertEqual(fs.getcwd(), homedir)
+
def test_initial_cwd_is_basepath(self):
self.assertEqual(self.fs.getcwd(), self.fs.path)