=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/monitor_wrap.c,v retrieving revision 1.5.2.3 retrieving revision 1.5.2.4 diff -u -r1.5.2.3 -r1.5.2.4 --- src/usr.bin/ssh/monitor_wrap.c 2002/06/26 15:30:38 1.5.2.3 +++ src/usr.bin/ssh/monitor_wrap.c 2002/10/11 14:51:52 1.5.2.4 @@ -25,7 +25,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor_wrap.c,v 1.5.2.3 2002/06/26 15:30:38 jason Exp $"); +RCSID("$OpenBSD: monitor_wrap.c,v 1.5.2.4 2002/10/11 14:51:52 miod Exp $"); #include #include @@ -62,8 +62,8 @@ void mm_request_send(int socket, enum monitor_reqtype type, Buffer *m) { - u_char buf[5]; u_int mlen = buffer_len(m); + u_char buf[5]; debug3("%s entering: type %d", __func__, type); @@ -79,8 +79,8 @@ mm_request_receive(int socket, Buffer *m) { u_char buf[4]; - ssize_t res; u_int msg_len; + ssize_t res; debug3("%s entering", __func__); @@ -205,7 +205,7 @@ return (pw); } -char* mm_auth2_read_banner(void) +char *mm_auth2_read_banner(void) { Buffer m; char *banner; @@ -409,7 +409,7 @@ enc->key = buffer_get_string(&b, &enc->key_len); enc->iv = buffer_get_string(&b, &len); if (len != enc->block_size) - fatal("%s: bad ivlen: expected %d != %d", __func__, + fatal("%s: bad ivlen: expected %u != %u", __func__, enc->block_size, len); if (enc->name == NULL || cipher_by_name(enc->name) != enc->cipher) @@ -423,7 +423,7 @@ mac->enabled = buffer_get_int(&b); mac->key = buffer_get_string(&b, &len); if (len > mac->key_len) - fatal("%s: bad mac key length: %d > %d", __func__, len, + fatal("%s: bad mac key length: %u > %d", __func__, len, mac->key_len); mac->key_len = len; @@ -434,7 +434,7 @@ len = buffer_len(&b); if (len != 0) - error("newkeys_from_blob: remaining bytes in blob %d", len); + error("newkeys_from_blob: remaining bytes in blob %u", len); buffer_free(&b); return (newkey); } @@ -444,7 +444,6 @@ { Buffer b; int len; - u_char *buf; Enc *enc; Mac *mac; Comp *comp; @@ -482,14 +481,14 @@ buffer_put_cstring(&b, comp->name); len = buffer_len(&b); - buf = xmalloc(len); - memcpy(buf, buffer_ptr(&b), len); - memset(buffer_ptr(&b), 0, len); - buffer_free(&b); if (lenp != NULL) *lenp = len; - if (blobp != NULL) - *blobp = buf; + if (blobp != NULL) { + *blobp = xmalloc(len); + memcpy(*blobp, buffer_ptr(&b), len); + } + memset(buffer_ptr(&b), 0, len); + buffer_free(&b); return len; } @@ -598,7 +597,7 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) { Buffer m; - u_char *p; + char *p; int success = 0; buffer_init(&m); @@ -686,7 +685,7 @@ *name = xstrdup(""); *infotxt = xstrdup(""); *numprompts = 1; - *prompts = xmalloc(*numprompts * sizeof(char*)); + *prompts = xmalloc(*numprompts * sizeof(char *)); *echo_on = xmalloc(*numprompts * sizeof(u_int)); (*echo_on)[0] = 0; } @@ -918,3 +917,74 @@ return (success); } + +#ifdef KRB4 +int +mm_auth_krb4(Authctxt *authctxt, void *_auth, char **client, void *_reply) +{ + KTEXT auth, reply; + Buffer m; + u_int rlen; + int success = 0; + char *p; + + debug3("%s entering", __func__); + auth = _auth; + reply = _reply; + + buffer_init(&m); + buffer_put_string(&m, auth->dat, auth->length); + + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB4, &m); + mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB4, &m); + + success = buffer_get_int(&m); + if (success) { + *client = buffer_get_string(&m, NULL); + p = buffer_get_string(&m, &rlen); + if (rlen >= MAX_KTXT_LEN) + fatal("%s: reply from monitor too large", __func__); + reply->length = rlen; + memcpy(reply->dat, p, rlen); + memset(p, 0, rlen); + xfree(p); + } + buffer_free(&m); + return (success); +} +#endif + +#ifdef KRB5 +int +mm_auth_krb5(void *ctx, void *argp, char **userp, void *resp) +{ + krb5_data *tkt, *reply; + Buffer m; + int success; + + debug3("%s entering", __func__); + tkt = (krb5_data *) argp; + reply = (krb5_data *) resp; + + buffer_init(&m); + buffer_put_string(&m, tkt->data, tkt->length); + + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB5, &m); + mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB5, &m); + + success = buffer_get_int(&m); + if (success) { + u_int len; + + *userp = buffer_get_string(&m, NULL); + reply->data = buffer_get_string(&m, &len); + reply->length = len; + } else { + memset(reply, 0, sizeof(*reply)); + *userp = NULL; + } + + buffer_free(&m); + return (success); +} +#endif