Skip to content

Commit b8d8245

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/L1'
2 parents ef4ffda + 3c6c8c3 commit b8d8245

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1853
-554
lines changed

.gitignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,18 @@ ssh_host_rsa_key
239239
ssh_host_rsa_key
240240
ssh_host_rsa_key
241241
ssh_host_dsa_key
242+
ssh_host_dsa_key.pub
242243
ssh_host_ecdsa_key.pub
244+
ssh_host_ecdsa_key
245+
ssh_host_ed25519_key
246+
ssh_host_ed25519_key.pub
243247
ssh_host_rsa_key.pub
244248
id_rsa.pub
249+
id_rsa
250+
id_dsa.pub
251+
id_dsa
252+
is_rsa
253+
is_rsa.pub
245254
regress/t10.out.pub
246255
regress/t12.out.pub
247256
regress/t6.out1
@@ -263,4 +272,7 @@ regress/t7.out.pub
263272
regress/t6.out2
264273
config.h
265274
configure
266-
config.h
275+
config.h
276+
277+
#temp key files
278+
d2utmpa*

Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
8787
msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
8888
ssh-pkcs11.o smult_curve25519_ref.o \
8989
poly1305.o chacha.o cipher-chachapoly.o \
90-
ssh-ed25519.o digest-openssl.o digest-libc.o hmac.o \
90+
ssh-ed25519.o digest-libc.o hmac.o \
9191
sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o \
9292
kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \
9393
kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# OpenSSH
22
Win32 port of OpenSSH
3+
4+
Look at the [wiki](https://github.com/PowerShell/Win32-OpenSSH/wiki) for help
5+
First release announcement is here:
6+
OpenSSH for Windows Update - Windows PowerShell Blog - Site Home - MSDN Blogs
7+
http://blogs.msdn.com/b/powershell/archive/2015/10/19/openssh-for-windows-update.aspx

channels.c

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,10 @@ channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset)
16851685
if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) {
16861686
errno = 0;
16871687
len = read(c->rfd, buf, sizeof(buf));
1688+
#ifdef WIN32_FIXME
1689+
if (len == 0)
1690+
return 1; // in Win32 console read, there may be no data, but is ok
1691+
#endif
16881692
if (len < 0 && (errno == EINTR ||
16891693
((errno == EAGAIN || errno == EWOULDBLOCK) && !force)))
16901694
return 1;
@@ -2395,9 +2399,7 @@ channel_output_poll(void)
23952399
}
23962400
}
23972401
}
2398-
#ifdef WIN32_FIXME
2399-
int lftocrlf = 0;
2400-
#endif
2402+
24012403
/* -- protocol input */
24022404

24032405
/* ARGSUSED */
@@ -2462,13 +2464,25 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
24622464
#else
24632465
if ( c->client_tty )
24642466
telProcessNetwork ( data, data_len ); // run it by ANSI engine if it is the ssh client
2465-
else
2466-
buffer_append(&c->output, data, data_len); // it is the sshd server, so pass it on
2467-
if ( c->isatty ) {
2468-
buffer_append(&c->input, data, data_len); // we echo the data if it is sshd server and pty interactive mode
2469-
if ( (data_len ==1) && (data[0] == '\b') )
2470-
buffer_append(&c->input, " \b", 2); // for backspace, we need to send space and another backspace for visual erase
2467+
else {
2468+
if ( ( c->isatty) && (data_len ==1) && (data[0] == '\003') ) {
2469+
/* send control-c to the shell process */
2470+
if ( GenerateConsoleCtrlEvent ( CTRL_C_EVENT, 0 ) ) {
2471+
}
2472+
else {
2473+
debug3("GenerateConsoleCtrlEvent failed with %d\n",GetLastError());
2474+
}
2475+
}
2476+
else {
2477+
buffer_append(&c->output, data, data_len); // it is the sshd server, so pass it on
2478+
if ( c->isatty ) { // we echo the data if it is sshd server and pty interactive mode
2479+
buffer_append(&c->input, data, data_len);
2480+
if ( (data_len ==1) && (data[0] == '\b') )
2481+
buffer_append(&c->input, " \b", 2); // for backspace, we need to send space and another backspace for visual erase
2482+
}
2483+
}
24712484
}
2485+
24722486
#endif
24732487
}
24742488
packet_check_eom();
@@ -3913,10 +3927,11 @@ channel_connect_to_path(const char *path, char *ctype, char *rname)
39133927
return connect_to(path, PORT_STREAMLOCAL, ctype, rname);
39143928
}
39153929

