summaryrefslogtreecommitdiff
path: root/monitor_wrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor_wrap.c')
-rw-r--r--monitor_wrap.c102
1 files changed, 86 insertions, 16 deletions
diff --git a/monitor_wrap.c b/monitor_wrap.c
index f7e332d8e..4c53bfd13 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: monitor_wrap.c,v 1.11 2002/06/19 18:01:00 markus Exp $"); 28RCSID("$OpenBSD: monitor_wrap.c,v 1.19 2002/09/26 11:38:43 markus Exp $");
29 29
30#include <openssl/bn.h> 30#include <openssl/bn.h>
31#include <openssl/dh.h> 31#include <openssl/dh.h>
@@ -62,8 +62,8 @@ extern Buffer input, output;
62void 62void
63mm_request_send(int socket, enum monitor_reqtype type, Buffer *m) 63mm_request_send(int socket, enum monitor_reqtype type, Buffer *m)
64{ 64{
65 u_char buf[5];
66 u_int mlen = buffer_len(m); 65 u_int mlen = buffer_len(m);
66 u_char buf[5];
67 67
68 debug3("%s entering: type %d", __func__, type); 68 debug3("%s entering: type %d", __func__, type);
69 69
@@ -79,8 +79,8 @@ void
79mm_request_receive(int socket, Buffer *m) 79mm_request_receive(int socket, Buffer *m)
80{ 80{
81 u_char buf[4]; 81 u_char buf[4];
82 ssize_t res;
83 u_int msg_len; 82 u_int msg_len;
83 ssize_t res;
84 84
85 debug3("%s entering", __func__); 85 debug3("%s entering", __func__);
86 86
@@ -207,7 +207,7 @@ mm_getpwnamallow(const char *login)
207 return (pw); 207 return (pw);
208} 208}
209 209
210char* mm_auth2_read_banner(void) 210char *mm_auth2_read_banner(void)
211{ 211{
212 Buffer m; 212 Buffer m;
213 char *banner; 213 char *banner;
@@ -411,7 +411,7 @@ mm_newkeys_from_blob(u_char *blob, int blen)
411 enc->key = buffer_get_string(&b, &enc->key_len); 411 enc->key = buffer_get_string(&b, &enc->key_len);
412 enc->iv = buffer_get_string(&b, &len); 412 enc->iv = buffer_get_string(&b, &len);
413 if (len != enc->block_size) 413 if (len != enc->block_size)
414 fatal("%s: bad ivlen: expected %d != %d", __func__, 414 fatal("%s: bad ivlen: expected %u != %u", __func__,
415 enc->block_size, len); 415 enc->block_size, len);
416 416
417 if (enc->name == NULL || cipher_by_name(enc->name) != enc->cipher) 417 if (enc->name == NULL || cipher_by_name(enc->name) != enc->cipher)
@@ -425,7 +425,7 @@ mm_newkeys_from_blob(u_char *blob, int blen)
425 mac->enabled = buffer_get_int(&b); 425 mac->enabled = buffer_get_int(&b);
426 mac->key = buffer_get_string(&b, &len); 426 mac->key = buffer_get_string(&b, &len);
427 if (len > mac->key_len) 427 if (len > mac->key_len)
428 fatal("%s: bad mac key length: %d > %d", __func__, len, 428 fatal("%s: bad mac key length: %u > %d", __func__, len,
429 mac->key_len); 429 mac->key_len);
430 mac->key_len = len; 430 mac->key_len = len;
431 431
@@ -436,7 +436,7 @@ mm_newkeys_from_blob(u_char *blob, int blen)
436 436
437 len = buffer_len(&b); 437 len = buffer_len(&b);
438 if (len != 0) 438 if (len != 0)
439 error("newkeys_from_blob: remaining bytes in blob %d", len); 439 error("newkeys_from_blob: remaining bytes in blob %u", len);
440 buffer_free(&b); 440 buffer_free(&b);
441 return (newkey); 441 return (newkey);
442} 442}
@@ -446,7 +446,6 @@ mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp)
446{ 446{
447 Buffer b; 447 Buffer b;
448 int len; 448 int len;
449 u_char *buf;
450 Enc *enc; 449 Enc *enc;
451 Mac *mac; 450 Mac *mac;
452 Comp *comp; 451 Comp *comp;
@@ -484,14 +483,14 @@ mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp)
484 buffer_put_cstring(&b, comp->name); 483 buffer_put_cstring(&b, comp->name);
485 484
486 len = buffer_len(&b); 485 len = buffer_len(&b);
487 buf = xmalloc(len);
488 memcpy(buf, buffer_ptr(&b), len);
489 memset(buffer_ptr(&b), 0, len);
490 buffer_free(&b);
491 if (lenp != NULL) 486 if (lenp != NULL)
492 *lenp = len; 487 *lenp = len;
493 if (blobp != NULL) 488 if (blobp != NULL) {
494 *blobp = buf; 489 *blobp = xmalloc(len);
490 memcpy(*blobp, buffer_ptr(&b), len);
491 }
492 memset(buffer_ptr(&b), 0, len);
493 buffer_free(&b);
495 return len; 494 return len;
496} 495}
497 496
@@ -600,7 +599,7 @@ int
600mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) 599mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
601{ 600{
602 Buffer m; 601 Buffer m;
603 u_char *p; 602 char *p;
604 int success = 0; 603 int success = 0;
605 604
606 buffer_init(&m); 605 buffer_init(&m);
@@ -705,7 +704,7 @@ mm_chall_setup(char **name, char **infotxt, u_int *numprompts,
705 *name = xstrdup(""); 704 *name = xstrdup("");
706 *infotxt = xstrdup(""); 705 *infotxt = xstrdup("");
707 *numprompts = 1; 706 *numprompts = 1;
708 *prompts = xmalloc(*numprompts * sizeof(char*)); 707 *prompts = xmalloc(*numprompts * sizeof(char *));
709 *echo_on = xmalloc(*numprompts * sizeof(u_int)); 708 *echo_on = xmalloc(*numprompts * sizeof(u_int));
710 (*echo_on)[0] = 0; 709 (*echo_on)[0] = 0;
711} 710}
@@ -937,3 +936,74 @@ mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16])
937 936
938 return (success); 937 return (success);
939} 938}
939
940#ifdef KRB4
941int
942mm_auth_krb4(Authctxt *authctxt, void *_auth, char **client, void *_reply)
943{
944 KTEXT auth, reply;
945 Buffer m;
946 u_int rlen;
947 int success = 0;
948 char *p;
949
950 debug3("%s entering", __func__);
951 auth = _auth;
952 reply = _reply;
953
954 buffer_init(&m);
955 buffer_put_string(&m, auth->dat, auth->length);
956
957 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB4, &m);
958 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB4, &m);
959
960 success = buffer_get_int(&m);
961 if (success) {
962 *client = buffer_get_string(&m, NULL);
963 p = buffer_get_string(&m, &rlen);
964 if (rlen >= MAX_KTXT_LEN)
965 fatal("%s: reply from monitor too large", __func__);
966 reply->length = rlen;
967 memcpy(reply->dat, p, rlen);
968 memset(p, 0, rlen);
969 xfree(p);
970 }
971 buffer_free(&m);
972 return (success);
973}
974#endif
975
976#ifdef KRB5
977int
978mm_auth_krb5(void *ctx, void *argp, char **userp, void *resp)
979{
980 krb5_data *tkt, *reply;
981 Buffer m;
982 int success;
983
984 debug3("%s entering", __func__);
985 tkt = (krb5_data *) argp;
986 reply = (krb5_data *) resp;
987
988 buffer_init(&m);
989 buffer_put_string(&m, tkt->data, tkt->length);
990
991 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB5, &m);
992 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB5, &m);
993
994 success = buffer_get_int(&m);
995 if (success) {
996 u_int len;
997
998 *userp = buffer_get_string(&m, NULL);
999 reply->data = buffer_get_string(&m, &len);
1000 reply->length = len;
1001 } else {
1002 memset(reply, 0, sizeof(*reply));
1003 *userp = NULL;
1004 }
1005
1006 buffer_free(&m);
1007 return (success);
1008}
1009#endif