summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/sshd.810
-rw-r--r--usr.bin/ssh/sshd.c68
2 files changed, 50 insertions, 28 deletions
diff --git a/usr.bin/ssh/sshd.8 b/usr.bin/ssh/sshd.8
index 309c50c7eda..c2162c0581c 100644
--- a/usr.bin/ssh/sshd.8
+++ b/usr.bin/ssh/sshd.8
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 21:55:14 1995 ylo
.\"
-.\" $Id: sshd.8,v 1.25 1999/11/19 09:46:49 markus Exp $
+.\" $Id: sshd.8,v 1.26 1999/11/22 20:02:45 markus Exp $
.\"
.Dd September 25, 1999
.Dt SSHD 8
@@ -26,6 +26,7 @@
.Op Fl h Ar host_key_file
.Op Fl k Ar key_gen_time
.Op Fl p Ar port
+.Op Fl V Ar client_protocol_id
.Sh DESCRIPTION
.Nm
(Secure Shell Daemon) is the daemon program for
@@ -165,6 +166,13 @@ Quiet mode. Nothing is sent to the system log. Normally the beginning,
authentication, and termination of each connection is logged.
.It Fl Q
Do not print an error message if RSA support is missing.
+.It Fl V Ar client_protocol_id
+SSH2 compatibility mode.
+When this options is specified
+.Nm
+assumes the client has sent the given version string
+and skips the
+Protocol Version Identification Exchange.
.El
.Sh CONFIGURATION FILE
.Nm
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index d06372a19c6..afa9667058d 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -18,7 +18,7 @@ agent connections.
*/
#include "includes.h"
-RCSID("$Id: sshd.c,v 1.60 1999/11/20 20:07:23 deraadt Exp $");
+RCSID("$Id: sshd.c,v 1.61 1999/11/22 20:02:45 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -74,6 +74,10 @@ char **saved_argv;
the SIGHUP signal handler. */
int listen_sock;
+/* the client's version string, passed by sshd2 in compat mode.
+ if != NULL, sshd will skip the version-number exchange */
+char *client_version_string = NULL;
+
/* Flags set in auth-rsa from authorized_keys flags. These are set in
auth-rsa.c. */
int no_port_forwarding_flag = 0;
@@ -254,7 +258,7 @@ main(int ac, char **av)
initialize_server_options(&options);
/* Parse command-line arguments. */
- while ((opt = getopt(ac, av, "f:p:b:k:h:g:diqQ")) != EOF)
+ while ((opt = getopt(ac, av, "f:p:b:k:h:g:V:diqQ")) != EOF)
{
switch (opt)
{
@@ -289,6 +293,11 @@ main(int ac, char **av)
case 'h':
options.host_key_file = optarg;
break;
+ case 'V':
+ client_version_string = optarg;
+ /* only makes sense with inetd_flag, i.e. no listen() */
+ inetd_flag = 1;
+ break;
case '?':
default:
fprintf(stderr, "sshd version %s\n", SSH_VERSION);
@@ -631,31 +640,36 @@ main(int ac, char **av)
if (!debug_flag)
alarm(options.login_grace_time);
- /* Send our protocol version identification. */
- snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s\n",
- PROTOCOL_MAJOR, PROTOCOL_MINOR, SSH_VERSION);
- if (write(sock_out, buf, strlen(buf)) != strlen(buf))
- fatal("Could not write ident string.");
-
- /* Read other side\'s version identification. */
- for (i = 0; i < sizeof(buf) - 1; i++)
- {
- if (read(sock_in, &buf[i], 1) != 1)
- fatal("Did not receive ident string.");
- if (buf[i] == '\r')
- {
- buf[i] = '\n';
- buf[i + 1] = 0;
- break;
- }
- if (buf[i] == '\n')
- {
- /* buf[i] == '\n' */
- buf[i + 1] = 0;
- break;
- }
- }
- buf[sizeof(buf) - 1] = 0;
+ if (client_version_string != NULL) {
+ /* we are exec'ed by sshd2, so skip exchange of protocol version */
+ strlcpy(buf, client_version_string, sizeof(buf));
+ } else {
+ /* Send our protocol version identification. */
+ snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s\n",
+ PROTOCOL_MAJOR, PROTOCOL_MINOR, SSH_VERSION);
+ if (write(sock_out, buf, strlen(buf)) != strlen(buf))
+ fatal("Could not write ident string.");
+
+ /* Read other side\'s version identification. */
+ for (i = 0; i < sizeof(buf) - 1; i++)
+ {
+ if (read(sock_in, &buf[i], 1) != 1)
+ fatal("Did not receive ident string.");
+ if (buf[i] == '\r')
+ {
+ buf[i] = '\n';
+ buf[i + 1] = 0;
+ break;
+ }
+ if (buf[i] == '\n')
+ {
+ /* buf[i] == '\n' */
+ buf[i + 1] = 0;
+ break;
+ }
+ }
+ buf[sizeof(buf) - 1] = 0;
+ }
/* Check that the versions match. In future this might accept several
versions and set appropriate flags to handle them. */