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.
This commit is contained in:
quamrulmina 2015-10-12 19:24:03 -05:00
parent 7f3709e11f
commit 9fa909e3df
1 changed files with 16 additions and 1 deletions

View File

@ -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) {