summaryrefslogtreecommitdiff
path: root/sshconnect1.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2007-06-12 16:16:35 +0000
committerColin Watson <cjwatson@debian.org>2007-06-12 16:16:35 +0000
commitb7e40fa9da0b5491534a429dadb321eab5a77558 (patch)
treebed1da11e9f829925797aa093e379fc0b5868ecd /sshconnect1.c
parent4f84beedf1005e44ff33c854abd6b711ffc0adb7 (diff)
parent086ea76990b1e6287c24b6db74adffd4605eb3b0 (diff)
* New upstream release (closes: #395507, #397961, #420035). Important
changes not previously backported to 4.3p2: - 4.4/4.4p1 (http://www.openssh.org/txt/release-4.4): + On portable OpenSSH, fix a GSSAPI authentication abort that could be used to determine the validity of usernames on some platforms. + Implemented conditional configuration in sshd_config(5) using the "Match" directive. This allows some configuration options to be selectively overridden if specific criteria (based on user, group, hostname and/or address) are met. So far a useful subset of post-authentication options are supported and more are expected to be added in future releases. + Add support for Diffie-Hellman group exchange key agreement with a final hash of SHA256. + Added a "ForceCommand" directive to sshd_config(5). Similar to the command="..." option accepted in ~/.ssh/authorized_keys, this forces the execution of the specified command regardless of what the user requested. This is very useful in conjunction with the new "Match" option. + Add a "PermitOpen" directive to sshd_config(5). This mirrors the permitopen="..." authorized_keys option, allowing fine-grained control over the port-forwardings that a user is allowed to establish. + Add optional logging of transactions to sftp-server(8). + ssh(1) will now record port numbers for hosts stored in ~/.ssh/known_hosts when a non-standard port has been requested (closes: #50612). + Add an "ExitOnForwardFailure" option to cause ssh(1) to exit (with a non-zero exit code) when requested port forwardings could not be established. + Extend sshd_config(5) "SubSystem" declarations to allow the specification of command-line arguments. + Replacement of all integer overflow susceptible invocations of malloc(3) and realloc(3) with overflow-checking equivalents. + Many manpage fixes and improvements. + Add optional support for OpenSSL hardware accelerators (engines), enabled using the --with-ssl-engine configure option. + Tokens in configuration files may be double-quoted in order to contain spaces (closes: #319639). + Move a debug() call out of a SIGCHLD handler, fixing a hang when the session exits very quickly (closes: #307890). + Fix some incorrect buffer allocation calculations (closes: #410599). + ssh-add doesn't ask for a passphrase if key file permissions are too liberal (closes: #103677). + Likewise, ssh doesn't ask either (closes: #99675). - 4.6/4.6p1 (http://www.openssh.org/txt/release-4.6): + sshd now allows the enabling and disabling of authentication methods on a per user, group, host and network basis via the Match directive in sshd_config. + Fixed an inconsistent check for a terminal when displaying scp progress meter (closes: #257524). + Fix "hang on exit" when background processes are running at the time of exit on a ttyful/login session (closes: #88337). * Update to current GSSAPI patch from http://www.sxw.org.uk/computing/patches/openssh-4.6p1-gsskex-20070312.patch; install ChangeLog.gssapi.
Diffstat (limited to 'sshconnect1.c')
-rw-r--r--sshconnect1.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/sshconnect1.c b/sshconnect1.c
index 440d7c5bd..fd07bbf74 100644
--- a/sshconnect1.c
+++ b/sshconnect1.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: sshconnect1.c,v 1.70 2006/11/06 21:25:28 markus Exp $ */
1/* 2/*
2 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -13,28 +14,38 @@
13 */ 14 */
14 15
15#include "includes.h" 16#include "includes.h"
16RCSID("$OpenBSD: sshconnect1.c,v 1.62 2005/10/30 08:52:18 djm Exp $"); 17
18#include <sys/types.h>
19#include <sys/socket.h>
17 20
18#include <openssl/bn.h> 21#include <openssl/bn.h>
19#include <openssl/md5.h> 22#include <openssl/md5.h>
20 23
24#include <stdarg.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <signal.h>
29#include <pwd.h>
30
31#include "xmalloc.h"
21#include "ssh.h" 32#include "ssh.h"
22#include "ssh1.h" 33#include "ssh1.h"
23#include "xmalloc.h"
24#include "rsa.h" 34#include "rsa.h"
25#include "buffer.h" 35#include "buffer.h"
26#include "packet.h" 36#include "packet.h"
37#include "key.h"
38#include "cipher.h"
27#include "kex.h" 39#include "kex.h"
28#include "uidswap.h" 40#include "uidswap.h"
29#include "log.h" 41#include "log.h"
30#include "readconf.h" 42#include "readconf.h"
31#include "key.h"
32#include "authfd.h" 43#include "authfd.h"
33#include "sshconnect.h" 44#include "sshconnect.h"
34#include "authfile.h" 45#include "authfile.h"
35#include "misc.h" 46#include "misc.h"
36#include "cipher.h"
37#include "canohost.h" 47#include "canohost.h"
48#include "hostfile.h"
38#include "auth.h" 49#include "auth.h"
39 50
40/* Session id for the current session. */ 51/* Session id for the current session. */
@@ -197,7 +208,7 @@ try_rsa_authentication(int idx)
197 BIGNUM *challenge; 208 BIGNUM *challenge;
198 Key *public, *private; 209 Key *public, *private;
199 char buf[300], *passphrase, *comment, *authfile; 210 char buf[300], *passphrase, *comment, *authfile;
200 int i, type, quit; 211 int i, perm_ok = 1, type, quit;
201 212
202 public = options.identity_keys[idx]; 213 public = options.identity_keys[idx];
203 authfile = options.identity_files[idx]; 214 authfile = options.identity_files[idx];
@@ -243,15 +254,16 @@ try_rsa_authentication(int idx)
243 if (public->flags & KEY_FLAG_EXT) 254 if (public->flags & KEY_FLAG_EXT)
244 private = public; 255 private = public;
245 else 256 else
246 private = key_load_private_type(KEY_RSA1, authfile, "", NULL); 257 private = key_load_private_type(KEY_RSA1, authfile, "", NULL,
247 if (private == NULL && !options.batch_mode) { 258 &perm_ok);
259 if (private == NULL && !options.batch_mode && perm_ok) {
248 snprintf(buf, sizeof(buf), 260 snprintf(buf, sizeof(buf),
249 "Enter passphrase for RSA key '%.100s': ", comment); 261 "Enter passphrase for RSA key '%.100s': ", comment);
250 for (i = 0; i < options.number_of_password_prompts; i++) { 262 for (i = 0; i < options.number_of_password_prompts; i++) {
251 passphrase = read_passphrase(buf, 0); 263 passphrase = read_passphrase(buf, 0);
252 if (strcmp(passphrase, "") != 0) { 264 if (strcmp(passphrase, "") != 0) {
253 private = key_load_private_type(KEY_RSA1, 265 private = key_load_private_type(KEY_RSA1,
254 authfile, passphrase, NULL); 266 authfile, passphrase, NULL, NULL);
255 quit = 0; 267 quit = 0;
256 } else { 268 } else {
257 debug2("no passphrase given, try next key"); 269 debug2("no passphrase given, try next key");
@@ -268,7 +280,7 @@ try_rsa_authentication(int idx)
268 xfree(comment); 280 xfree(comment);
269 281
270 if (private == NULL) { 282 if (private == NULL) {
271 if (!options.batch_mode) 283 if (!options.batch_mode && perm_ok)
272 error("Bad passphrase."); 284 error("Bad passphrase.");
273 285
274 /* Send a dummy response packet to avoid protocol error. */ 286 /* Send a dummy response packet to avoid protocol error. */
@@ -551,14 +563,20 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
551 * the first 16 bytes of the session id. 563 * the first 16 bytes of the session id.
552 */ 564 */
553 if ((key = BN_new()) == NULL) 565 if ((key = BN_new()) == NULL)
554 fatal("respond_to_rsa_challenge: BN_new failed"); 566 fatal("ssh_kex: BN_new failed");
555 BN_set_word(key, 0); 567 if (BN_set_word(key, 0) == 0)
568 fatal("ssh_kex: BN_set_word failed");
556 for (i = 0; i < SSH_SESSION_KEY_LENGTH; i++) { 569 for (i = 0; i < SSH_SESSION_KEY_LENGTH; i++) {
557 BN_lshift(key, key, 8); 570 if (BN_lshift(key, key, 8) == 0)
558 if (i < 16) 571 fatal("ssh_kex: BN_lshift failed");
559 BN_add_word(key, session_key[i] ^ session_id[i]); 572 if (i < 16) {
560 else 573 if (BN_add_word(key, session_key[i] ^ session_id[i])
561 BN_add_word(key, session_key[i]); 574 == 0)
575 fatal("ssh_kex: BN_add_word failed");
576 } else {
577 if (BN_add_word(key, session_key[i]) == 0)
578 fatal("ssh_kex: BN_add_word failed");
579 }
562 } 580 }
563 581
564 /* 582 /*