Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/defs.h
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2018-10-21 00:10:32 +0300
committerSimon Tatham <anakin@pobox.com>2018-10-21 12:02:10 +0300
commita081dd0a4ca0f3e99653e371f6ea14d0130a279e (patch)
tree38b47de2c7ca72554ce59437429e4c0736e5e11f /defs.h
parent1d323d5c804eaf7f8ac9e4a80702ded7b6c7bdd2 (diff)
Add an SFTP server to the SSH server code.
Unlike the traditional Unix SSH server organisation, the SFTP server is built into the same process as all the rest of the code. sesschan.c spots a subsystem request for "sftp", and responds to it by instantiating an SftpServer object and swapping out its own vtable for one that talks to it. (I rather like the idea of an object swapping its own vtable for a different one in the middle of its lifetime! This is one of those tricks that would be absurdly hard to implement in a 'proper' OO language, but when you're doing vtables by hand in C, it's no more difficult than any other piece of ordinary pointer manipulation. As long as the methods in both vtables expect the same physical structure layout, it doesn't cause a problem.) The SftpServer object doesn't deal directly with SFTP packet formats; it implements the SFTP server logic in a more abstract way, by having a vtable method for each SFTP request type with an appropriate parameter list. It sends its replies by calling methods in another vtable called SftpReplyBuilder, which in the normal case will write an SFTP reply packet to send back to the client. So SftpServer can focus more or less completely on the details of a particular filesystem API - and hence, the implementation I've got lives in the unix source directory, and works directly with file descriptors and struct stat and the like. (One purpose of this abstraction layer is that I may well want to write a second dummy implementation, for test-suite purposes, with completely controllable behaviour, and now I have a handy place to plug it in in place of the live filesystem.) In between sesschan's parsing of the byte stream into SFTP packets and the SftpServer object, there's a layer in the new file sftpserver.c which does the actual packet decoding and encoding: each request packet is passed to that, which pulls the fields out of the request packet and calls the appropriate method of SftpServer. It also provides the default SftpReplyBuilder which makes the output packet. I've moved some code out of the previous SFTP client implementation - basic packet construction code, and in particular the BinarySink/ BinarySource marshalling fuinction for fxp_attrs - into sftpcommon.c, so that the two directions can share as much as possible.
Diffstat (limited to 'defs.h')
-rw-r--r--defs.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/defs.h b/defs.h
index ed934a13..bf257117 100644
--- a/defs.h
+++ b/defs.h
@@ -61,6 +61,9 @@ typedef struct Frontend Frontend;
typedef struct Ssh Ssh;
+typedef struct SftpServer SftpServer;
+typedef struct SftpServerVtable SftpServerVtable;
+
typedef struct Channel Channel;
typedef struct SshChannel SshChannel;
typedef struct mainchan mainchan;