mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 22:15:37 +02:00
Made sftp.exe functional
This commit is contained in:
parent
31ed6d1458
commit
2854245328
@ -397,6 +397,7 @@ VOID CALLBACK WriteCompletionRoutine(
|
|||||||
abort();
|
abort();
|
||||||
pio->write_details.remaining -= dwNumberOfBytesTransfered;
|
pio->write_details.remaining -= dwNumberOfBytesTransfered;
|
||||||
pio->write_details.pending = FALSE;
|
pio->write_details.pending = FALSE;
|
||||||
|
*((__int64*)&lpOverlapped->Offset) += dwNumberOfBytesTransfered;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write() implementation */
|
/* write() implementation */
|
||||||
@ -507,6 +508,18 @@ fileio_stat(const char *path, struct _stat64 *buf) {
|
|||||||
return _stat64(path, buf);
|
return _stat64(path, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
fileio_lseek(struct w32_io* pio, long offset, int origin) {
|
||||||
|
int fd = _open_osfhandle((intptr_t)pio->handle, 0);
|
||||||
|
debug2("pio:%p", pio);
|
||||||
|
if (fd == -1) {
|
||||||
|
errno = EOTHER;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _lseek(fd, offset, origin);
|
||||||
|
}
|
||||||
|
|
||||||
/* isatty() implementation */
|
/* isatty() implementation */
|
||||||
int
|
int
|
||||||
fileio_isatty(struct w32_io* pio) {
|
fileio_isatty(struct w32_io* pio) {
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#define sleep(sec) Sleep(1000 * sec)
|
#define sleep(sec) Sleep(1000 * sec)
|
||||||
#define alarm w32_alarm
|
#define alarm w32_alarm
|
||||||
|
#define lseek w32_lseek
|
||||||
|
|
||||||
/* Compatibility header to avoid lots of #ifdefs in includes.h on Win32 */
|
/* Compatibility header to avoid lots of #ifdefs in includes.h on Win32 */
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@ int w32_read(int fd, void *dst, unsigned int 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_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);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -353,6 +353,12 @@ w32_stat(const char *path, struct w32_stat *buf) {
|
|||||||
return fileio_stat(path, (struct _stat64*)buf);
|
return fileio_stat(path, (struct _stat64*)buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
w32_lseek(int fd, long offset, int origin) {
|
||||||
|
CHECK_FD(fd);
|
||||||
|
return fileio_lseek(fd_table.w32_ios[fd], offset, origin);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
w32_mkdir(const char *pathname, unsigned short mode) {
|
w32_mkdir(const char *pathname, unsigned short mode) {
|
||||||
return _mkdir(pathname);
|
return _mkdir(pathname);
|
||||||
|
@ -116,6 +116,7 @@ int fileio_read(struct w32_io* pio, void *dst, unsigned int max);
|
|||||||
int fileio_write(struct w32_io* pio, const void *buf, unsigned int max);
|
int fileio_write(struct w32_io* pio, const void *buf, unsigned int max);
|
||||||
int fileio_fstat(struct w32_io* pio, struct _stat64 *buf);
|
int fileio_fstat(struct w32_io* pio, struct _stat64 *buf);
|
||||||
int fileio_stat(const char *path, struct _stat64 *buf);
|
int fileio_stat(const char *path, struct _stat64 *buf);
|
||||||
|
long fileio_lseek(struct w32_io* pio, long offset, int origin);
|
||||||
int fileio_isatty(struct w32_io* pio);
|
int fileio_isatty(struct w32_io* pio);
|
||||||
FILE* fileio_fdopen(struct w32_io* pio, const char *mode);
|
FILE* fileio_fdopen(struct w32_io* pio, const char *mode);
|
||||||
|
|
||||||
|
68
readpass.c
68
readpass.c
@ -334,41 +334,57 @@ read_passphrase(const char *prompt, int flags)
|
|||||||
/*
|
/*
|
||||||
* Show prompt for user.
|
* Show prompt for user.
|
||||||
*/
|
*/
|
||||||
|
HANDLE c_in = CreateFileA("CONIN$", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL);
|
||||||
|
HANDLE c_out = CreateFileA("CONOUT$", GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL);
|
||||||
|
int tmp;
|
||||||
|
int originalMode, tmpMode;
|
||||||
|
|
||||||
write(STDOUT_FILENO, prompt, strlen(prompt));
|
GetConsoleMode(c_in, &originalMode);
|
||||||
|
SetConsoleMode(c_in, ENABLE_LINE_INPUT);
|
||||||
|
//SetConsoleMode(c_in, (originalMode & ~(ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT)));
|
||||||
|
|
||||||
len = retr = 0;
|
GetConsoleMode(c_in, &tmpMode);
|
||||||
int bufsize = sizeof(buf);
|
|
||||||
|
|
||||||
while (_kbhit())
|
WriteFile(c_out, prompt, strlen(prompt), &tmp, NULL);
|
||||||
_getch();
|
// write(STDOUT_FILENO, prompt, strlen(prompt));
|
||||||
|
ReadFile(c_in, buf, 1024, &tmp, NULL);
|
||||||
|
buf[tmp - 2] = '\0';
|
||||||
|
SetConsoleMode(c_in, originalMode);
|
||||||
|
CloseHandle(c_in);
|
||||||
|
CloseHandle(c_out);
|
||||||
|
|
||||||
while ( len < bufsize ) {
|
// len = retr = 0;
|
||||||
|
// int bufsize = sizeof(buf);
|
||||||
|
|
||||||
buf[len] = (unsigned char) _getch() ;
|
//while (_kbhit())
|
||||||
|
// _getch();
|
||||||
|
|
||||||
|
//while ( len < bufsize ) {
|
||||||
|
|
||||||
|
// buf[len] = (unsigned char) _getch() ;
|
||||||
|
|
||||||
|
|
||||||
if ( buf[len] == '\r' ) {
|
// if ( buf[len] == '\r' ) {
|
||||||
if (_kbhit() )
|
// if (_kbhit() )
|
||||||
_getch(); // read linefeed if its there
|
// _getch(); // read linefeed if its there
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else if ( buf[len] == '\n' ) {
|
// else if ( buf[len] == '\n' ) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
else if ( buf[len] == '\b' ) { // backspace
|
// else if ( buf[len] == '\b' ) { // backspace
|
||||||
if (len > 0 )
|
// if (len > 0 )
|
||||||
len--; // overwrite last character
|
// len--; // overwrite last character
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
|
|
||||||
//_putch( (int) '*' ); // show a star in place of what is typed
|
// //_putch( (int) '*' ); // show a star in place of what is typed
|
||||||
len++; // keep reading in the loop
|
// len++; // keep reading in the loop
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
buf[len] = '\0' ; // get rid of the cr/lf
|
//buf[len] = '\0' ; // get rid of the cr/lf
|
||||||
write(STDOUT_FILENO,"\n", strlen("\n")); // show a newline as we do not echo password or the line
|
//write(STDOUT_FILENO,"\n", strlen("\n")); // show a newline as we do not echo password or the line
|
||||||
|
|
||||||
ret = xstrdup(buf);
|
ret = xstrdup(buf);
|
||||||
|
|
||||||
|
@ -1556,7 +1556,7 @@ do_download(struct sftp_conn *conn, const char *remote_path,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef WIN32_FIXME
|
#if(0)//def WIN32_FIXME
|
||||||
|
|
||||||
_close(local_fd);
|
_close(local_fd);
|
||||||
|
|
||||||
|
8
sftp.c
8
sftp.c
@ -75,11 +75,11 @@ typedef void EditLine;
|
|||||||
|
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME
|
||||||
|
|
||||||
#define mkdir(a, b) _mkdir(a)
|
// #define mkdir(a, b) _mkdir(a)
|
||||||
|
|
||||||
#define FAIL(X) if (X) goto fail
|
#define FAIL(X) if (X) goto fail
|
||||||
|
|
||||||
extern int sfd_start;
|
//extern int sfd_start;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2308,9 +2308,7 @@ connect_to_server(char *path, char **args, int *in, int *out)
|
|||||||
si.cb = sizeof(STARTUPINFO);
|
si.cb = sizeof(STARTUPINFO);
|
||||||
si.hStdInput = sfd_to_handle(sockout[0]);
|
si.hStdInput = sfd_to_handle(sockout[0]);
|
||||||
si.hStdOutput = sfd_to_handle(sockin[1]);//GetStdHandle(STD_OUTPUT_HANDLE);//sfd_to_handle(sockin[1]);
|
si.hStdOutput = sfd_to_handle(sockin[1]);//GetStdHandle(STD_OUTPUT_HANDLE);//sfd_to_handle(sockin[1]);
|
||||||
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
|
||||||
si.wShowWindow = SW_HIDE;
|
si.wShowWindow = SW_HIDE;
|
||||||
si.dwFlags = STARTF_USESTDHANDLES;
|
si.dwFlags = STARTF_USESTDHANDLES;
|
||||||
si.lpDesktop = NULL;
|
si.lpDesktop = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user