Skip to content

Commit bbc576e

Browse files
committed
Merge branch 'console-updates-integration' of https://github.com/PowerShell/Win32-OpenSSH.git
2 parents f6dac9e + 72c7549 commit bbc576e

File tree

22 files changed

+121
-658
lines changed

22 files changed

+121
-658
lines changed

atomicio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
5454
{
5555
char *s = _s;
5656
size_t pos = 0;
57-
ssize_t res;
57+
int res;
5858
struct pollfd pfd;
5959

6060
#ifndef BROKEN_READ_COMPARISON

channels.c

Lines changed: 77 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,85 +1722,91 @@ channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset)
17221722
int len;
17231723

17241724
/* Send buffered output data to the socket. */
1725-
if (c->wfd != -1 &&
1726-
FD_ISSET(c->wfd, writeset) &&
1727-
buffer_len(&c->output) > 0) {
1728-
olen = buffer_len(&c->output);
1729-
if (c->output_filter != NULL) {
1730-
if ((buf = c->output_filter(c, &data, &dlen)) == NULL) {
1731-
debug2("channel %d: filter stops", c->self);
1732-
if (c->type != SSH_CHANNEL_OPEN)
1733-
chan_mark_dead(c);
1734-
else
1735-
chan_write_failed(c);
1736-
return -1;
1737-
}
1738-
} else if (c->datagram) {
1739-
buf = data = buffer_get_string(&c->output, &dlen);
1740-
} else {
1741-
buf = data = buffer_ptr(&c->output);
1742-
dlen = buffer_len(&c->output);
1743-
}
1725+
if (c->wfd != -1 &&
1726+
FD_ISSET(c->wfd, writeset) &&
1727+
buffer_len(&c->output) > 0) {
1728+
olen = buffer_len(&c->output);
1729+
if (c->output_filter != NULL) {
1730+
if ((buf = c->output_filter(c, &data, &dlen)) == NULL) {
1731+
debug2("channel %d: filter stops", c->self);
1732+
if (c->type != SSH_CHANNEL_OPEN)
1733+
chan_mark_dead(c);
1734+
else
1735+
chan_write_failed(c);
1736+
return -1;
1737+
}
1738+
} else if (c->datagram) {
1739+
buf = data = buffer_get_string(&c->output, &dlen);
1740+
} else {
1741+
buf = data = buffer_ptr(&c->output);
1742+
dlen = buffer_len(&c->output);
1743+
}
17441744

1745-
if (c->datagram) {
1746-
/* ignore truncated writes, datagrams might get lost */
1747-
len = write(c->wfd, buf, dlen);
1748-
free(data);
1749-
if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1750-
errno == EWOULDBLOCK))
1751-
return 1;
1752-
if (len <= 0) {
1753-
if (c->type != SSH_CHANNEL_OPEN)
1754-
chan_mark_dead(c);
1755-
else
1756-
chan_write_failed(c);
1757-
return -1;
1758-
}
1759-
goto out;
1760-
}
1745+
if (c->datagram) {
1746+
/* ignore truncated writes, datagrams might get lost */
1747+
len = write(c->wfd, buf, dlen);
1748+
free(data);
1749+
if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1750+
errno == EWOULDBLOCK))
1751+
return 1;
1752+
if (len <= 0) {
1753+
if (c->type != SSH_CHANNEL_OPEN)
1754+
chan_mark_dead(c);
1755+
else
1756+
chan_write_failed(c);
1757+
return -1;
1758+
}
1759+
goto out;
1760+
}
17611761
#ifdef _AIX
1762-
/* XXX: Later AIX versions can't push as much data to tty */
1763-
if (compat20 && c->wfd_isatty)
1764-
dlen = MIN(dlen, 8*1024);
1762+
/* XXX: Later AIX versions can't push as much data to tty */
1763+
if (compat20 && c->wfd_isatty)
1764+
dlen = MIN(dlen, 8 * 1024);
1765+
#endif
1766+
#ifdef WIN32_FIXME /* TODO - Fix this - on windows we somehow end up with dlen = 0*/
1767+
if (dlen > 0) {
17651768
#endif
17661769

1767-
len = write(c->wfd, buf, dlen);
1768-
if (len < 0 &&
1769-
(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1770-
return 1;
1771-
if (len <= 0) {
1772-
if (c->type != SSH_CHANNEL_OPEN) {
1773-
debug2("channel %d: not open", c->self);
1774-
chan_mark_dead(c);
1775-
return -1;
1776-
} else if (compat13) {
1777-
buffer_clear(&c->output);
1778-
debug2("channel %d: input draining.", c->self);
1779-
c->type = SSH_CHANNEL_INPUT_DRAINING;
1780-
} else {
1781-
chan_write_failed(c);
1782-
}
1783-
return -1;
1784-
}
1770+
len = write(c->wfd, buf, dlen);
1771+
if (len < 0 &&
1772+
(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1773+
return 1;
1774+
if (len <= 0) {
1775+
if (c->type != SSH_CHANNEL_OPEN) {
1776+
debug2("channel %d: not open", c->self);
1777+
chan_mark_dead(c);
1778+
return -1;
1779+
} else if (compat13) {
1780+
buffer_clear(&c->output);
1781+
debug2("channel %d: input draining.", c->self);
1782+
c->type = SSH_CHANNEL_INPUT_DRAINING;
1783+
} else {
1784+
chan_write_failed(c);
1785+
}
1786+
return -1;
1787+
}
17851788
#ifndef WIN32_FIXME//R
17861789
#ifndef BROKEN_TCGETATTR_ICANON
1787-
if (compat20 && c->isatty && dlen >= 1 && buf[0] != '\r') {
1788-
if (tcgetattr(c->wfd, &tio) == 0 &&
1789-
!(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
1790-
/*
1791-
* Simulate echo to reduce the impact of
1792-
* traffic analysis. We need to match the
1793-
* size of a SSH2_MSG_CHANNEL_DATA message
1794-
* (4 byte channel id + buf)
1795-
*/
1796-
packet_send_ignore(4 + len);
1797-
packet_send();
1798-
}
1799-
}
1790+
if (compat20 && c->isatty && dlen >= 1 && buf[0] != '\r') {
1791+
if (tcgetattr(c->wfd, &tio) == 0 &&
1792+
!(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
1793+
/*
1794+
* Simulate echo to reduce the impact of
1795+
* traffic analysis. We need to match the
1796+
* size of a SSH2_MSG_CHANNEL_DATA message
1797+
* (4 byte channel id + buf)
1798+
*/
1799+
packet_send_ignore(4 + len);
1800+
packet_send();
1801+
}
1802+
}
18001803
#endif
18011804
#endif
1802-
buffer_consume(&c->output, len);
1803-
}
1805+
buffer_consume(&c->output, len);
1806+
}
1807+
#ifdef WIN32_FIXME /* for if (dlen > 0) */
1808+
}
1809+
#endif
18041810
out:
18051811
if (compat20 && olen > 0)
18061812
c->local_consumed += olen - buffer_len(&c->output);

contrib/win32/openssh/config.h.vs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,7 @@
16711671
#define HAVE_KRB5_FREE_ERROR_MESSAGE 1
16721672
#define HAVE_DECL_NFDBITS 0
16731673
#define HAVE_DECL_HOWMANY 0
1674+
#define HAVE_DES_CRYPT 1
16741675

16751676
#define WIN32_ZLIB_NO 1
16761677
#define USE_MSCNG 1

contrib/win32/openssh/win32compat.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@
151151
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\gettimeofday.c" />
152152
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\homedirhelp.c" />
153153
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\kerberos.c" />
154-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsalogon.c" />
155-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsastring.c" />
156154
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\pwd.c" />
157155
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\startupneeds.c" />
158156
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\strcasecmp.c" />

contrib/win32/openssh/win32compat.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@
5757
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\kerberos.c">
5858
<Filter>Source Files</Filter>
5959
</ClCompile>
60-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsalogon.c">
61-
<Filter>Source Files</Filter>
62-
</ClCompile>
63-
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\lsastring.c">
64-
<Filter>Source Files</Filter>
65-
</ClCompile>
6660
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\pwd.c">
6761
<Filter>Source Files</Filter>
6862
</ClCompile>

contrib/win32/win32compat/inc/defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ typedef int sigset_t;
7070

7171
typedef unsigned short _mode_t;
7272
typedef _mode_t mode_t;
73+
/* TODO - investigate if it makes sense to make pid_t a DWORD_PTR.
74+
* Double check usage of pid_t as int */
7375
typedef int pid_t;
7476

7577
/* wait pid options */

contrib/win32/win32compat/inc/sys/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
#define recv(a,b,c,d) w32_recv((a), (b), (c), (d))
2020
#define send(a,b,c,d) w32_send((a), (b), (c), (d))
2121
#define shutdown(a,b) w32_shutdown((a), (b))
22-
#define socketpair(a,b,c) w32_socketpair((a), (b), (c))
22+
#define socketpair(a,b,c,d) w32_socketpair((a), (b), (c), (d))

contrib/win32/win32compat/inc/unistd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
/* Compatibility header to avoid lots of #ifdefs in includes.h on Win32 */
3939

4040
#include <conio.h>
41-
#include <direct.h>
4241

4342
/* We can't put these in string.h since we can't easily override that header, so here they are */
4443
#if !defined(HAVE_STRCASECMP) && !defined(__MINGW32__)

contrib/win32/win32compat/inc/w32posix.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ int w32_connect(int fd, const struct sockaddr* name, int namelen);
3232
int w32_recv(int fd, void *buf, size_t len, int flags);
3333
int w32_send(int fd, const void *buf, size_t len, int flags);
3434
int w32_shutdown(int fd, int how);
35-
int w32_socketpair(int domain, int type, int sv[2]);
35+
int w32_socketpair(int domain, int type, int protocol, int sv[2]);
3636

3737
/*non-network (file) i/o*/
38+
#undef fdopen
3839
#define fdopen(a,b) w32_fdopen((a), (b))
3940
#define fstat(a,b) w32_fstat((a), (b))
4041

4142
struct w32_stat;
4243
int w32_pipe(int *pfds);
4344
int w32_open(const char *pathname, int flags, ...);
44-
int w32_read(int fd, void *dst, unsigned int max);
45+
int w32_read(int fd, void *dst, size_t max);
4546
int w32_write(int fd, const void *buf, unsigned int max);
4647
int w32_fstat(int fd, struct w32_stat *buf);
4748
int w32_stat(const char *path, struct w32_stat *buf);

contrib/win32/win32compat/includes/pwd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ struct passwd *getpwuid(uid_t uid);
2626
struct passwd *getpwnam(const char *username);
2727
void endpwent(void);
2828

29-
typedef int PWD_USER_TOKEN; /* This is really just a HANDLE, but we might not have windows.h included */
30-
PWD_USER_TOKEN PwdCreateUserToken(const char *pUserName, const char *pDomainName, const char *pSourceName);
29+
char *realpathWin32(const char *path, char resolved[PATH_MAX]);
3130

3231
const char *
3332
user_from_uid(uid_t uid, int nouser);

0 commit comments

Comments
 (0)