aboutsummaryrefslogtreecommitdiff
path: root/lib/ssh
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-12-17 03:11:46 +0700
committerShulhan <ms@kilabit.info>2023-12-17 03:12:43 +0700
commitcc1b44567b77dda34203f0fcddeecc2d093a2480 (patch)
tree3189bd00f5494db638dbcd359693214356618775 /lib/ssh
parent0d9f916fa0d55c4e7d8044a2b17850791e84041a (diff)
downloadpakakeh.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.go6
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()