]> andersk Git - openssh.git/blobdiff - monitor_wrap.c
- (bal) auth1.c minor resync while looking at the code.
[openssh.git] / monitor_wrap.c
index eb4453fc4404289af539ac2065e106218e9574dd..183ae8d0ef364d5539c332d698f9915c9ce8706d 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: monitor_wrap.c,v 1.14 2002/06/30 21:59:45 deraadt Exp $");
+RCSID("$OpenBSD: monitor_wrap.c,v 1.26 2003/04/07 08:29:57 markus Exp $");
 
 #include <openssl/bn.h>
 #include <openssl/dh.h>
@@ -34,6 +34,7 @@ RCSID("$OpenBSD: monitor_wrap.c,v 1.14 2002/06/30 21:59:45 deraadt Exp $");
 #include "dh.h"
 #include "kex.h"
 #include "auth.h"
+#include "auth-options.h"
 #include "buffer.h"
 #include "bufaux.h"
 #include "packet.h"
@@ -312,7 +313,7 @@ mm_key_allowed(enum mm_keytype type, char *user, char *host, Key *key)
        Buffer m;
        u_char *blob;
        u_int len;
-       int allowed = 0;
+       int allowed = 0, have_forced = 0;
 
        debug3("%s entering", __func__);
 
@@ -334,6 +335,11 @@ mm_key_allowed(enum mm_keytype type, char *user, char *host, Key *key)
 
        allowed = buffer_get_int(&m);
 
+       /* fake forced command */
+       auth_clear_options();
+       have_forced = buffer_get_int(&m);
+       forced_command = have_forced ? xstrdup("true") : NULL;
+
        /* Send potential debug messages */
        mm_send_debug(&m);
 
@@ -446,7 +452,6 @@ mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp)
 {
        Buffer b;
        int len;
-       u_char *buf;
        Enc *enc;
        Mac *mac;
        Comp *comp;
@@ -484,14 +489,14 @@ mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp)
        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;
 }
 
@@ -515,6 +520,8 @@ mm_send_keystate(struct monitor *pmonitor)
        Buffer m;
        u_char *blob, *p;
        u_int bloblen, plen;
+       u_int32_t seqnr, packets;
+       u_int64_t blocks;
 
        buffer_init(&m);
 
@@ -563,8 +570,14 @@ mm_send_keystate(struct monitor *pmonitor)
        buffer_put_string(&m, blob, bloblen);
        xfree(blob);
 
-       buffer_put_int(&m, packet_get_seqnr(MODE_OUT));
-       buffer_put_int(&m, packet_get_seqnr(MODE_IN));
+       packet_get_state(MODE_OUT, &seqnr, &blocks, &packets);
+       buffer_put_int(&m, seqnr);
+       buffer_put_int64(&m, blocks);
+       buffer_put_int(&m, packets);
+       packet_get_state(MODE_IN, &seqnr, &blocks, &packets);
+       buffer_put_int(&m, seqnr);
+       buffer_put_int64(&m, blocks);
+       buffer_put_int(&m, packets);
 
        debug3("%s: New keys have been sent", __func__);
  skip:
@@ -600,7 +613,7 @@ int
 mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
 {
        Buffer m;
-       u_char *p;
+       char *p;
        int success = 0;
 
        buffer_init(&m);
@@ -715,7 +728,7 @@ mm_bsdauth_query(void *ctx, char **name, char **infotxt,
    u_int *numprompts, char ***prompts, u_int **echo_on)
 {
        Buffer m;
-       int res;
+       u_int success;
        char *challenge;
 
        debug3("%s: entering", __func__);
@@ -725,8 +738,8 @@ mm_bsdauth_query(void *ctx, char **name, char **infotxt,
 
        mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_BSDAUTHQUERY,
            &m);
-       res = buffer_get_int(&m);
-       if (res == -1) {
+       success = buffer_get_int(&m);
+       if (success == 0) {
                debug3("%s: no challenge", __func__);
                buffer_free(&m);
                return (-1);
@@ -772,7 +785,8 @@ mm_skey_query(void *ctx, char **name, char **infotxt,
    u_int *numprompts, char ***prompts, u_int **echo_on)
 {
        Buffer m;
-       int len, res;
+       int len;
+       u_int success;
        char *p, *challenge;
 
        debug3("%s: entering", __func__);
@@ -782,8 +796,8 @@ mm_skey_query(void *ctx, char **name, char **infotxt,
 
        mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SKEYQUERY,
            &m);
-       res = buffer_get_int(&m);
-       if (res == -1) {
+       success = buffer_get_int(&m);
+       if (success == 0) {
                debug3("%s: no challenge", __func__);
                buffer_free(&m);
                return (-1);
@@ -853,7 +867,7 @@ mm_auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
        Key *key;
        u_char *blob;
        u_int blen;
-       int allowed = 0;
+       int allowed = 0, have_forced = 0;
 
        debug3("%s entering", __func__);
 
@@ -865,6 +879,11 @@ mm_auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
 
        allowed = buffer_get_int(&m);
 
+       /* fake forced command */
+       auth_clear_options();
+       have_forced = buffer_get_int(&m);
+       forced_command = have_forced ? xstrdup("true") : NULL;
+
        if (allowed && rkey != NULL) {
                blob = buffer_get_string(&m, &blen);
                if ((key = key_from_blob(blob, blen)) == NULL)
@@ -937,3 +956,74 @@ mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16])
 
        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
This page took 0.041553 seconds and 4 git commands to generate.