mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-25 15:04:54 +02:00
Temporary fixes in scp.exe to have a working solution
This commit is contained in:
parent
27d9e5bb33
commit
367476c953
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.24720.0
|
VisualStudioVersion = 14.0.23107.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh", "ssh.vcxproj", "{74E69D5E-A1EF-46EA-9173-19A412774104}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh", "ssh.vcxproj", "{74E69D5E-A1EF-46EA-9173-19A412774104}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
@ -95,6 +95,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-add", "ssh-add.vcxproj"
|
|||||||
{8660C2FE-9874-432D-B047-E042BB41DBE0} = {8660C2FE-9874-432D-B047-E042BB41DBE0}
|
{8660C2FE-9874-432D-B047-E042BB41DBE0} = {8660C2FE-9874-432D-B047-E042BB41DBE0}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scp", "scp.vcxproj", "{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{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
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
@ -223,6 +232,14 @@ Global
|
|||||||
{029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x64.Build.0 = Release|x64
|
{029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x64.Build.0 = Release|x64
|
||||||
{029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.ActiveCfg = Release|Win32
|
{029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.Build.0 = Release|Win32
|
{029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Release|x64.Build.0 = Release|x64
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{29B98ADF-1285-49CE-BF6C-AA92C5D2FB24}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
77
scp.c
77
scp.c
@ -708,6 +708,59 @@ do_local_cmd(arglist *a)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int pipe_counter = 1;
|
||||||
|
/* create overlapped supported pipe */
|
||||||
|
BOOL CreateOverlappedPipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES sa, DWORD size) {
|
||||||
|
HANDLE read_handle = INVALID_HANDLE_VALUE, write_handle = INVALID_HANDLE_VALUE;
|
||||||
|
char pipe_name[MAX_PATH];
|
||||||
|
|
||||||
|
/* create name for named pipe */
|
||||||
|
if (-1 == sprintf_s(pipe_name, MAX_PATH, "\\\\.\\Pipe\\W32SCPPipe.%08x.%08x",
|
||||||
|
GetCurrentProcessId(), pipe_counter++)) {
|
||||||
|
debug("pipe - ERROR sprintf_s %d", errno);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
read_handle = CreateNamedPipeA(pipe_name,
|
||||||
|
PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
|
||||||
|
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||||
|
1,
|
||||||
|
4096,
|
||||||
|
4096,
|
||||||
|
0,
|
||||||
|
sa);
|
||||||
|
if (read_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
debug("pipe - CreateNamedPipe() ERROR:%d", errno);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* connect to named pipe */
|
||||||
|
write_handle = CreateFileA(pipe_name,
|
||||||
|
GENERIC_WRITE,
|
||||||
|
0,
|
||||||
|
sa,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
|
||||||
|
NULL);
|
||||||
|
if (write_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
debug("pipe - ERROR CreateFile() :%d", errno);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
*hReadPipe = read_handle;
|
||||||
|
*hWritePipe = write_handle;
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (read_handle)
|
||||||
|
CloseHandle(read_handle);
|
||||||
|
if (write_handle)
|
||||||
|
CloseHandle(write_handle);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function executes the given command as the specified user on the
|
* This function executes the given command as the specified user on the
|
||||||
* given host. This returns < 0 if execution fails, and >= 0 otherwise. This
|
* given host. This returns < 0 if execution fails, and >= 0 otherwise. This
|
||||||
@ -814,7 +867,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
|
|||||||
sa.lpSecurityDescriptor = NULL;
|
sa.lpSecurityDescriptor = NULL;
|
||||||
/* command processor output redirected to a nameless pipe */
|
/* command processor output redirected to a nameless pipe */
|
||||||
|
|
||||||
rc = CreatePipe ( &hstdout[0], &hstdout[1], &sa, 0 ) ;
|
rc = CreateOverlappedPipe( &hstdout[0], &hstdout[1], &sa, 0 ) ;
|
||||||
/* read from this fd to get data from ssh.exe*/
|
/* read from this fd to get data from ssh.exe*/
|
||||||
|
|
||||||
// make scp's pipe read handle not inheritable by ssh
|
// make scp's pipe read handle not inheritable by ssh
|
||||||
@ -830,7 +883,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
|
|||||||
*fdin = _open_osfhandle((intptr_t)hstdout[0],0);
|
*fdin = _open_osfhandle((intptr_t)hstdout[0],0);
|
||||||
_setmode (*fdin, O_BINARY); // set this file handle for binary I/O
|
_setmode (*fdin, O_BINARY); // set this file handle for binary I/O
|
||||||
|
|
||||||
rc = CreatePipe ( &hstdin[0], &hstdin[1], &sa, 0 ) ;
|
rc = CreateOverlappedPipe( &hstdin[0], &hstdin[1], &sa, 0 ) ;
|
||||||
/* write to this fd to get data into ssh.exe*/
|
/* write to this fd to get data into ssh.exe*/
|
||||||
|
|
||||||
// make scp's pipe write handle not inheritable by ssh
|
// make scp's pipe write handle not inheritable by ssh
|
||||||
@ -1033,11 +1086,7 @@ int pflag, iamremote, iamrecursive, targetshouldbedirectory;
|
|||||||
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
|
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
|
||||||
|
|
||||||
int response(void);
|
int response(void);
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
void rsource(char *, struct _stati64 *);
|
|
||||||
#else
|
|
||||||
void rsource(char *, struct stat *);
|
void rsource(char *, struct stat *);
|
||||||
#endif
|
|
||||||
|
|
||||||
void sink(int, char *[]);
|
void sink(int, char *[]);
|
||||||
void source(int, char *[]);
|
void source(int, char *[]);
|
||||||
@ -1439,7 +1488,7 @@ tolocal(int argc, char **argv)
|
|||||||
void
|
void
|
||||||
source(int argc, char *argv[])
|
source(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct _stati64 stb;
|
struct stat stb;
|
||||||
static BUF buffer;
|
static BUF buffer;
|
||||||
BUF *bp;
|
BUF *bp;
|
||||||
off_t i;
|
off_t i;
|
||||||
@ -1520,7 +1569,7 @@ source(int argc, char *argv[])
|
|||||||
|
|
||||||
if (_sopen_s(&fd, name, O_RDONLY | O_BINARY, _SH_DENYNO, 0) != 0) {
|
if (_sopen_s(&fd, name, O_RDONLY | O_BINARY, _SH_DENYNO, 0) != 0) {
|
||||||
// in NT, we have to check if it is a directory
|
// in NT, we have to check if it is a directory
|
||||||
if (_stati64(name, &stb) >= 0) {
|
if (stat(name, &stb) >= 0) {
|
||||||
goto switchpoint;
|
goto switchpoint;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1692,7 +1741,7 @@ next: if (fd != -1) (void)_close(fd);
|
|||||||
free(filenames[ii]);
|
free(filenames[ii]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsource(char *name, struct _stati64 *statp)
|
void rsource(char *name, struct stat *statp)
|
||||||
{
|
{
|
||||||
SCPDIR *dirp;
|
SCPDIR *dirp;
|
||||||
struct scp_dirent *dp;
|
struct scp_dirent *dp;
|
||||||
@ -1754,7 +1803,7 @@ void sink(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// DWORD dwread;
|
// DWORD dwread;
|
||||||
static BUF buffer;
|
static BUF buffer;
|
||||||
struct _stati64 stb;
|
struct stat stb;
|
||||||
enum { YES, NO, DISPLAYED } wrerr;
|
enum { YES, NO, DISPLAYED } wrerr;
|
||||||
BUF *bp;
|
BUF *bp;
|
||||||
size_t i, j, size;
|
size_t i, j, size;
|
||||||
@ -1812,7 +1861,7 @@ void sink(int argc, char *argv[])
|
|||||||
|
|
||||||
(void)_write(remout, "", 1);
|
(void)_write(remout, "", 1);
|
||||||
|
|
||||||
if (_stati64(targ, &stb) == 0 && S_ISDIR(stb.st_mode))
|
if (stat(targ, &stb) == 0 && S_ISDIR(stb.st_mode))
|
||||||
targisdir = 1;
|
targisdir = 1;
|
||||||
|
|
||||||
for (first = 1;; first = 0) {
|
for (first = 1;; first = 0) {
|
||||||
@ -1912,7 +1961,7 @@ keepgoing:
|
|||||||
np = namebuf;
|
np = namebuf;
|
||||||
} else
|
} else
|
||||||
np = targ;
|
np = targ;
|
||||||
exists = _stati64(np, &stb) == 0;
|
exists = stat(np, &stb) == 0;
|
||||||
if (buf[0] == 'D') {
|
if (buf[0] == 'D') {
|
||||||
int mod_flag = pflag;
|
int mod_flag = pflag;
|
||||||
if (exists) {
|
if (exists) {
|
||||||
@ -2807,9 +2856,9 @@ char *win32colon(char *cp)
|
|||||||
|
|
||||||
void verifydir(char *cp)
|
void verifydir(char *cp)
|
||||||
{
|
{
|
||||||
struct _stati64 stb;
|
struct stat stb;
|
||||||
|
|
||||||
if (!_stati64(cp, &stb)) {
|
if (!stat(cp, &stb)) {
|
||||||
if (S_ISDIR(stb.st_mode))
|
if (S_ISDIR(stb.st_mode))
|
||||||
return;
|
return;
|
||||||
errno = ENOTDIR;
|
errno = ENOTDIR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user