mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-24 14:35:35 +02:00
enabled sftp-server over new POSIX wrapper. not functional yet
This commit is contained in:
parent
5cb9fb09ed
commit
5a47bedd44
@ -73,6 +73,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sftp-server", "sftp-server.
|
||||
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
|
||||
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
|
||||
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
|
||||
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
|
||||
{8660C2FE-9874-432D-B047-E042BB41DBE0} = {8660C2FE-9874-432D-B047-E042BB41DBE0}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -80,21 +80,25 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@ -111,7 +115,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -130,7 +134,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -152,7 +156,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -174,7 +178,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -82,6 +82,7 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
@ -93,11 +94,13 @@
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
125
sftp-server.c
125
sftp-server.c
@ -79,28 +79,6 @@
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
|
||||
#undef select
|
||||
#undef send
|
||||
#undef recv
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
// #define isatty(a) WSHELPisatty(a)
|
||||
|
||||
#define mkdir(a, b) _mkdir(a)
|
||||
|
||||
#define open(NAME, FLAGS, MODE) _open(NAME, FLAGS | O_BINARY, MODE)
|
||||
|
||||
#define close(FD) _close(FD)
|
||||
|
||||
#define write(FD, BUF, LEN) _write(FD, BUF, LEN)
|
||||
|
||||
#define read(FD, BUF, LEN) _read(FD, BUF, LEN)
|
||||
|
||||
#define lstat(PATH, BUF) _stat(PATH, BUF)
|
||||
|
||||
#define stat(PATH, BUF) _stat(PATH, BUF)
|
||||
|
||||
char * get_inside_path(char *, BOOL, BOOL);
|
||||
int readlink(const char *path, char *link, int linklen);
|
||||
|
||||
@ -112,15 +90,6 @@
|
||||
|
||||
#define realpath realpathWin32
|
||||
|
||||
/*
|
||||
* Don't use fstat() function redefined
|
||||
* in socket.h ported header. It is wrong
|
||||
* in this context.
|
||||
*/
|
||||
|
||||
#ifdef fstat
|
||||
#undef fstat
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handle to log file.
|
||||
@ -2202,7 +2171,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
|
||||
fatal("%s: sshbuf_new failed", __func__);
|
||||
if ((oqueue = sshbuf_new()) == NULL)
|
||||
fatal("%s: sshbuf_new failed", __func__);
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
//rset = (fd_set *)xmalloc(sizeof(fd_set));
|
||||
//wset = (fd_set *)xmalloc(sizeof(fd_set));
|
||||
#else
|
||||
@ -2250,52 +2219,52 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
|
||||
fatal("%s: sshbuf_check_reserve failed: %s",
|
||||
__func__, ssh_err(r));
|
||||
|
||||
|
||||
#endif
|
||||
/* send oqueue to stdout */
|
||||
olen = sshbuf_len(oqueue);
|
||||
|
||||
if (olen > 0) {
|
||||
len = _write(out, sshbuf_ptr(oqueue), olen);
|
||||
if (len < 0) {
|
||||
error("write: %s", strerror(errno));
|
||||
sftp_server_cleanup_exit(1);
|
||||
} else if ((r = sshbuf_consume(oqueue, len)) != 0) {
|
||||
fatal("%s: buffer error: %s",
|
||||
__func__, ssh_err(r));
|
||||
}
|
||||
}
|
||||
|
||||
/* copy stdin to iqueue */
|
||||
if ( select_read ) {
|
||||
if ( readsomemore || ( sshbuf_len(iqueue) <= 0)) {
|
||||
len = _read(in, buf, sizeof buf);
|
||||
if (len == 0) {
|
||||
debug("read eof");
|
||||
sftp_server_cleanup_exit(0);
|
||||
} else if (len < 0) {
|
||||
error("read: %s", strerror(errno));
|
||||
sftp_server_cleanup_exit(1);
|
||||
} else if ((r = sshbuf_put(iqueue, buf, len)) != 0) {
|
||||
fatal("%s: buffer error: %s",
|
||||
__func__, ssh_err(r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Process requests from client if we can fit the results
|
||||
* into the output buffer, otherwise stop processing input
|
||||
* and let the output queue drain.
|
||||
*/
|
||||
r = sshbuf_check_reserve(oqueue, SFTP_MAX_MSG_LENGTH);
|
||||
if (r == 0)
|
||||
process();
|
||||
else if (r != SSH_ERR_NO_BUFFER_SPACE)
|
||||
fatal("%s: sshbuf_check_reserve: %s",
|
||||
__func__, ssh_err(r));
|
||||
}
|
||||
#else /* WIN32_FIXME */
|
||||
// olen = sshbuf_len(oqueue);
|
||||
//
|
||||
// if (olen > 0) {
|
||||
// len = _write(out, sshbuf_ptr(oqueue), olen);
|
||||
// if (len < 0) {
|
||||
// error("write: %s", strerror(errno));
|
||||
// sftp_server_cleanup_exit(1);
|
||||
// } else if ((r = sshbuf_consume(oqueue, len)) != 0) {
|
||||
// fatal("%s: buffer error: %s",
|
||||
// __func__, ssh_err(r));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /* copy stdin to iqueue */
|
||||
// if ( select_read ) {
|
||||
// if ( readsomemore || ( sshbuf_len(iqueue) <= 0)) {
|
||||
// len = _read(in, buf, sizeof buf);
|
||||
// if (len == 0) {
|
||||
// debug("read eof");
|
||||
// sftp_server_cleanup_exit(0);
|
||||
// } else if (len < 0) {
|
||||
// error("read: %s", strerror(errno));
|
||||
// sftp_server_cleanup_exit(1);
|
||||
// } else if ((r = sshbuf_put(iqueue, buf, len)) != 0) {
|
||||
// fatal("%s: buffer error: %s",
|
||||
// __func__, ssh_err(r));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*
|
||||
// * Process requests from client if we can fit the results
|
||||
// * into the output buffer, otherwise stop processing input
|
||||
// * and let the output queue drain.
|
||||
// */
|
||||
// r = sshbuf_check_reserve(oqueue, SFTP_MAX_MSG_LENGTH);
|
||||
// if (r == 0)
|
||||
// process();
|
||||
// else if (r != SSH_ERR_NO_BUFFER_SPACE)
|
||||
// fatal("%s: sshbuf_check_reserve: %s",
|
||||
// __func__, ssh_err(r));
|
||||
// }
|
||||
//#else /* WIN32_FIXME */
|
||||
|
||||
olen = sshbuf_len(oqueue);
|
||||
if (olen > 0)
|
||||
@ -2346,5 +2315,5 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
|
||||
fatal("%s: sshbuf_check_reserve: %s",
|
||||
__func__, ssh_err(r));
|
||||
}
|
||||
#endif /* else WIN32 */
|
||||
//#endif /* else WIN32 */
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user