Mercurial > dropbear
comparison cli-agentfwd.c @ 910:89555751c489 asm
merge up to 2013.63, improve ASM makefile rules a bit
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 27 Feb 2014 21:35:58 +0800 |
parents | 30ab30e46452 |
children | 0bb16232e7c4 |
comparison
equal
deleted
inserted
replaced
909:e4b75744acab | 910:89555751c489 |
---|---|
32 #include "dbutil.h" | 32 #include "dbutil.h" |
33 #include "chansession.h" | 33 #include "chansession.h" |
34 #include "channel.h" | 34 #include "channel.h" |
35 #include "packet.h" | 35 #include "packet.h" |
36 #include "buffer.h" | 36 #include "buffer.h" |
37 #include "random.h" | 37 #include "dbrandom.h" |
38 #include "listener.h" | 38 #include "listener.h" |
39 #include "runopts.h" | 39 #include "runopts.h" |
40 #include "atomicio.h" | 40 #include "atomicio.h" |
41 #include "signkey.h" | 41 #include "signkey.h" |
42 #include "auth.h" | 42 #include "auth.h" |
71 } | 71 } |
72 | 72 |
73 return fd; | 73 return fd; |
74 } | 74 } |
75 | 75 |
76 // handle a request for a connection to the locally running ssh-agent | 76 /* handle a request for a connection to the locally running ssh-agent |
77 // or forward. | 77 or forward. */ |
78 static int new_agent_chan(struct Channel * channel) { | 78 static int new_agent_chan(struct Channel * channel) { |
79 | 79 |
80 int fd = -1; | 80 int fd = -1; |
81 | 81 |
82 if (!cli_opts.agent_fwd) | 82 if (!cli_opts.agent_fwd) |
92 ses.maxfd = MAX(ses.maxfd, fd); | 92 ses.maxfd = MAX(ses.maxfd, fd); |
93 | 93 |
94 channel->readfd = fd; | 94 channel->readfd = fd; |
95 channel->writefd = fd; | 95 channel->writefd = fd; |
96 | 96 |
97 // success | |
98 return 0; | 97 return 0; |
99 } | 98 } |
100 | 99 |
101 /* Sends a request to the agent, returning a newly allocated buffer | 100 /* Sends a request to the agent, returning a newly allocated buffer |
102 * with the response */ | 101 * with the response */ |
200 } | 199 } |
201 | 200 |
202 num = buf_getint(inbuf); | 201 num = buf_getint(inbuf); |
203 for (i = 0; i < num; i++) { | 202 for (i = 0; i < num; i++) { |
204 sign_key * pubkey = NULL; | 203 sign_key * pubkey = NULL; |
205 int key_type = DROPBEAR_SIGNKEY_ANY; | 204 enum signkey_type key_type = DROPBEAR_SIGNKEY_ANY; |
206 buffer * key_buf; | 205 buffer * key_buf; |
207 | 206 |
208 /* each public key is encoded as a string */ | 207 /* each public key is encoded as a string */ |
209 key_buf = buf_getstringbuf(inbuf); | 208 key_buf = buf_getstringbuf(inbuf); |
210 pubkey = new_sign_key(); | 209 pubkey = new_sign_key(); |
252 | 251 |
253 agent_get_key_list(ret_list); | 252 agent_get_key_list(ret_list); |
254 } | 253 } |
255 | 254 |
256 void agent_buf_sign(buffer *sigblob, sign_key *key, | 255 void agent_buf_sign(buffer *sigblob, sign_key *key, |
257 const unsigned char *data, unsigned int len) { | 256 buffer *data_buf) { |
258 buffer *request_data = NULL; | 257 buffer *request_data = NULL; |
259 buffer *response = NULL; | 258 buffer *response = NULL; |
260 unsigned int siglen; | 259 unsigned int siglen; |
261 int packet_type; | 260 int packet_type; |
262 | 261 |
264 byte SSH2_AGENTC_SIGN_REQUEST | 263 byte SSH2_AGENTC_SIGN_REQUEST |
265 string key_blob | 264 string key_blob |
266 string data | 265 string data |
267 uint32 flags | 266 uint32 flags |
268 */ | 267 */ |
269 request_data = buf_new(MAX_PUBKEY_SIZE + len + 12); | 268 request_data = buf_new(MAX_PUBKEY_SIZE + data_buf->len + 12); |
270 buf_put_pub_key(request_data, key, key->type); | 269 buf_put_pub_key(request_data, key, key->type); |
271 | 270 |
272 buf_putstring(request_data, data, len); | 271 buf_putbufstring(request_data, data_buf); |
273 buf_putint(request_data, 0); | 272 buf_putint(request_data, 0); |
274 | 273 |
275 response = agent_request(SSH2_AGENTC_SIGN_REQUEST, request_data); | 274 response = agent_request(SSH2_AGENTC_SIGN_REQUEST, request_data); |
276 | 275 |
277 if (!response) { | 276 if (!response) { |