summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-11-13 22:57:25 +1100
committerDamien Miller <djm@mindrot.org>2000-11-13 22:57:25 +1100
commit0bc1bd814e3c2b5e92d6f595930051960d17f47f (patch)
tree176c7dc2844ecc2c1de0f72d221449556ffa5209 /clientloop.c
parent559d383037b0872fcde4e6c40188b649c574be74 (diff)
- (djm) Merge OpenBSD changes:
- markus@cvs.openbsd.org 2000/11/06 16:04:56 [channels.c channels.h clientloop.c nchan.c serverloop.c] [session.c ssh.c] agent forwarding and -R for ssh2, based on work from jhuuskon@messi.uku.fi - markus@cvs.openbsd.org 2000/11/06 16:13:27 [ssh.c sshconnect.c sshd.c] do not disabled rhosts(rsa) if server port > 1024; from pekkas@netcore.fi - markus@cvs.openbsd.org 2000/11/06 16:16:35 [sshconnect.c] downgrade client to 1.3 if server is 1.4; help from mdb@juniper.net - markus@cvs.openbsd.org 2000/11/09 18:04:40 [auth1.c] typo; from mouring@pconline.com - markus@cvs.openbsd.org 2000/11/12 12:03:28 [ssh-agent.c] off-by-one when removing a key from the agent - markus@cvs.openbsd.org 2000/11/12 12:50:39 [auth-rh-rsa.c auth2.c authfd.c authfd.h] [authfile.c hostfile.c kex.c kex.h key.c key.h myproposal.h] [readconf.c readconf.h rsa.c rsa.h servconf.c servconf.h ssh-add.c] [ssh-agent.c ssh-keygen.1 ssh-keygen.c ssh.1 ssh.c ssh_config] [sshconnect1.c sshconnect2.c sshd.8 sshd.c sshd_config ssh-dss.c] [ssh-dss.h ssh-rsa.c ssh-rsa.h dsa.c dsa.h] add support for RSA to SSH2. please test. there are now 3 types of keys: RSA1 is used by ssh-1 only, RSA and DSA are used by SSH2. you can use 'ssh-keygen -t rsa -f ssh2_rsa_file' to generate RSA keys for SSH2 and use the RSA keys for hostkeys or for user keys. SSH2 RSA or DSA keys are added to .ssh/authorised_keys2 as before. - (djm) Fix up Makefile and Redhat init script to create RSA host keys - (djm) Change to interim version
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c122
1 files changed, 98 insertions, 24 deletions
diff --git a/clientloop.c b/clientloop.c
index bccb9be2f..8f16d2fb9 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.39 2000/10/27 07:48:22 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.40 2000/11/06 23:04:56 markus Exp $");
63 63
64#include "xmalloc.h" 64#include "xmalloc.h"
65#include "ssh.h" 65#include "ssh.h"
@@ -75,6 +75,10 @@ RCSID("$OpenBSD: clientloop.c,v 1.39 2000/10/27 07:48:22 markus Exp $");
75#include "buffer.h" 75#include "buffer.h"
76#include "bufaux.h" 76#include "bufaux.h"
77 77
78#include <openssl/dsa.h>
79#include <openssl/rsa.h>
80#include "key.h"
81#include "authfd.h"
78 82
79/* import options */ 83/* import options */
80extern Options options; 84extern Options options;
@@ -1016,13 +1020,99 @@ client_input_exit_status(int type, int plen, void *ctxt)
1016 quit_pending = 1; 1020 quit_pending = 1;
1017} 1021}
1018 1022
1023Channel *
1024client_request_forwarded_tcpip(const char *request_type, int rchan)
1025{
1026 Channel* c = NULL;
1027 char *listen_address, *originator_address;
1028 int listen_port, originator_port;
1029 int sock, newch;
1030
1031 /* Get rest of the packet */
1032 listen_address = packet_get_string(NULL);
1033 listen_port = packet_get_int();
1034 originator_address = packet_get_string(NULL);
1035 originator_port = packet_get_int();
1036 packet_done();
1037
1038 debug("client_request_forwarded_tcpip: listen %s port %d, originator %s port %d",
1039 listen_address, listen_port, originator_address, originator_port);
1040
1041 sock = channel_connect_by_listen_adress(listen_port);
1042 if (sock >= 0) {
1043 newch = channel_new("forwarded-tcpip",
1044 SSH_CHANNEL_OPEN, sock, sock, -1,
1045 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
1046 xstrdup(originator_address), 1);
1047 c = channel_lookup(newch);
1048 }
1049 xfree(originator_address);
1050 xfree(listen_address);
1051 return c;
1052}
1053
1054Channel*
1055client_request_x11(const char *request_type, int rchan)
1056{
1057 Channel *c = NULL;
1058 char *originator;
1059 int originator_port;
1060 int sock, newch;
1061
1062 if (!options.forward_x11) {
1063 error("Warning: ssh server tried X11 forwarding.");
1064 error("Warning: this is probably a break in attempt by a malicious server.");
1065 return NULL;
1066 }
1067 originator = packet_get_string(NULL);
1068 if (datafellows & SSH_BUG_X11FWD) {
1069 debug2("buggy server: x11 request w/o originator_port");
1070 originator_port = 0;
1071 } else {
1072 originator_port = packet_get_int();
1073 }
1074 packet_done();
1075 /* XXX check permission */
1076 sock = x11_connect_display();
1077 if (sock >= 0) {
1078 newch = channel_new("x11",
1079 SSH_CHANNEL_X11_OPEN, sock, sock, -1,
1080 CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0,
1081 xstrdup("x11"), 1);
1082 c = channel_lookup(newch);
1083 }
1084 xfree(originator);
1085 return c;
1086}
1087
1088Channel*
1089client_request_agent(const char *request_type, int rchan)
1090{
1091 Channel *c = NULL;
1092 int sock, newch;
1093
1094 if (!options.forward_agent) {
1095 error("Warning: ssh server tried agent forwarding.");
1096 error("Warning: this is probably a break in attempt by a malicious server.");
1097 return NULL;
1098 }
1099 sock = ssh_get_authentication_socket();
1100 if (sock >= 0) {
1101 newch = channel_new("authentication agent connection",
1102 SSH_CHANNEL_OPEN, sock, sock, -1,
1103 CHAN_X11_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
1104 xstrdup("authentication agent connection"), 1);
1105 c = channel_lookup(newch);
1106 }
1107 return c;
1108}
1109
1019/* XXXX move to generic input handler */ 1110/* XXXX move to generic input handler */
1020void 1111void
1021client_input_channel_open(int type, int plen, void *ctxt) 1112client_input_channel_open(int type, int plen, void *ctxt)
1022{ 1113{
1023 Channel *c = NULL; 1114 Channel *c = NULL;
1024 char *ctype; 1115 char *ctype;
1025 int id;
1026 unsigned int len; 1116 unsigned int len;
1027 int rchan; 1117 int rchan;
1028 int rmaxpack; 1118 int rmaxpack;
@@ -1036,28 +1126,12 @@ client_input_channel_open(int type, int plen, void *ctxt)
1036 debug("client_input_channel_open: ctype %s rchan %d win %d max %d", 1126 debug("client_input_channel_open: ctype %s rchan %d win %d max %d",
1037 ctype, rchan, rwindow, rmaxpack); 1127 ctype, rchan, rwindow, rmaxpack);
1038 1128
1039 if (strcmp(ctype, "x11") == 0 && options.forward_x11) { 1129 if (strcmp(ctype, "forwarded-tcpip") == 0) {
1040 int sock; 1130 c = client_request_forwarded_tcpip(ctype, rchan);
1041 char *originator; 1131 } else if (strcmp(ctype, "x11") == 0) {
1042 int originator_port; 1132 c = client_request_x11(ctype, rchan);
1043 originator = packet_get_string(NULL); 1133 } else if (strcmp(ctype, "auth-agent@openssh.com") == 0) {
1044 if (datafellows & SSH_BUG_X11FWD) { 1134 c = client_request_agent(ctype, rchan);
1045 debug2("buggy server: x11 request w/o originator_port");
1046 originator_port = 0;
1047 } else {
1048 originator_port = packet_get_int();
1049 }
1050 packet_done();
1051 /* XXX check permission */
1052 xfree(originator);
1053 /* XXX move to channels.c */
1054 sock = x11_connect_display();
1055 if (sock >= 0) {
1056 id = channel_new("x11", SSH_CHANNEL_X11_OPEN,
1057 sock, sock, -1, CHAN_X11_WINDOW_DEFAULT,
1058 CHAN_X11_PACKET_DEFAULT, 0, xstrdup("x11"), 1);
1059 c = channel_lookup(id);
1060 }
1061 } 1135 }
1062/* XXX duplicate : */ 1136/* XXX duplicate : */
1063 if (c != NULL) { 1137 if (c != NULL) {