From 9fa909e3df4eaa4efce55b2e46c35101129be5db Mon Sep 17 00:00:00 2001 From: quamrulmina Date: Mon, 12 Oct 2015 19:24:03 -0500 Subject: [PATCH] Remote directory on sftp logon is set to user's home directory #7 Fix the reported problem #7. Remote directory set to remote user's home directory like its is done on openssh on all platforms. Users can then cd to "Documents" directory. Actual fix was to expand "." to user's home directory so that pwd showed it correctly rather than just showing a dot. --- sftp-server.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sftp-server.c b/sftp-server.c index e2a1db4..1f0b510 100644 --- a/sftp-server.c +++ b/sftp-server.c @@ -1283,11 +1283,26 @@ process_realpath(u_int32_t id) //#endif - +#ifndef WIN32_FIXME if (path[0] == '\0') { free(path); path = xstrdup("."); } +#else + if ( (path[0] == '\0') || ( strcmp(path, ".")== 0 ) ) { + free(path); + _getcwd(resolvedname, sizeof(resolvedname)); + // convert back slashes to forward slashes to be compatibale with unix naming + char *cptr = resolvedname; + while (*cptr) { + if (*cptr == '\\') + *cptr = '/' ; + cptr++; + } + path = xstrdup(resolvedname); + } +#endif + debug3("request %u: realpath", id); verbose("realpath \"%s\"", path); if (realpath(path, resolvedname) == NULL) {