3930+
#ifndef WIN32_FIXME
39163931
void
39173932
channel_send_window_changes(void)
39183933
{
3919-
#ifndef WIN32_FIXME
3934+
39203935
u_int i;
39213936
struct winsize ws;
39223937

@@ -3933,9 +3948,30 @@ channel_send_window_changes(void)
39333948
packet_put_int((u_int)ws.ws_ypixel);
39343949
packet_send();
39353950
}
3936-
#endif
39373951
}
39383952

3953+
#else // WIN32_FIXME
3954+
void
3955+
channel_send_window_changes(int col, int row, int xpixel, int ypixel)
3956+
{
3957+
u_int i;
3958+
struct winsize ws;
3959+
3960+
for (i = 0; i < channels_alloc; i++) {
3961+
if (channels[i] == NULL || !channels[i]->client_tty ||
3962+
channels[i]->type != SSH_CHANNEL_OPEN)
3963+
continue;
3964+
channel_request_start(i, "window-change", 0);
3965+
packet_put_int((u_int)col);
3966+
packet_put_int((u_int)row);
3967+
packet_put_int((u_int)xpixel);
3968+
packet_put_int((u_int)ypixel);
3969+
packet_send();
3970+
}
3971+
}
3972+
#endif
3973+
3974+
39393975
/* -- X11 forwarding */
39403976

39413977
/*

channels.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,12 @@ void channel_register_status_confirm(int, channel_confirm_cb *,
226226
channel_confirm_abandon_cb *, void *);
227227
void channel_cancel_cleanup(int);
228228
int channel_close_fd(int *);
229+
#ifndef WIN32_FIXME
229230
void channel_send_window_changes(void);
231+
#else
232+
void channel_send_window_changes(int, int, int, int);
233+
#endif
234+
230235

231236
/* protocol handler */
232237

clientloop.c

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@
119119
#include <sys/stat.h>
120120

121121
#define isatty(a) WSHELPisatty(a)
122+
123+
// Windows Console screen size change related
124+
extern int ScreenX;
125+
extern int ScrollBottom;
126+
int win_received_window_change_signal = 1;
127+
122128
#endif
123129

124130
/* import options */
@@ -162,7 +168,10 @@ static int escape_pending1; /* Last character was an escape (proto1 only) */
162168
static int last_was_cr; /* Last character was a newline. */
163169
static int exit_status; /* Used to store the command exit status. */
164170
static int stdin_eof; /* EOF has been encountered on stderr. */
165-
static Buffer stdin_buffer; /* Buffer for stdin data. */
171+
#ifndef WIN32_FIXME
172+
static
173+
#endif
174+
Buffer stdin_buffer; /* Buffer for stdin data. */
166175
static Buffer stdout_buffer; /* Buffer for stdout data. */
167176
static Buffer stderr_buffer; /* Buffer for stderr data. */
168177
static u_int buffer_high; /* Soft max buffer size. */
@@ -563,6 +572,25 @@ client_check_window_change(void)
563572
packet_put_int((u_int)ws.ws_ypixel);
564573
packet_send();
565574
}
575+
#else
576+
577+
if (! win_received_window_change_signal)
578+
return;
579+
/** XXX race */
580+
win_received_window_change_signal = 0;
581+
582+
debug2("client_check_window_change: changed");
583+
584+
if (compat20) {
585+
channel_send_window_changes(ScreenX, ScrollBottom, 640, 480);
586+
} else {
587+
packet_start(SSH_CMSG_WINDOW_SIZE);
588+
packet_put_int((u_int)ScreenX);
589+
packet_put_int((u_int)ScrollBottom);
590+
packet_put_int((u_int)640);
591+
packet_put_int((u_int)480);
592+
packet_send();
593+
}
566594
#endif /* !WIN32_FIXME */
567595
}
568596

