summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--paramiko/sftp_server.py4
-rw-r--r--paramiko/sftp_si.py30
-rwxr-xr-xtests/test_sftp.py1
3 files changed, 35 insertions, 0 deletions
diff --git a/paramiko/sftp_server.py b/paramiko/sftp_server.py
index 22c1f39e..11f12c85 100644
--- a/paramiko/sftp_server.py
+++ b/paramiko/sftp_server.py
@@ -324,6 +324,10 @@ class SFTPServer (BaseSFTP, SubsystemHandler):
self._response(request_number, CMD_NAME, 1, resp, '', SFTPAttributes())
else:
self._send_status(request_number, resp)
+ elif t == CMD_SYMLINK:
+ path = msg.get_string()
+ target_path = msg.get_string()
+ self._send_status(request_number, self.server.symlink(path, target_path))
elif t == CMD_REALPATH:
path = msg.get_string()
rpath = self.server.canonicalize(path)
diff --git a/paramiko/sftp_si.py b/paramiko/sftp_si.py
index 3f77a3fb..a65073b4 100644
--- a/paramiko/sftp_si.py
+++ b/paramiko/sftp_si.py
@@ -261,3 +261,33 @@ class SFTPServerInterface (object):
else:
return os.path.normpath('/' + path)
+ def readlink(self, path):
+ """
+ Return the target of a symbolic link (or shortcut) on the server.
+ If the specified path doesn't refer to a symbolic link, an error
+ should be returned.
+
+ @param path: path (relative or absolute) of the symbolic link.
+ @type path: str
+ @return: the target path of the symbolic link, or an error code like
+ L{SFTP_NO_SUCH_FILE}.
+ @rtype: str I{or error code}
+ """
+ return SFTP_OP_UNSUPPORTED
+
+ def symlink(self, path, target_path):
+ """
+ Create a symbolic link on the server, as new pathname C{path},
+ with C{target_path} as the target of the link.
+
+ @param path: path (relative or absolute) of the symbolic link to
+ create.
+ @type path: str
+ @param target_path: path (relative or absolute) of the target for
+ this new symbolic link.
+ @type target_path: str
+ @return: an error code like C{SFTP_OK}.
+ @rtype: int
+ """
+ return SFTP_OP_UNSUPPORTED
+
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index 64334fbc..eebb2184 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -295,6 +295,7 @@ class SFTPTest (unittest.TestCase):
self.assertEqual(f.readlines(), [ 'original\n' ])
f.close()
self.assertEqual(sftp.lstat(FOLDER + '/link.txt').st_size, 12)
+ self.assertEqual(sftp.stat(FOLDER + '/link.txt').st_size, 9)
self.assertEqual(sftp.stat(FOLDER + '/original.txt').st_size, 9)
finally:
try: