Skip to content

Commit 9fa909e

Browse files
committed
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.
1 parent 7f3709e commit 9fa909e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

sftp-server.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,11 +1283,26 @@ process_realpath(u_int32_t id)
12831283
//#endif
12841284

12851285

1286-
1286+
#ifndef WIN32_FIXME
12871287
if (path[0] == '\0') {
12881288
free(path);
12891289
path = xstrdup(".");
12901290
}
1291+
#else
1292+
if ( (path[0] == '\0') || ( strcmp(path, ".")== 0 ) ) {
1293+
free(path);
1294+
_getcwd(resolvedname, sizeof(resolvedname));
1295+
// convert back slashes to forward slashes to be compatibale with unix naming
1296+
char *cptr = resolvedname;
1297+
while (*cptr) {
1298+
if (*cptr == '\\')
1299+
*cptr = '/' ;
1300+
cptr++;
1301+
}
1302+
path = xstrdup(resolvedname);
1303+
}
1304+
#endif
1305+
12911306
debug3("request %u: realpath", id);
12921307
verbose("realpath \"%s\"", path);
12931308
if (realpath(path, resolvedname) == NULL) {

0 commit comments

Comments
 (0)