@@ -1320,14 +1348,14 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
13201348
* and append it to the buffer.
13211349
*/
13221350
last_was_cr = (ch == '\r' || ch == '\n');
1323-
#ifdef WIN32_FIXME
1324-
extern int lftocrlf ; // defined in channels.c file's channel_input_data() function for now
1325-
if ( (lftocrlf == 1) && ( ch == '\n') ) {
1351+
//#ifdef WIN32_FIXME
1352+
//extern int lftocrlf ; // defined in channels.c file's channel_input_data() function for now
1353+
//if ( (lftocrlf == 1) && ( ch == '\n') ) {
13261354
// add a \r before \n if sshd server sent us ESC[20h during initial tty mode setting
1327-
buffer_put_char(bin, '\r');
1328-
bytes++;
1329-
}
1330-
#endif
1355+
//buffer_put_char(bin, '\r');
1356+
//bytes++;
1357+
//}
1358+
//#endif
13311359
buffer_put_char(bin, ch);
13321360
bytes++;
13331361
}
@@ -2571,11 +2599,11 @@ client_session2_setup(int id, int want_tty, int want_subsystem,
25712599
tty_make_modes(-1, tiop);
25722600

25732601
#else
2574-
packet_put_cstring(term != NULL ? term : "");
2575-
packet_put_int((u_int) 80 /*ws.ws_col*/);
2576-
packet_put_int((u_int) 25 /*ws.ws_row*/);
2577-
packet_put_int((u_int) 640 /*ws.ws_xpixel*/);
2578-
packet_put_int((u_int) 480 /*ws.ws_ypixel*/);
2602+
packet_put_cstring(term != NULL ? term : "vt220");
2603+
packet_put_int((u_int) ScreenX);
2604+
packet_put_int((u_int) ScrollBottom);
2605+
packet_put_int((u_int) 640);
2606+
packet_put_int((u_int) 480);
25792607
tty_make_modes(-1, NULL);
25802608
#endif /* else !WIN32_FIXME */
25812609
packet_send();

contrib/win32/win32compat/Makefile.in

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ LDFLAGS=-L. @LDFLAGS@ -L/lib/win32api
1919

2020
WIN32COMPATFILES = daemon.o gettimeofday.o homedirhelp.o pwd.o sfds.o \
2121
socket.o startupneeds.o strcasecmp.o syslog.o lsalogon.o lsastring.o \
22-
stringhelp.o deskright.o win32auth.o kerberos.o cng_cipher.o ansiprsr.o console.o tnnet.o
22+
stringhelp.o deskright.o win32auth.o kerberos.o cng_cipher.o ansiprsr.o \
23+
console.o tnnet.o conio.o tncon.o
2324

2425
WIN32COMPATLIB=@LIBWIN32COMPAT@
2526

26-
CNGFILES=cng_cipher.o
27+
CNGFILES=cng_cipher.o cng_digest.o
2728

2829

2930
.c.o:
@@ -44,6 +45,6 @@ distclean: clean
4445

4546
$(WIN32COMPATFILES): ../../../config.h
4647

47-
$(WIN32COMPATLIB): $(WIN32COMPATFILES)
48-
$(AR) rv $@ $(WIN32COMPATFILES)
48+
$(WIN32COMPATLIB): $(WIN32COMPATFILES) $(CNGFILES)
49+
$(AR) rv $@ $(WIN32COMPATFILES) $(CNGFILES)
4950
$(RANLIB) $@

contrib/win32/win32compat/ansiprsr.c

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1-
/* ansiprsr.c
2-
* Author: Pragma Systems, Inc. <www.pragmasys.com>
3-
* Contribution by Pragma Systems, Inc. for Microsoft openssh win32 port
4-
* Copyright (c) 2011, 2015 Pragma Systems, Inc.
1+
/*
2+
* Author: Microsoft Corp.
3+
*
4+
* Copyright (c) 2015 Microsoft Corp.
55
* All rights reserved
6-
*
7-
* ANSI Parser to run on Win32 based operating systems.
6+
*
7+
* Microsoft openssh win32 port
88
*
99
* Redistribution and use in source and binary forms, with or without
10-
* modification, are permitted provided that the following conditions are met:
10+
* modification, are permitted provided that the following conditions
11+
* are met:
12+
*
13+
* 1. Redistributions of source code must retain the above copyright
14+
* notice, this list of conditions and the following disclaimer.
15+
* 2. Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in the
17+
* documentation and/or other materials provided with the distribution.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
/* ansiprsr.c
31+
*
32+
* ANSI Parser to run on Win32 based operating systems.
1133
*
12-
* 1. Redistributions of source code must retain the above copyright notice.
13-
* 2. Binaries produced provide no direct or implied warranties or any
14-
* guarantee of performance or suitability.
1534
*/
1635

1736
#include <stdlib.h>
@@ -32,7 +51,6 @@
3251
// items used from other modules
3352
int NetWriteString(char* pszString, size_t cbString);
3453
TelParams Parameters;
35-
extern int lftocrlf;
3654

3755
extern int ScreenX;
3856
extern int ScreenY;
@@ -388,12 +406,10 @@ void ConSetExtendedMode(int iFunction, BOOL bEnable)
388406
case 20: // LNM Mode CSI 20h
389407
if (bEnable){
390408
VTMode |= MODE_LNM;
391-
Parameters.nReceiveCRLF = ENUM_LF;
392-
lftocrlf = 1;
409+
Parameters.nReceiveCRLF = ENUM_CRLF;
393410
}else{
394411
VTMode &= ~MODE_LNM;
395-
Parameters.nReceiveCRLF = ENUM_CRLF;
396-
lftocrlf = 0;
412+
Parameters.nReceiveCRLF = ENUM_LF;
397413
}
398414
break;
399415
case 25:

0 commit comments

Comments
 (0)