mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-04-08 19:35:37 +02:00
Enabled SFTP client over new POSIX wrapper. Its not functional yet
This commit is contained in:
parent
41f53d605c
commit
31ed6d1458
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh", "ssh.vcxproj", "{74E69D5E-A1EF-46EA-9173-19A412774104}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
@ -40,6 +40,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sftp", "sftp.vcxproj", "{BB
|
||||
{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
|
||||
|
@ -87,6 +87,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)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
@ -132,7 +133,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>
|
||||
|
@ -27,6 +27,8 @@
|
||||
#define S_IEXEC _S_IEXEC
|
||||
|
||||
#define stat w32_stat
|
||||
#define lstat w32_stat
|
||||
#define mkdir w32_mkdir
|
||||
|
||||
struct w32_stat {
|
||||
dev_t st_dev; /* ID of device containing file */
|
||||
|
@ -40,7 +40,6 @@ int w32_socketpair(int domain, int type, int sv[2]);
|
||||
/*non-network (file) i/o*/
|
||||
#define fdopen(a,b) w32_fdopen((a), (b))
|
||||
#define fstat(a,b) w32_fstat((a), (b))
|
||||
//#define stat(a,b) w32_stat((a), (b))
|
||||
|
||||
struct w32_stat;
|
||||
int w32_pipe(int *pfds);
|
||||
@ -51,6 +50,7 @@ int w32_fstat(int fd, struct w32_stat *buf);
|
||||
int w32_stat(const char *path, struct w32_stat *buf);
|
||||
int w32_isatty(int fd);
|
||||
FILE* w32_fdopen(int fd, const char *mode);
|
||||
int w32_mkdir(const char *pathname, unsigned short mode);
|
||||
|
||||
/*common i/o*/
|
||||
#define fcntl(a,b,...) w32_fcntl((a), (b), __VA_ARGS__)
|
||||
|
@ -353,6 +353,10 @@ w32_stat(const char *path, struct w32_stat *buf) {
|
||||
return fileio_stat(path, (struct _stat64*)buf);
|
||||
}
|
||||
|
||||
int
|
||||
w32_mkdir(const char *pathname, unsigned short mode) {
|
||||
return _mkdir(pathname);
|
||||
}
|
||||
int
|
||||
w32_isatty(int fd) {
|
||||
if ((fd < 0) || (fd > MAX_FDS - 1) || fd_table.w32_ios[fd] == NULL) {
|
||||
|
@ -65,11 +65,11 @@
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
|
||||
#include <sys/socket.h>
|
||||
//#include <sys/socket.h>
|
||||
|
||||
#define mkdir(a, b) _mkdir(a)
|
||||
//#define mkdir(a, b) _mkdir(a)
|
||||
|
||||
#define lstat(PATH, BUF) _stat(PATH, BUF)
|
||||
//#define lstat(PATH, BUF) _stat(PATH, BUF)
|
||||
|
||||
/*
|
||||
* Don't use fstat() function redefined
|
||||
@ -77,9 +77,9 @@
|
||||
* in this context.
|
||||
*/
|
||||
|
||||
#ifdef fstat
|
||||
#undef fstat
|
||||
#endif
|
||||
//#ifdef fstat
|
||||
//#undef fstat
|
||||
//#endif
|
||||
|
||||
int glob(const char *pattern, int flags, int (*errfunc)(const char *epath, int eerrno),
|
||||
glob_t *pglob)
|
||||
@ -1315,7 +1315,7 @@ do_download(struct sftp_conn *conn, const char *remote_path,
|
||||
return(-1);
|
||||
}
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
|
||||
local_fd = _open(local_path,
|
||||
O_WRONLY | O_CREAT | O_BINARY | (resume_flag ? 0 : O_TRUNC), mode | S_IWUSR);
|
||||
@ -1433,7 +1433,7 @@ do_download(struct sftp_conn *conn, const char *remote_path,
|
||||
fatal("Received more data than asked for "
|
||||
"%zu > %zu", len, req->len);
|
||||
if ((lseek(local_fd, req->offset, SEEK_SET) == -1 ||
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
|
||||
atomicio(_write, local_fd, data, len) != len) &&
|
||||
|
||||
@ -1709,7 +1709,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
|
||||
|
||||
TAILQ_INIT(&acks);
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
|
||||
if ((local_fd = _open(local_path, O_RDONLY | O_BINARY, 0)) == -1) {
|
||||
|
||||
@ -1730,7 +1730,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
|
||||
}
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
error("%s is not a regular file", local_path);
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
|
||||
_close(local_fd);
|
||||
|
||||
@ -1789,7 +1789,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
|
||||
handle = get_handle(conn, id, &handle_len,
|
||||
"remote open(\"%s\")", remote_path);
|
||||
if (handle == NULL) {
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
|
||||
_close(local_fd);
|
||||
|
||||
@ -1824,7 +1824,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
|
||||
if (interrupted || status != SSH2_FX_OK)
|
||||
len = 0;
|
||||
else do
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
|
||||
len = _read(local_fd, data, conn->transfer_buflen);
|
||||
|
||||
@ -1916,7 +1916,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
|
||||
status = SSH2_FX_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
#if(0)//def WIN32_FIXME
|
||||
|
||||
if (_close(local_fd) == -1)
|
||||
{
|
||||
|
31
sftp.c
31
sftp.c
@ -2211,7 +2211,7 @@ connect_to_server(char *path, char **args, int *in, int *out)
|
||||
HANDLE childInput = NULL;
|
||||
HANDLE childOutput = NULL;
|
||||
|
||||
int i = 0;
|
||||
int i = 0, tmp;
|
||||
|
||||
char fullCmd[MAX_PATH] = {0};
|
||||
|
||||
@ -2227,8 +2227,9 @@ connect_to_server(char *path, char **args, int *in, int *out)
|
||||
|
||||
debug3("Creating socket pairs for child ssh process...");
|
||||
|
||||
socketpair(sockin);
|
||||
socketpair(sockout);
|
||||
pipe(sockin);
|
||||
pipe(sockout);
|
||||
|
||||
|
||||
debug3("sockin[0]: %d sockin[1]: %d", sockin[0], sockin[1]);
|
||||
debug3("sockout[0]: %d sockout[1]: %d", sockout[0], sockout[1]);
|
||||
@ -2264,15 +2265,15 @@ connect_to_server(char *path, char **args, int *in, int *out)
|
||||
TRUE, DUPLICATE_SAME_ACCESS) == FALSE);
|
||||
*/
|
||||
|
||||
FAIL(DuplicateHandle(GetCurrentProcess(), sfd_to_handle(STDIN_FILENO),
|
||||
GetCurrentProcess(), &childInput, 0,
|
||||
TRUE, DUPLICATE_SAME_ACCESS) == FALSE);
|
||||
//FAIL(DuplicateHandle(GetCurrentProcess(), sfd_to_handle(STDIN_FILENO),
|
||||
// GetCurrentProcess(), &childInput, 0,
|
||||
// TRUE, DUPLICATE_SAME_ACCESS) == FALSE);
|
||||
|
||||
debug3("Duplicating stdout sockets for child ssh process...\n");
|
||||
|
||||
FAIL(DuplicateHandle(GetCurrentProcess(), sfd_to_handle(STDOUT_FILENO),
|
||||
GetCurrentProcess(), &childOutput, 0,
|
||||
TRUE, DUPLICATE_SAME_ACCESS) == FALSE);
|
||||
//debug3("Duplicating stdout sockets for child ssh process...\n");
|
||||
//
|
||||
//FAIL(DuplicateHandle(GetCurrentProcess(), sfd_to_handle(STDOUT_FILENO),
|
||||
// GetCurrentProcess(), &childOutput, 0,
|
||||
// TRUE, DUPLICATE_SAME_ACCESS) == FALSE);
|
||||
|
||||
|
||||
//childInput = sfd_to_handle(STDIN_FILENO);
|
||||
@ -2307,6 +2308,8 @@ connect_to_server(char *path, char **args, int *in, int *out)
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
si.hStdInput = sfd_to_handle(sockout[0]);
|
||||
si.hStdOutput = sfd_to_handle(sockin[1]);//GetStdHandle(STD_OUTPUT_HANDLE);//sfd_to_handle(sockin[1]);
|
||||
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||
si.wShowWindow = SW_HIDE;
|
||||
si.dwFlags = STARTF_USESTDHANDLES;
|
||||
@ -2470,14 +2473,16 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Initialize I/O wrappers.
|
||||
*/
|
||||
|
||||
w32posix_initialize();
|
||||
|
||||
WSHELPinitialize();
|
||||
/* WSHELPinitialize();
|
||||
|
||||
allocate_standard_descriptor(STDIN_FILENO);
|
||||
allocate_standard_descriptor(STDOUT_FILENO);
|
||||
allocate_standard_descriptor(STDERR_FILENO);
|
||||
|
||||
LoadLibrary("libwindbg.dll");
|
||||
LoadLibrary("libwindbg.dll");*/
|
||||
|
||||
//sfd_start = 3;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user