Complete merge.

This commit is contained in:
Ray Hayes 2016-10-24 10:19:04 -07:00
commit a4e013b414
32 changed files with 950 additions and 1477 deletions

12
.gitignore vendored
View File

@ -277,5 +277,17 @@ Makefile.in
d2utmpa* d2utmpa*
configure configure
contrib/win32/openssh/Win32-OpenSSH.VC.opendb contrib/win32/openssh/Win32-OpenSSH.VC.opendb
contrib/win32/openssh/Win32-OpenSSH.VC.db
*.opendb *.opendb
*.db *.db
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

View File

@ -1632,6 +1632,9 @@
#define HAVE_STRNCASECMP 1 #define HAVE_STRNCASECMP 1
#endif #endif
/* Define to 1 if you have the locale.h header. */
#define HAVE_LOCALE_H 1
#define HAVE_STRUCT_IN6_ADDR 1 #define HAVE_STRUCT_IN6_ADDR 1
#define HAVE_STRUCT_SOCKADDR_IN6 1 #define HAVE_STRUCT_SOCKADDR_IN6 1
#define HAVE_STRUCT_TIMEVAL 1 #define HAVE_STRUCT_TIMEVAL 1
@ -1725,6 +1728,6 @@ typedef long ssize_t;
#define HAVE_MBLEN 1 #define HAVE_MBLEN 1
#define SSHDIR "." #define SSHDIR "."
#define _PATH_SFTP_SERVER "./sftp-server.exe" #define _PATH_SFTP_SERVER "sftp-server.exe"
#define _PATH_SSH_PROGRAM "./ssh.exe" #define _PATH_SSH_PROGRAM "ssh.exe"
#define _PATH_LS "dir" #define _PATH_LS "dir"

View File

@ -4,10 +4,12 @@
<OpenSSH-Src-Path>$(SolutionDir)..\..\..\</OpenSSH-Src-Path> <OpenSSH-Src-Path>$(SolutionDir)..\..\..\</OpenSSH-Src-Path>
<OpenSSH-Bin-Path>$(SolutionDir)..\..\..\bin\</OpenSSH-Bin-Path> <OpenSSH-Bin-Path>$(SolutionDir)..\..\..\bin\</OpenSSH-Bin-Path>
<OpenSSH-Lib-Path>$(SolutionDir)lib\</OpenSSH-Lib-Path> <OpenSSH-Lib-Path>$(SolutionDir)lib\</OpenSSH-Lib-Path>
<OpenSSL-Path>$(SolutionDir)..\..\..\..\OpenSSL\1.0.2d\VS2015\</OpenSSL-Path> <OpenSSL-Path>g:\openssl-1.0.2h-x64\OpenSSLInstallx64_vs2015-debug\</OpenSSL-Path>
<OpenSSL-Win32-Release-Path>$(SolutionDir)..\..\..\..\OpenSSL\1.0.2d\VS2015\Win32\Release\</OpenSSL-Win32-Release-Path> <OpenSSL-Win32-Release-Path>g:\openssl-1.0.2h-x86\OpenSSLInstallx86_vs2015\</OpenSSL-Win32-Release-Path>
<OpenSSL-Win32-Debug-Path>$(SolutionDir)..\..\..\..\OpenSSL\1.0.2d\VS2015\Win32\Debug\</OpenSSL-Win32-Debug-Path> <OpenSSL-Win32-Debug-Path>g:\openssl-1.0.2h-x86\OpenSSLInstallx86_vs2015-debug\</OpenSSL-Win32-Debug-Path>
<OpenSSL-x64-Release-Path>$(SolutionDir)..\..\..\..\OpenSSL\1.0.2d\VS2015\x64\Release\</OpenSSL-x64-Release-Path> <OpenSSL-x64-Release-Path>g:\openssl-1.0.2h-x64\OpenSSLInstallx64_vs2015\</OpenSSL-x64-Release-Path>
<OpenSSL-x64-Debug-Path>$(SolutionDir)..\..\..\..\OpenSSL\1.0.2d\VS2015\x64\Debug\</OpenSSL-x64-Debug-Path> <OpenSSL-x64-Debug-Path>g:\openssl-1.0.2h-x64\OpenSSLInstallx64_vs2015-debug\</OpenSSL-x64-Debug-Path>
<OpenSSL-x86-ARM-Release-Path>g:\openssl-1.0.2h-arm-x86\OpenSSLInstallx86_vs2015\</OpenSSL-x86-ARM-Release-Path>
<OpenSSL-x86-ARM-Debug-Path>g:\openssl-1.0.2h-arm-x86\OpenSSLInstallx86_vs2015\</OpenSSL-x86-ARM-Debug-Path>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -21,6 +21,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="$(OpenSSH-Src-Path)scp.c" /> <ClCompile Include="$(OpenSSH-Src-Path)scp.c" />
<ClCompile Include="$(OpenSSH-Src-Path)win32_dirent.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="version.rc" /> <ResourceCompile Include="version.rc" />
@ -116,6 +117,7 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>
@ -135,6 +137,7 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>
@ -158,6 +161,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>
@ -181,6 +185,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>

View File

@ -18,6 +18,9 @@
<ClCompile Include="$(OpenSSH-Src-Path)scp.c"> <ClCompile Include="$(OpenSSH-Src-Path)scp.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)win32_dirent.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="version.rc"> <ResourceCompile Include="version.rc">

View File

@ -23,6 +23,7 @@
<ClCompile Include="$(OpenSSH-Src-Path)sftp-common.c" /> <ClCompile Include="$(OpenSSH-Src-Path)sftp-common.c" />
<ClCompile Include="$(OpenSSH-Src-Path)sftp-server-main.c" /> <ClCompile Include="$(OpenSSH-Src-Path)sftp-server-main.c" />
<ClCompile Include="$(OpenSSH-Src-Path)sftp-server.c" /> <ClCompile Include="$(OpenSSH-Src-Path)sftp-server.c" />
<ClCompile Include="$(OpenSSH-Src-Path)win32_dirent.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="version.rc" /> <ResourceCompile Include="version.rc" />
@ -119,6 +120,7 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>

View File

@ -24,6 +24,9 @@
<ClCompile Include="$(OpenSSH-Src-Path)sftp-server.c"> <ClCompile Include="$(OpenSSH-Src-Path)sftp-server.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)win32_dirent.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="version.rc"> <ResourceCompile Include="version.rc">

View File

