diff options
| author | Shulhan <ms@kilabit.info> | 2023-12-17 03:11:46 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-12-17 03:12:43 +0700 |
| commit | cc1b44567b77dda34203f0fcddeecc2d093a2480 (patch) | |
| tree | 3189bd00f5494db638dbcd359693214356618775 /lib/ssh | |
| parent | 0d9f916fa0d55c4e7d8044a2b17850791e84041a (diff) | |
| download | pakakeh.go-cc1b44567b77dda34203f0fcddeecc2d093a2480.tar.xz | |
ssh/sftp: fix Stat on empty remote file name
The implementation of SSH server for Stat is not consistent with
the RFC.
The RFC mentioned that
An empty path name is valid, and it refers to the user's default
directory (usually the user's home directory).
But this only working on some command, like Mkdir, but not Stat.
Diffstat (limited to 'lib/ssh')
| -rw-r--r-- | lib/ssh/sftp/client.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ssh/sftp/client.go b/lib/ssh/sftp/client.go index 215bf406..47364f4f 100644 --- a/lib/ssh/sftp/client.go +++ b/lib/ssh/sftp/client.go @@ -580,7 +580,13 @@ func (cl *Client) Setstat(remoteFile string, fa *FileAttrs) (err error) { // Stat get the file attributes based on the remote file path. // This method follow symbolic links. +// +// To stat the user's home directory pass empty string or '.' in remoteFile +// parameter. func (cl *Client) Stat(remoteFile string) (fa *FileAttrs, err error) { + if remoteFile == `` { + remoteFile = `.` + } var ( logp = "Stat" req = cl.generatePacket() |
