WinSCP client now works with win32 sftp-server as readlink now supported in Win32 sftp-server

process_readlink() now implemented in Win32 sftp-server and linked
directories can now be read and browsed. as a result opensource WinSCP
client ( it has SFTP and SCP gui clients ) now works with our Win32
sftp-server.
This commit is contained in:
quamrulmina 2015-12-30 18:31:11 -06:00
parent 8c92d7bd95
commit 332890c330
2 changed files with 30 additions and 51 deletions

View File

@ -559,4 +559,11 @@ char * get_inside_path(char * opath, BOOL bResolve, BOOL bMustExist)
return ipath; return ipath;
} }
// if file is symbolic link, copy its link into "link" .
int readlink(const char *path, char *link, int linklen)
{
strcpy_s(link, linklen, path);
return 0;
}
#endif #endif

View File

@ -24,6 +24,10 @@
#ifdef WIN32_FIXME #ifdef WIN32_FIXME
#undef GSSAPI #undef GSSAPI
#undef KRB5 #undef KRB5
#define true 1
#define false 0
#endif #endif
#include <sys/param.h> /* MIN */ #include <sys/param.h> /* MIN */
@ -98,6 +102,7 @@
#define stat(PATH, BUF) _stat(PATH, BUF) #define stat(PATH, BUF) _stat(PATH, BUF)
char * get_inside_path(char *, BOOL, BOOL); char * get_inside_path(char *, BOOL, BOOL);
int readlink(const char *path, char *link, int linklen);
/* /*
* Function to cut last slash (windows * Function to cut last slash (windows
@ -1521,31 +1526,6 @@ if (realpathWin32i(newpath, resolvedname))
static void static void
process_readlink(u_int32_t id) process_readlink(u_int32_t id)
{ {
#ifdef WIN32_FIXME
/*
* Win32 code.
*/
//u_int32_t id;
char *request;
//id = get_int();
#ifndef WIN32_FIXME
// PRAGMA:TODO
request = get_string(NULL);
send_status(id, SSH2_FX_OP_UNSUPPORTED);
free(request);
#endif
#else
/*
* Original OpenSSH code.
*/
int r, len; int r, len;
char buf[PATH_MAX]; char buf[PATH_MAX];
char *path; char *path;
@ -1555,6 +1535,16 @@ process_readlink(u_int32_t id)
debug3("request %u: readlink", id); debug3("request %u: readlink", id);
verbose("readlink \"%s\"", path); verbose("readlink \"%s\"", path);
#ifdef WIN32_FIXME
char resolvedname[MAXPATHLEN];
if (realpathWin32i(path, resolvedname))
{
free(path);
path = strdup(resolvedname);
}
#endif
if ((len = readlink(path, buf, sizeof(buf) - 1)) == -1) if ((len = readlink(path, buf, sizeof(buf) - 1)) == -1)
send_status(id, errno_to_portable(errno)); send_status(id, errno_to_portable(errno));
else { else {
@ -1566,37 +1556,13 @@ process_readlink(u_int32_t id)
send_names(id, 1, &s); send_names(id, 1, &s);
} }
free(path); free(path);
#endif /* WIN32_FIXME */
} }
static void static void
process_symlink(u_int32_t id) process_symlink(u_int32_t id)
{ {
#ifdef WIN32_FIXME
/*
* Win32 code.
*/
//u_int32_t id;
char *request;
//id = get_int();
#ifndef WIN32_FIXME
// PRAGMA:TODO
request = get_string(NULL);
send_status(id, SSH2_FX_OP_UNSUPPORTED);
free(request);
#endif
#else
/*
* Original OpenSSH code.
*/
char *oldpath, *newpath; char *oldpath, *newpath;
int r, status; int r, status;
@ -1606,13 +1572,19 @@ process_symlink(u_int32_t id)
debug3("request %u: symlink", id); debug3("request %u: symlink", id);
logit("symlink old \"%s\" new \"%s\"", oldpath, newpath); logit("symlink old \"%s\" new \"%s\"", oldpath, newpath);
#ifdef WIN32_FIXME
send_status(id, SSH2_FX_OP_UNSUPPORTED);
#else
/* this will fail if 'newpath' exists */ /* this will fail if 'newpath' exists */
r = symlink(oldpath, newpath); r = symlink(oldpath, newpath);
status = (r == -1) ? errno_to_portable(errno) : SSH2_FX_OK; status = (r == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
send_status(id, status); send_status(id, status);
#endif
free(oldpath); free(oldpath);
free(newpath); free(newpath);
#endif
} }
static void static void