@ -25,6 +25,7 @@
<ClCompile Include="$(OpenSSH-Src-Path)sftp-common.c" /> <ClCompile Include="$(OpenSSH-Src-Path)sftp-common.c" />
<ClCompile Include="$(OpenSSH-Src-Path)sftp-glob.c" /> <ClCompile Include="$(OpenSSH-Src-Path)sftp-glob.c" />
<ClCompile Include="$(OpenSSH-Src-Path)sftp.c" /> <ClCompile Include="$(OpenSSH-Src-Path)sftp.c" />
<ClCompile Include="$(OpenSSH-Src-Path)win32_dirent.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="version.rc" /> <ResourceCompile Include="version.rc" />
@ -121,6 +122,7 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>
@ -141,6 +143,7 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>
@ -164,6 +167,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>
@ -187,6 +191,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>Netapi32.lib;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> <AdditionalDependencies>Netapi32.lib;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> <AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
</Link> </Link>

View File

@ -30,6 +30,9 @@
<ClCompile Include="$(OpenSSH-Src-Path)sftp.c"> <ClCompile Include="$(OpenSSH-Src-Path)sftp.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(OpenSSH-Src-Path)win32_dirent.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="version.rc"> <ResourceCompile Include="version.rc">

View File

@ -150,8 +150,10 @@
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigalrm.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigalrm.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigchld.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigchld.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32log.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32log.c" />
<ClCompile Include="..\win32compat\pwd.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\pwd.c" />
<ClCompile Include="..\win32compat\wmain.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\wmain.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
@ -170,9 +172,12 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dlfcn.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dlfcn.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\syslog.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\syslog.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_internal.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_internal.h" />
<ClInclude Include="..\win32compat\inc\pwd.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\pwd.h" />
<ClInclude Include="..\win32compat\inc\sys\param.h" />
<ClInclude Include="..\win32compat\inc\utf.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\param.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\utf.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -10,8 +10,10 @@
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigalrm.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigalrm.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigchld.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_sigchld.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32log.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32log.c" />
<ClCompile Include="..\win32compat\pwd.c" /> <ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\pwd.c" />
<ClCompile Include="..\win32compat\wmain.c" />
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\wmain.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
@ -54,14 +56,22 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dlfcn.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\dlfcn.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\syslog.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\syslog.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_internal.h" /> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\signal_internal.h" />
<ClInclude Include="..\win32compat\inc\pwd.h"> <ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\pwd.h">
<Filter>inc</Filter> <Filter>inc</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\win32compat\inc\sys\param.h">
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\param.h">
<Filter>inc\sys</Filter> <Filter>inc\sys</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\win32compat\inc\utf.h">
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\utf.h">
<Filter>inc</Filter> <Filter>inc</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -559,8 +559,15 @@ fileio_fstat(struct w32_io* pio, struct _stat64 *buf) {
int int
fileio_stat(const char *path, struct _stat64 *buf) { fileio_stat(const char *path, struct _stat64 *buf) {
/* TODO - path is UTD -8, support unicode*/ wchar_t wpath[MAX_PATH];
return _stat64(path, buf); wchar_t* wtmp = NULL;
if ((wtmp = utf8_to_utf16(path)) == NULL)
fatal("failed to covert input arguments");
wcscpy(&wpath[0], wtmp);
free(wtmp);
return _wstat64(wpath, buf);
} }
long long

View File

@ -50,6 +50,7 @@
#define W32_SIGWINCH 11 #define W32_SIGWINCH 11
#define W32_SIGMAX 12 #define W32_SIGMAX 12
#define W32_SIGSTOP 13
/* singprocmask "how" codes*/ /* singprocmask "how" codes*/
#define SIG_BLOCK 0 #define SIG_BLOCK 0

View File

@ -11,4 +11,8 @@
#define O_TRUNC 0x0200 // open and truncate #define O_TRUNC 0x0200 // open and truncate
#define O_EXCL 0x0400 // open only if file doesn't already exist #define O_EXCL 0x0400 // open only if file doesn't already exist
#define O_BINARY 0x8000 // file mode is binary (untranslated) #define O_TEXT 0x4000 /* file mode is text (translated) */
#define O_BINARY 0x8000 /* file mode is binary (untranslated) */
#define O_WTEXT 0x10000 /* file mode is UTF16 (translated) */
#define O_U16TEXT 0x20000 /* file mode is UTF16 no BOM (translated) */
#define O_U8TEXT 0x40000 /* file mode is UTF8 no BOM (translated) */

View File

@ -12,6 +12,7 @@
#define mysignal(a,b) w32_signal((a), (b)) #define mysignal(a,b) w32_signal((a), (b))
#define raise(a) w32_raise(a) #define raise(a) w32_raise(a)
#define kill(a,b) w32_kill((a), (b)) #define kill(a,b) w32_kill((a), (b))
#define ftruncate(a, b) w32_ftruncate((a), (b))
#define sigprocmask(a,b,c) w32_sigprocmask((a), (b), (c)) #define sigprocmask(a,b,c) w32_sigprocmask((a), (b), (c))
#define SIGINT W32_SIGINT #define SIGINT W32_SIGINT
@ -26,6 +27,7 @@
#define SIGTTIN W32_SIGTTIN #define SIGTTIN W32_SIGTTIN
#define SIGTTOU W32_SIGTTOU #define SIGTTOU W32_SIGTTOU
#define SIGWINCH W32_SIGWINCH #define SIGWINCH W32_SIGWINCH
#define SIGSTOP W32_SIGSTOP
#define SIG_DFL W32_SIG_DFL #define SIG_DFL W32_SIG_DFL
#define SIG_IGN W32_SIG_IGN #define SIG_IGN W32_SIG_IGN

View File

@ -29,6 +29,8 @@
#define stat w32_stat #define stat w32_stat
#define lstat w32_stat #define lstat w32_stat
#define mkdir w32_mkdir #define mkdir w32_mkdir
#define chdir w32_chdir
#define getcwd w32_getcwd
struct w32_stat { struct w32_stat {
dev_t st_dev; /* ID of device containing file */ dev_t st_dev; /* ID of device containing file */

View File

@ -13,5 +13,7 @@
#define WIFSIGNALED(w) FALSE #define WIFSIGNALED(w) FALSE
#define WEXITSTATUS(w) w #define WEXITSTATUS(w) w
#define WTERMSIG(w) -1 #define WTERMSIG(w) -1
#define WNOHANG 1
#define WUNTRACED 2
int waitpid(int pid, int *status, int options); int waitpid(int pid, int *status, int options);

View File

@ -24,6 +24,7 @@
#define open w32_open #define open w32_open
#define read w32_read #define read w32_read
#define write w32_write #define write w32_write
#define writev w32_writev
//#define isatty w32_isatty //#define isatty w32_isatty
#define close w32_close #define close w32_close
#define dup w32_dup #define dup w32_dup

View File

@ -10,6 +10,15 @@
#include "defs.h" #include "defs.h"
#include "utf.h" #include "utf.h"
#ifndef _OFF_T_DEFINED
#define _OFF_T_DEFINED
typedef long _off_t; // file offset value
#if !__STDC__
typedef _off_t off_t;
#endif
#endif
typedef struct w32_fd_set_ { typedef struct w32_fd_set_ {
unsigned char bitmap[MAX_FDS >> 3]; unsigned char bitmap[MAX_FDS >> 3];
@ -45,6 +54,7 @@ int w32_pipe(int *pfds);
int w32_open(const char *pathname, int flags, ...); int w32_open(const char *pathname, int flags, ...);
int w32_read(int fd, void *dst, size_t max); int w32_read(int fd, void *dst, size_t max);
int w32_write(int fd, const void *buf, unsigned int max); int w32_write(int fd, const void *buf, unsigned int max);
int w32_writev(int fd, const struct iovec *iov, int iovcnt);
int w32_fstat(int fd, struct w32_stat *buf); int w32_fstat(int fd, struct w32_stat *buf);
int w32_stat(const char *path, struct w32_stat *buf); int w32_stat(const char *path, struct w32_stat *buf);
long w32_lseek( int fd, long offset, int origin); long w32_lseek( int fd, long offset, int origin);
@ -52,6 +62,8 @@ long w32_lseek( int fd, long offset, int origin);
int w32_isatty(int fd); int w32_isatty(int fd);
FILE* w32_fdopen(int fd, const char *mode); FILE* w32_fdopen(int fd, const char *mode);
int w32_mkdir(const char *pathname, unsigned short mode); int w32_mkdir(const char *pathname, unsigned short mode);
int w32_chdir(const char *dirname);
char *w32_getcwd(char *buffer, int maxlen);
/*common i/o*/ /*common i/o*/
#define fcntl(a,b,...) w32_fcntl((a), (b), __VA_ARGS__) #define fcntl(a,b,...) w32_fcntl((a), (b), __VA_ARGS__)
@ -75,6 +87,7 @@ void w32_freeaddrinfo(struct addrinfo *);
int w32_getaddrinfo(const char *, const char *, int w32_getaddrinfo(const char *, const char *,
const struct addrinfo *, struct addrinfo **); const struct addrinfo *, struct addrinfo **);
FILE* w32_fopen_utf8(const char *, const char *); FILE* w32_fopen_utf8(const char *, const char *);
int w32_ftruncate(int fd, off_t length);
char* w32_programdir(); char* w32_programdir();
@ -124,7 +137,6 @@ int sw_add_child(HANDLE child, DWORD pid);
#define allocate_sfd(a, b) w32_allocate_fd_for_handle((a, b)) #define allocate_sfd(a, b) w32_allocate_fd_for_handle((a, b))
//#define WSHELPwopen(a, b) w32_open((a, b)) //#define WSHELPwopen(a, b) w32_open((a, b))
/* TODO - These defs need to revisited and positioned appropriately */ /* TODO - These defs need to revisited and positioned appropriately */
#define environ _environ #define environ _environ

View File

@ -36,6 +36,7 @@
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
#include <assert.h> #include <assert.h>
#include <direct.h>
/* internal table that stores the fd to w32_io mapping*/ /* internal table that stores the fd to w32_io mapping*/
struct w32fd_table { struct w32fd_table {
@ -384,6 +385,23 @@ w32_write(int fd, const void *buf, unsigned int max) {
return fileio_write(fd_table.w32_ios[fd], buf, max); return fileio_write(fd_table.w32_ios[fd], buf, max);
} }
int w32_writev(int fd, const struct iovec *iov, int iovcnt) {
int written = 0;
int i = 0;
CHECK_FD(fd);
for (i = 0; i < iovcnt; i++) {
int ret = w32_write(fd, iov[i].iov_base, iov[i].iov_len);
if (ret > 0) {
written += ret;
}
}
return written;
}
int int
w32_fstat(int fd, struct w32_stat *buf) { w32_fstat(int fd, struct w32_stat *buf) {
CHECK_FD(fd); CHECK_FD(fd);
@ -411,6 +429,30 @@ w32_mkdir(const char *path_utf8, unsigned short mode) {
return _wmkdir(path_utf16); return _wmkdir(path_utf16);
} }
int w32_chdir(const char *dirname_utf8) {
wchar_t *dirname_utf16 = utf8_to_utf16(dirname_utf8);
if (dirname_utf16 == NULL) {
errno = ENOMEM;
return -1;
}
return _wchdir(dirname_utf16);
}
char *w32_getcwd(char *buffer, int maxlen) {
wchar_t wdirname[MAX_PATH];
char* putf8 = NULL;
wchar_t *wpwd = _wgetcwd(&wdirname[0], MAX_PATH);
if ((putf8 = utf16_to_utf8(&wdirname[0])) == NULL)
fatal("failed to convert input arguments");
strcpy(buffer, putf8);
free(putf8);
return buffer;
}
int int
w32_isatty(int fd) { w32_isatty(int fd) {
struct w32_io* pio; struct w32_io* pio;
@ -807,3 +849,17 @@ int
w32_kill(int pid, int sig) { w32_kill(int pid, int sig) {
return sw_kill(pid, sig); return sw_kill(pid, sig);
} }
int
w32_ftruncate(int fd, off_t length) {
CHECK_FD(fd);
if (!SetEndOfFile(w32_fd_to_handle(fd)))
return -1;
if (!SetFileValidData(w32_fd_to_handle(fd), length))
return -1;
if (!SetFilePointer(w32_fd_to_handle(fd), 0, 0, FILE_BEGIN))
return -1;
return 0;
}

View File

@ -172,6 +172,8 @@ enum
# define S_IRWXU 0000700 /* read, write, execute */ # define S_IRWXU 0000700 /* read, write, execute */
# define S_IRWXG 0000070 /* read, write, execute */ # define S_IRWXG 0000070 /* read, write, execute */
# define S_IRWXO 0000007 /* read, write, execute */ # define S_IRWXO 0000007 /* read, write, execute */
# define S_ISUID 0x800
# define S_ISGID 0x400
#endif /* S_IXUSR */ #endif /* S_IXUSR */
#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)

28
misc.c
View File

@ -222,6 +222,8 @@ pwcopy(struct passwd *pw)
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS #ifdef HAVE_STRUCT_PASSWD_PW_CLASS
copy->pw_class = xstrdup(pw->pw_class); copy->pw_class = xstrdup(pw->pw_class);
#endif #endif
copy->pw_dir = xstrdup(pw->pw_dir); copy->pw_dir = xstrdup(pw->pw_dir);
copy->pw_shell = xstrdup(pw->pw_shell); copy->pw_shell = xstrdup(pw->pw_shell);
return copy; return copy;
@ -431,9 +433,34 @@ char *
colon(char *cp) colon(char *cp)
{ {
int flag = 0; int flag = 0;
int len = 0;
if (*cp == ':') /* Leading colon is part of file name. */ if (*cp == ':') /* Leading colon is part of file name. */
return NULL; return NULL;
#ifdef WINDOWS
for (; *cp; ++cp) {
len++;
if (*cp == '[')
flag = 1;
if (flag && *cp != ']')
continue;
if (*cp == ']')
flag = 0;
if (*cp == ':') {
if (len != 2) { // avoid x: format for drive letter in Windows
return (cp);
}
}
// if ( (*cp == '/') || (*cp == '\\') )
// return (0);
}
return NULL;
#else
if (*cp == '[') if (*cp == '[')
flag = 1; flag = 1;
@ -448,6 +475,7 @@ colon(char *cp)
return NULL; return NULL;
} }
return NULL; return NULL;
#endif
} }
/* function to assist building execv() arguments */ /* function to assist building execv() arguments */

View File

@ -78,13 +78,23 @@ static volatile sig_atomic_t win_resized; /* for window resizing */
/* units for format_size */ /* units for format_size */
static const char unit[] = " KMGT"; static const char unit[] = " KMGT";
#ifdef WINDOWS
extern int ScreenX;
#endif
static int static int
can_output(void) can_output(void)
{ {
#ifndef WIN32_FIXME//R #ifndef WINDOWS
return (getpgrp() == tcgetpgrp(STDOUT_FILENO)); return (getpgrp() == tcgetpgrp(STDOUT_FILENO));
#else #else
return 1; DWORD dwProcessId = -1;
if (GetWindowThreadProcessId(GetStdHandle(STD_OUTPUT_HANDLE), &dwProcessId)) {
return(GetCurrentProcess() == dwProcessId);
}
else {
return -1;
}
#endif #endif
} }
@ -227,7 +237,14 @@ refresh_progress_meter(void)
strlcat(buf, " ", win_size); strlcat(buf, " ", win_size);
} }
#ifdef WINDOWS
wchar_t* wtmp = utf8_to_utf16(buf);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
#else
atomicio(vwrite, STDOUT_FILENO, buf, win_size - 1); atomicio(vwrite, STDOUT_FILENO, buf, win_size - 1);
#endif
last_update = now; last_update = now;
} }
@ -298,7 +315,7 @@ sig_winch(int sig)
static void static void
setscreensize(void) setscreensize(void)
{ {
#ifndef WIN32_FIXME//N #ifndef WINDOWS
struct winsize winsize; struct winsize winsize;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 && if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 &&
@ -310,6 +327,7 @@ setscreensize(void)
} else } else
win_size = DEFAULT_WINSIZE; win_size = DEFAULT_WINSIZE;
win_size += 1; /* trailing \0 */ win_size += 1; /* trailing \0 */
#else
win_size = ConScreenSizeX() + 1;
#endif #endif
win_size = DEFAULT_WINSIZE + 1;
} }

1185
scp.c

File diff suppressed because it is too large Load Diff

View File

@ -109,30 +109,8 @@
} }
} }
/** TODO - Move this to POSIX wrapper**/
/* ??? What if fd is nonblocking ???*/
int writev(int fd, struct iovec *iov, int iovcnt)
{
int written = 0;
int i = 0;
for (i = 0; i < iovcnt; i++)
{
int ret = write(fd, iov[i].iov_base, iov[i].iov_len);
if (ret > 0)
{
written += ret;
}
}
return written;
}
#endif #endif
extern volatile sig_atomic_t interrupted; extern volatile sig_atomic_t interrupted;
extern int showprogress; extern int showprogress;
@ -776,6 +754,7 @@ do_mkdir(struct sftp_conn *conn, const char *path, Attrib *a, int print_flag)
status = get_status(conn, id); status = get_status(conn, id);
if (status != SSH2_FX_OK && print_flag) if (status != SSH2_FX_OK && print_flag)
error("Couldn't create directory: %s", fx2txt(status)); error("Couldn't create directory: %s", fx2txt(status));
errno = status;
return status == SSH2_FX_OK ? 0 : -1; return status == SSH2_FX_OK ? 0 : -1;
} }
@ -1502,15 +1481,19 @@ do_download(struct sftp_conn *conn, const char *remote_path,
error("Can't set times on \"%s\": %s", error("Can't set times on \"%s\": %s",
local_path, strerror(errno)); local_path, strerror(errno));
} }
#ifndef WIN32_FIXME
// PRAGMA:TODO
if (fsync_flag) { if (fsync_flag) {
debug("syncing \"%s\"", local_path); debug("syncing \"%s\"", local_path);
#ifdef WINDOWS
if(FlushFileBuffers(local_fd))
error("Couldn't sync file \"%s\": %s",
local_path, strerror(GetLastError()));
#else
if (fsync(local_fd) == -1) if (fsync(local_fd) == -1)
error("Couldn't sync file \"%s\": %s", error("Couldn't sync file \"%s\": %s",
local_path, strerror(errno)); local_path, strerror(errno));
}
#endif #endif
}
} }
close(local_fd); close(local_fd);
sshbuf_free(msg); sshbuf_free(msg);
@ -1657,15 +1640,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
TAILQ_INIT(&acks); TAILQ_INIT(&acks);
#if(0)//def WIN32_FIXME
if ((local_fd = _open(local_path, O_RDONLY | O_BINARY, 0)) == -1) {
#else
if ((local_fd = open(local_path, O_RDONLY, 0)) == -1) { if ((local_fd = open(local_path, O_RDONLY, 0)) == -1) {
#endif
error("Couldn't open local file \"%s\" for reading: %s", error("Couldn't open local file \"%s\" for reading: %s",
local_path, strerror(errno)); local_path, strerror(errno));
return(-1); return(-1);
@ -1904,7 +1879,7 @@ upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst,
* if it was created successfully. * if it was created successfully.
*/ */
if (status != SSH2_FX_OK) { if (status != SSH2_FX_OK) {
if (status != SSH2_FX_FAILURE) if (errno != SSH2_FX_FAILURE)
return -1; return -1;
if (do_stat(conn, dst, 0) == NULL) if (do_stat(conn, dst, 0) == NULL)
return -1; return -1;

View File

@ -26,7 +26,7 @@
#include "includes.h" #include "includes.h"
#ifdef WIN32_FIXME #ifdef WINDOWS
void strmode(mode_t mode, char *p); void strmode(mode_t mode, char *p);
void strmode_from_attrib(unsigned attrib, char *p); void strmode_from_attrib(unsigned attrib, char *p);
#endif #endif
@ -225,10 +225,8 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
char sbuf[FMT_SCALED_STRSIZE]; char sbuf[FMT_SCALED_STRSIZE];
time_t now; time_t now;
#ifndef WIN32_FIXME
strmode(st->st_mode, mode);
#else
strmode(st->st_mode, mode); strmode(st->st_mode, mode);
#ifdef WINDOWS
strmode_from_attrib(remote, mode); strmode_from_attrib(remote, mode);
#endif #endif
if (!remote) { if (!remote) {
@ -242,12 +240,9 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
} else { } else {
snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid); snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid);
user = ubuf; user = ubuf;
#ifdef WIN32_FIXME #ifdef WINDOWS
snprintf(gbuf, sizeof gbuf, "%u", (u_int) st -> st_gid); snprintf(gbuf, sizeof gbuf, "%u", (u_int) st -> st_gid);
group = gbuf; group = gbuf;
#else #else
if (!remote) { if (!remote) {
group = group_from_gid(st->st_gid, 0); group = group_from_gid(st->st_gid, 0);
@ -256,7 +251,6 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
group = gbuf; group = gbuf;
} }
#endif #endif
} }
if (ltime != NULL) { if (ltime != NULL) {
now = time(NULL); now = time(NULL);
@ -283,7 +277,7 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
return xstrdup(buf); return xstrdup(buf);
} }
#ifdef WIN32_FIXME #ifdef WINDOWS
#include <sys/types.h> #include <sys/types.h>
#include <windows.h> #include <windows.h>
@ -299,7 +293,6 @@ strmode_from_attrib(unsigned attrib, char *p)
*p = '-'; *p = '-';
} }
void void
strmode(mode_t mode, char *p) strmode(mode_t mode, char *p)
{ {

View File

@ -22,7 +22,7 @@
# include <sys/stat.h> # include <sys/stat.h>
#endif #endif
#ifdef WIN32_VS #ifdef WINDOWS
#include "win32_dirent.h" #include "win32_dirent.h"
#else #else
#include <dirent.h> #include <dirent.h>
@ -37,10 +37,6 @@
#include "sftp-common.h" #include "sftp-common.h"
#include "sftp-client.h" #include "sftp-client.h"
#ifdef WIN32_VS
#include "win32_dirent.c"
#endif
int remote_glob(struct sftp_conn *, const char *, int, int remote_glob(struct sftp_conn *, const char *, int,
int (*)(const char *, int), glob_t *); int (*)(const char *, int), glob_t *);

View File

@ -61,11 +61,8 @@
#include "sftp.h" #include "sftp.h"
#include "sftp-common.h" #include "sftp-common.h"
#ifdef WIN32_VS
#include "win32_dirent.c"
#endif
#ifdef WIN32_FIXME #ifdef WIN32_FIXME
#include <Shlwapi.h>
char * get_inside_path(char *, BOOL, BOOL); char * get_inside_path(char *, BOOL, BOOL);
int readlink(const char *path, char *link, int linklen); int readlink(const char *path, char *link, int linklen);
@ -75,6 +72,7 @@
* stat requires paths * stat requires paths
* without slash at the end). * without slash at the end).
*/ */
char *realpathWin32(const char *path, char resolved[PATH_MAX]); char *realpathWin32(const char *path, char resolved[PATH_MAX]);
char *realpathWin32i(const char *path, char resolved[PATH_MAX]); char *realpathWin32i(const char *path, char resolved[PATH_MAX]);
#define realpath realpathWin32 #define realpath realpathWin32

297
sftp.c
View File

@ -72,10 +72,7 @@ typedef void EditLine;
#define DEFAULT_COPY_BUFLEN 32768 /* Size of buffer for up/download */ #define DEFAULT_COPY_BUFLEN 32768 /* Size of buffer for up/download */
#define DEFAULT_NUM_REQUESTS 64 /* # concurrent outstanding requests */ #define DEFAULT_NUM_REQUESTS 64 /* # concurrent outstanding requests */
#define MAX_COMMAND_LINE 2048
#ifdef WIN32_FIXME
#define FAIL(X) if (X) goto fail
#endif
#ifdef WIN32_VS #ifdef WIN32_VS
#include "win32_dirent.h" #include "win32_dirent.h"
@ -290,17 +287,12 @@ help(void)
static void static void
local_do_shell(const char *args) local_do_shell(const char *args)
{ {
#ifdef WIN32_FIXME #ifdef WINDOWS
if (!*args) { if (!*args) {
args = (char *) getenv("ComSpec"); // get name of Windows cmd shell args = (char *) getenv("ComSpec"); // get name of Windows cmd shell
} }
system(args); // execute the shell or cmd given system(args); // execute the shell or cmd given
#else #else
/*
* Original OpenSSH code.
*/
int status; int status;
char *shell; char *shell;
pid_t pid; pid_t pid;
@ -664,9 +656,37 @@ process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
resume |= global_aflag; resume |= global_aflag;
if (!quiet && resume) if (!quiet && resume)
#ifdef WINDOWS
{
printf("Resuming ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
printf(" to ");
free(wtmp);
wtmp = utf8_to_utf16(abs_dst);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Resuming %s to %s\n", g.gl_pathv[i], abs_dst); printf("Resuming %s to %s\n", g.gl_pathv[i], abs_dst);
#endif
else if (!quiet && !resume) else if (!quiet && !resume)
#ifdef WINDOWS
{
printf("Fetching ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
printf(" to ");
free(wtmp);
wtmp = utf8_to_utf16(abs_dst);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst); printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst);
#endif
if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL,
pflag || global_pflag, 1, resume, pflag || global_pflag, 1, resume,
@ -755,10 +775,38 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
resume |= global_aflag; resume |= global_aflag;
if (!quiet && resume) if (!quiet && resume)
#ifdef WINDOWS
{
printf("Resuming upload of ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
printf(" to ");
free(wtmp);
wtmp = utf8_to_utf16(abs_dst);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Resuming upload of %s to %s\n", g.gl_pathv[i], printf("Resuming upload of %s to %s\n", g.gl_pathv[i],
abs_dst); abs_dst);
#endif
else if (!quiet && !resume) else if (!quiet && !resume)
#ifdef WINDOWS
{
printf("Uploading ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
printf(" to ");
free(wtmp);
wtmp = utf8_to_utf16(abs_dst);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst); printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst);
#endif
if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
if (upload_dir(conn, g.gl_pathv[i], abs_dst, if (upload_dir(conn, g.gl_pathv[i], abs_dst,
pflag || global_pflag, 1, resume, pflag || global_pflag, 1, resume,
@ -823,13 +871,12 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
tmp = path_strip(path, strip_path); tmp = path_strip(path, strip_path);
m += strlen(tmp); m += strlen(tmp);
free(tmp); free(tmp);
#ifndef WIN32_FIXME #ifdef WINDOWS
width = ConScreenSizeX();
#else
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
width = ws.ws_col; width = ws.ws_col;
#endif #endif
columns = width / (m + 2); columns = width / (m + 2);
columns = MAX(columns, 1); columns = MAX(columns, 1);
colspace = width / columns; colspace = width / columns;
@ -862,12 +909,37 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
attrib_to_stat(&d[n]->a, &sb); attrib_to_stat(&d[n]->a, &sb);
lname = ls_file(fname, &sb, 1, lname = ls_file(fname, &sb, 1,
(lflag & LS_SI_UNITS)); (lflag & LS_SI_UNITS));
#ifdef WINDOWS
wchar_t* wtmp = utf8_to_utf16(lname);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
#else
printf("%s\n", lname); printf("%s\n", lname);
#endif
free(lname); free(lname);
} else }
else {
#ifdef WINDOWS
wchar_t* wtmp = utf8_to_utf16(d[n]->longname);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
#else
printf("%s\n", d[n]->longname); printf("%s\n", d[n]->longname);
} else { #endif
}
}
else {
#ifdef WINDOWS
wchar_t* wtmp = utf8_to_utf16(fname);
// TODO: Deal with the sizing wprintf_s(L"%-*s", colspace, wtmp);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L" ", 1, 0, 0);
free(wtmp);
#else
printf("%-*s", colspace, fname); printf("%-*s", colspace, fname);
#endif
if (c >= columns) { if (c >= columns) {
printf("\n"); printf("\n");
c = 1; c = 1;
@ -926,14 +998,13 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
return err; return err;
} }
#ifdef WINDOWS
#ifndef WIN32_FIXME width = ConScreenSizeX();
#else
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
width = ws.ws_col; width = ws.ws_col;
#endif #endif
if (!(lflag & LS_SHORT_VIEW)) { if (!(lflag & LS_SHORT_VIEW)) {
/* Count entries for sort and find longest filename */ /* Count entries for sort and find longest filename */
for (i = 0; g.gl_pathv[i]; i++) for (i = 0; g.gl_pathv[i]; i++)
@ -953,10 +1024,25 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
} }
lname = ls_file(fname, g.gl_statv[i], 1, lname = ls_file(fname, g.gl_statv[i], 1,
(lflag & LS_SI_UNITS)); (lflag & LS_SI_UNITS));
#ifdef WINDOWS
wchar_t* wtmp = utf8_to_utf16(lname);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
#else
printf("%s\n", lname); printf("%s\n", lname);
#endif
free(lname); free(lname);
} else { } else {
#ifdef WINDOWS
wchar_t* wtmp = utf8_to_utf16(fname);
// TODO: Deal with the sizing wprintf_s(L"%-*s", colspace, wtmp);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L" ", 1, 0, 0);
free(wtmp);
#else
printf("%-*s", colspace, fname); printf("%-*s", colspace, fname);
#endif
if (c >= columns) { if (c >= columns) {
printf("\n"); printf("\n");
c = 1; c = 1;
@ -1436,6 +1522,7 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
glob_t g; glob_t g;
path1 = path2 = NULL; path1 = path2 = NULL;
cmdnum = parse_args(&cmd, &ignore_errors, &aflag, &fflag, &hflag, cmdnum = parse_args(&cmd, &ignore_errors, &aflag, &fflag, &hflag,
&iflag, &lflag, &pflag, &rflag, &sflag, &n_arg, &path1, &path2); &iflag, &lflag, &pflag, &rflag, &sflag, &n_arg, &path1, &path2);
if (ignore_errors != 0) if (ignore_errors != 0)
@ -1484,7 +1571,17 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g);
for (i = 0; g.gl_pathv[i] && !interrupted; i++) { for (i = 0; g.gl_pathv[i] && !interrupted; i++) {
if (!quiet) if (!quiet)
#ifdef WINDOWS
{
printf("Removing ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Removing %s\n", g.gl_pathv[i]); printf("Removing %s\n", g.gl_pathv[i]);
#endif
err = do_rm(conn, g.gl_pathv[i]); err = do_rm(conn, g.gl_pathv[i]);
if (err != 0 && err_abort) if (err != 0 && err_abort)
break; break;
@ -1584,7 +1681,17 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g);
for (i = 0; g.gl_pathv[i] && !interrupted; i++) { for (i = 0; g.gl_pathv[i] && !interrupted; i++) {
if (!quiet) if (!quiet)
#ifdef WINDOWS
{
printf("Changing mode on ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Changing mode on %s\n", g.gl_pathv[i]); printf("Changing mode on %s\n", g.gl_pathv[i]);
#endif
err = do_setstat(conn, g.gl_pathv[i], &a); err = do_setstat(conn, g.gl_pathv[i], &a);
if (err != 0 && err_abort) if (err != 0 && err_abort)
break; break;
@ -1614,13 +1721,33 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
aa->flags &= SSH2_FILEXFER_ATTR_UIDGID; aa->flags &= SSH2_FILEXFER_ATTR_UIDGID;
if (cmdnum == I_CHOWN) { if (cmdnum == I_CHOWN) {
if (!quiet) if (!quiet)
#ifdef WINDOWS
{
printf("Changing owner on ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Changing owner on %s\n", printf("Changing owner on %s\n",
g.gl_pathv[i]); g.gl_pathv[i]);
#endif
aa->uid = n_arg; aa->uid = n_arg;
} else { } else {
if (!quiet) if (!quiet)
#ifdef WINDOWS
{
printf("Changing group on ");
wchar_t* wtmp = utf8_to_utf16(g.gl_pathv[i]);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Changing group on %s\n", printf("Changing group on %s\n",
g.gl_pathv[i]); g.gl_pathv[i]);
#endif
aa->gid = n_arg; aa->gid = n_arg;
} }
err = do_setstat(conn, g.gl_pathv[i], aa); err = do_setstat(conn, g.gl_pathv[i], aa);
@ -1629,7 +1756,17 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
} }
break; break;
case I_PWD: case I_PWD:
#ifdef WINDOWS
printf("Remote working directory: ");
{
wchar_t* wtmp = utf8_to_utf16(*pwd);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Remote working directory: %s\n", *pwd); printf("Remote working directory: %s\n", *pwd);
#endif
break; break;
case I_LPWD: case I_LPWD:
if (!getcwd(path_buf, sizeof(path_buf))) { if (!getcwd(path_buf, sizeof(path_buf))) {
@ -1637,7 +1774,17 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
err = -1; err = -1;
break; break;
} }
#ifdef WINDOWS
printf("Local working directory: ");
{
wchar_t* wtmp = utf8_to_utf16(path_buf);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Local working directory: %s\n", path_buf); printf("Local working directory: %s\n", path_buf);
#endif
break; break;
case I_QUIT: case I_QUIT:
/* Processed below */ /* Processed below */
@ -2040,7 +2187,7 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
{ {
char *remote_path; char *remote_path;
char *dir = NULL; char *dir = NULL;
char cmd[2048]; char cmd[MAX_COMMAND_LINE];
int err, interactive; int err, interactive;
EditLine *el = NULL; EditLine *el = NULL;
#ifdef USE_LIBEDIT #ifdef USE_LIBEDIT
@ -2090,7 +2237,17 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
if (remote_is_dir(conn, dir) && file2 == NULL) { if (remote_is_dir(conn, dir) && file2 == NULL) {
if (!quiet) if (!quiet)
#ifdef WINDOWS
{
printf("Changing to: ");
wchar_t* wtmp = utf8_to_utf16(dir);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
free(wtmp);
}
#else
printf("Changing to: %s\n", dir); printf("Changing to: %s\n", dir);
#endif
snprintf(cmd, sizeof cmd, "cd \"%s\"", dir); snprintf(cmd, sizeof cmd, "cd \"%s\"", dir);
if (parse_dispatch_command(conn, cmd, if (parse_dispatch_command(conn, cmd,
&remote_path, 1) != 0) { &remote_path, 1) != 0) {
@ -2115,7 +2272,7 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
free(dir); free(dir);
} }
#ifndef WIN32_VS #ifndef WINDOWS
setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(infile, NULL, _IOLBF, 0); setvbuf(infile, NULL, _IOLBF, 0);
#endif #endif
@ -2128,13 +2285,36 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
if (el == NULL) { if (el == NULL) {
if (interactive) #ifdef WINDOWS
if (interactive) {
wchar_t wcmd[MAX_COMMAND_LINE];
printf("sftp> ");
if (fgetws(wcmd, sizeof(cmd)/sizeof(wchar_t), infile) == NULL) {
printf("\n");
break;
}
else {
char *pcmd = NULL;
if ((pcmd = utf16_to_utf8(wcmd)) == NULL)
fatal("failed to convert input arguments");
strcpy(cmd, pcmd);
free(pcmd);
}
}
else {
if (fgets(cmd, sizeof(cmd), infile) == NULL) {
break;
}
}
#else
if (interactive) {
printf("sftp> "); printf("sftp> ");
if (fgets(cmd, sizeof(cmd), infile) == NULL) { if (fgets(cmd, sizeof(cmd), infile) == NULL) {
if (interactive) if (interactive)
printf("\n"); printf("\n");
break; break;
} }
#endif
if (!interactive) { /* Echo command */ if (!interactive) { /* Echo command */
printf("sftp> %s", cmd); printf("sftp> %s", cmd);
if (strlen(cmd) > 0 && if (strlen(cmd) > 0 &&
@ -2187,9 +2367,6 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
static void static void
connect_to_server(char *path, char **args, int *in, int *out) connect_to_server(char *path, char **args, int *in, int *out)
{ {
/*
* Original OpenSSH code.
*/
int c_in, c_out; int c_in, c_out;
#ifdef USE_PIPES #ifdef USE_PIPES
@ -2210,9 +2387,9 @@ connect_to_server(char *path, char **args, int *in, int *out)
c_in = c_out = inout[1]; c_in = c_out = inout[1];
#endif /* USE_PIPES */ #endif /* USE_PIPES */
#ifdef WIN32_FIXME #ifdef WINDOWS
{ {
int i; int i = 0;
char fullCmd[MAX_PATH] = { 0 }; char fullCmd[MAX_PATH] = { 0 };
char ioArg[1024] = { 0 }; char ioArg[1024] = { 0 };
PROCESS_INFORMATION pi = { 0 }; PROCESS_INFORMATION pi = { 0 };
@ -2225,8 +2402,7 @@ connect_to_server(char *path, char **args, int *in, int *out)
strncat(fullCmd, "\\", MAX_PATH); strncat(fullCmd, "\\", MAX_PATH);
} }
strncat(fullCmd, path, MAX_PATH); strncat(fullCmd, path, MAX_PATH);
for (i = 1; args[i]; i++) for (i = 1; args[i]; i++) {
{
strncat(fullCmd, " ", MAX_PATH); strncat(fullCmd, " ", MAX_PATH);
strncat(fullCmd, args[i], MAX_PATH); strncat(fullCmd, args[i], MAX_PATH);
} }
@ -2337,35 +2513,35 @@ main(int argc, char **argv)
size_t num_requests = DEFAULT_NUM_REQUESTS; size_t num_requests = DEFAULT_NUM_REQUESTS;
long long limit_kbps = 0; long long limit_kbps = 0;
#ifdef WIN32_FIXME #ifdef WINDOWS
/*
* Initialize I/O wrappers.
*/
w32posix_initialize();
setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0);
ConInit(STD_OUTPUT_HANDLE, TRUE);
#endif #endif
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd(); sanitise_stdfd();
#ifndef WIN32_FIXME
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
#endif
__progname = ssh_get_progname(argv[0]); __progname = ssh_get_progname(argv[0]);
memset(&args, '\0', sizeof(args)); memset(&args, '\0', sizeof(args));
args.list = NULL; args.list = NULL;
addargs(&args, "%s", ssh_program); addargs(&args, "%s", ssh_program);
#ifdef WIN32_FIXME
addargs(&args, "-oForwardX11=no"); addargs(&args, "\"-oForwardX11 no\"");
addargs(&args, "-oForwardAgent=no"); addargs(&args, "\"-oForwardAgent no\"");
addargs(&args, "-oPermitLocalCommand=no"); addargs(&args, "\"-oPermitLocalCommand no\"");
addargs(&args, "-oClearAllForwardings=yes"); addargs(&args, "\"-oClearAllForwardings yes\"");
#else
addargs(&args, "-oForwardX11 no");
addargs(&args, "-oForwardAgent no");
addargs(&args, "-oPermitLocalCommand no");
addargs(&args, "-oClearAllForwardings yes");
#endif
ll = SYSLOG_LEVEL_INFO; ll = SYSLOG_LEVEL_INFO;
#ifdef WINDOWS
_setmode(_fileno(stdin), O_U16TEXT);
#endif
infile = stdin; infile = stdin;
while ((ch = getopt(argc, argv, while ((ch = getopt(argc, argv,
@ -2392,16 +2568,7 @@ main(int argc, char **argv)
addargs(&args, "-%c", ch); addargs(&args, "-%c", ch);
break; break;
case 'P': case 'P':
#ifdef WIN32_FIXME addargs(&args, "\"-oPort %s\"", optarg);
addargs(&args, "-oPort=%s", optarg);
#else
addargs(&args, "-oPort %s", optarg);
#endif
break; break;
case 'v': case 'v':
if (debug_level < 3) { if (debug_level < 3) {
@ -2436,16 +2603,7 @@ main(int argc, char **argv)
fatal("%s (%s).", strerror(errno), optarg); fatal("%s (%s).", strerror(errno), optarg);
showprogress = 0; showprogress = 0;
quiet = batchmode = 1; quiet = batchmode = 1;
#ifdef WIN32_FIXME addargs(&args, "\"-obatchmode yes\"");
addargs(&args, "-obatchmode=yes");
#else
addargs(&args, "-obatchmode yes");
#endif
break; break;
case 'f': case 'f':
global_fflag = 1; global_fflag = 1;
@ -2519,16 +2677,7 @@ main(int argc, char **argv)
fprintf(stderr, "Missing hostname\n"); fprintf(stderr, "Missing hostname\n");
usage(); usage();
} }
#ifdef WIN32_FIXME addargs(&args, "\"-oProtocol %d\"", sshver);
addargs(&args, "-oProtocol=%d", sshver);
#else
addargs(&args, "-oProtocol %d", sshver);
#endif
/* no subsystem if the server-spec contains a '/' */ /* no subsystem if the server-spec contains a '/' */
if (sftp_server == NULL || strchr(sftp_server, '/') == NULL) if (sftp_server == NULL || strchr(sftp_server, '/') == NULL)

View File

@ -2,11 +2,11 @@
// directory entry functions in Windows platform like Ubix/Linux // directory entry functions in Windows platform like Ubix/Linux
// opendir(), readdir(), closedir(). // opendir(), readdir(), closedir().
#include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <windows.h>
#include "win32_dirent.h" #include "win32_dirent.h"
@ -14,15 +14,19 @@
Return a DIR stream on the directory, or NULL if it could not be opened. */ Return a DIR stream on the directory, or NULL if it could not be opened. */
DIR * opendir(char *name) DIR * opendir(char *name)
{ {
struct _finddata_t c_file; struct _wfinddata_t c_file;
intptr_t hFile; intptr_t hFile;
DIR *pdir; DIR *pdir;
char searchstr[256]; wchar_t searchstr[MAX_PATH];
wchar_t wname[MAX_PATH];
int needed;
MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, MAX_PATH);
// add *.* for Windows _findfirst() search pattern // add *.* for Windows _findfirst() search pattern
sprintf_s(searchstr, sizeof(searchstr), "%s\\*.*",name); swprintf_s(searchstr, MAX_PATH, L"%s\\*.*", wname);
if ((hFile = _findfirst(searchstr, &c_file)) == -1L) { if ((hFile = _wfindfirst(searchstr, &c_file)) == -1L) {
if (1) // verbose if (1) // verbose
printf( "No files found for %s search.\n", name ); printf( "No files found for %s search.\n", name );
return (DIR *) NULL; return (DIR *) NULL;
@ -30,8 +34,17 @@ DIR * opendir(char *name)
else { else {
pdir = (DIR *) malloc( sizeof(DIR) ); pdir = (DIR *) malloc( sizeof(DIR) );
pdir->hFile = hFile ; pdir->hFile = hFile ;
pdir->c_file = c_file ; pdir->c_file.attrib = c_file.attrib ;
strcpy_s(pdir->initName,sizeof(pdir->initName), c_file.name); pdir->c_file.size = c_file.size;
pdir->c_file.time_access = c_file.time_access;
pdir->c_file.time_create = c_file.time_create;
pdir->c_file.time_write = c_file.time_write;
if ((needed = WideCharToMultiByte(CP_UTF8, 0, c_file.name, -1, NULL, 0, NULL, NULL)) == 0 ||
WideCharToMultiByte(CP_UTF8, 0, c_file.name, -1, pdir->c_file.name, needed, NULL, NULL) != needed)
fatal("failed to covert input arguments");
strcpy_s(pdir->initName, sizeof(pdir->initName), pdir->c_file.name);
return pdir ; return pdir ;
} }
@ -56,17 +69,26 @@ int closedir(DIR *dirp)
by a later readdir call on the same DIR stream. */ by a later readdir call on the same DIR stream. */
struct dirent *readdir(void *avp) struct dirent *readdir(void *avp)
{ {
int needed;
struct dirent *pdirentry; struct dirent *pdirentry;
struct _wfinddata_t c_file;
DIR *dirp = (DIR *)avp; DIR *dirp = (DIR *)avp;
char *tmp = NULL;
for (;;) { for (;;) {
if ( _findnext( dirp->hFile, &(dirp->c_file) ) == 0 ) { if ( _wfindnext( dirp->hFile, &c_file ) == 0 ) {
if ( ( strcmp (dirp->c_file.name,".") == 0 ) || if ( ( wcscmp (c_file.name, L".") == 0 ) ||
( strcmp (dirp->c_file.name,"..") == 0 ) ) { ( wcscmp (c_file.name, L"..") == 0 ) ) {
continue ; continue ;
} }
pdirentry = (struct dirent *) malloc( sizeof(struct dirent) ); pdirentry = (struct dirent *) malloc( sizeof(struct dirent) );
pdirentry->d_name = dirp->c_file.name ;
if ((tmp = utf16_to_utf8(pdirentry->d_name)) == NULL)
fatal("failed to covert input arguments");
strcpy(c_file.name[0], tmp);
free(tmp);
tmp = NULL;
pdirentry->d_ino = 1; // a fictious one like UNIX to say it is nonzero pdirentry->d_ino = 1; // a fictious one like UNIX to say it is nonzero
return pdirentry ; return pdirentry ;
} }

View File

@ -9,6 +9,7 @@
#include <direct.h> #include <direct.h>
#include <io.h> #include <io.h>
#include <fcntl.h>
// Windows directory structure content // Windows directory structure content
struct dirent { struct dirent {