]> andersk Git - openssh.git/blobdiff - monitor.c
- markus@cvs.openbsd.org 2003/02/04 09:32:08
[openssh.git] / monitor.c
index 562efcaf801a626f3f105ad254e627ce2726b43a..b91cfdeda735e140670d34a0a11422d597806f86 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -25,7 +25,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: monitor.c,v 1.25 2002/09/09 06:48:06 itojun Exp $");
+RCSID("$OpenBSD: monitor.c,v 1.30 2002/11/05 19:45:20 markus Exp $");
 
 #include <openssl/dh.h>
 
@@ -120,6 +120,9 @@ int mm_answer_sessid(int, Buffer *);
 int mm_answer_pam_start(int, Buffer *);
 #endif
 
+#ifdef KRB4
+int mm_answer_krb4(int, Buffer *);
+#endif
 #ifdef KRB5
 int mm_answer_krb5(int, Buffer *);
 #endif
@@ -131,8 +134,8 @@ static BIGNUM *ssh1_challenge = NULL;       /* used for ssh1 rsa auth */
 static u_char *key_blob = NULL;
 static u_int key_bloblen = 0;
 static int key_blobtype = MM_NOKEY;
-static u_char *hostbased_cuser = NULL;
-static u_char *hostbased_chost = NULL;
+static char *hostbased_cuser = NULL;
+static char *hostbased_chost = NULL;
 static char *auth_method = "unknown";
 static int session_id2_len = 0;
 static u_char *session_id2 = NULL;
@@ -203,6 +206,9 @@ struct mon_table mon_dispatch_proto15[] = {
 #ifdef USE_PAM
     {MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start},
 #endif
+#ifdef KRB4
+    {MONITOR_REQ_KRB4, MON_ONCE|MON_AUTH, mm_answer_krb4},
+#endif
 #ifdef KRB5
     {MONITOR_REQ_KRB5, MON_ONCE|MON_AUTH, mm_answer_krb5},
 #endif
@@ -758,7 +764,8 @@ int
 mm_answer_keyallowed(int socket, Buffer *m)
 {
        Key *key;
-       u_char *cuser, *chost, *blob;
+       char *cuser, *chost;
+       u_char *blob;
        u_int bloblen;
        enum mm_keytype type = 0;
        int allowed = 0;
@@ -834,7 +841,7 @@ static int
 monitor_valid_userblob(u_char *data, u_int datalen)
 {
        Buffer b;
-       u_char *p;
+       char *p;
        u_int len;
        int fail = 0;
 
@@ -887,11 +894,11 @@ monitor_valid_userblob(u_char *data, u_int datalen)
 }
 
 static int
-monitor_valid_hostbasedblob(u_char *data, u_int datalen, u_char *cuser,
-    u_char *chost)
+monitor_valid_hostbasedblob(u_char *data, u_int datalen, char *cuser,
+    char *chost)
 {
        Buffer b;
-       u_char *p;
+       char *p;
        u_int len;
        int fail = 0;
 
@@ -1284,6 +1291,51 @@ mm_answer_rsa_response(int socket, Buffer *m)
        return (success);
 }
 
+#ifdef KRB4
+int
+mm_answer_krb4(int socket, Buffer *m)
+{
+       KTEXT_ST auth, reply;
+       char  *client, *p;
+       int success;
+       u_int alen;
+
+       reply.length = auth.length = 0;
+       p = buffer_get_string(m, &alen);
+       if (alen >=  MAX_KTXT_LEN)
+                fatal("%s: auth too large", __func__);
+       memcpy(auth.dat, p, alen);
+       auth.length = alen;
+       memset(p, 0, alen);
+       xfree(p);
+
+       success = options.kerberos_authentication &&
+           authctxt->valid &&
+           auth_krb4(authctxt, &auth, &client, &reply);
+
+       memset(auth.dat, 0, alen);
+       buffer_clear(m);
+       buffer_put_int(m, success);
+
+       if (success) {
+               buffer_put_cstring(m, client);
+               buffer_put_string(m, reply.dat, reply.length);
+               if (client)
+                       xfree(client);
+               if (reply.length)
+                       memset(reply.dat, 0, reply.length);
+       }
+
+       debug3("%s: sending result %d", __func__, success);
+       mm_request_send(socket, MONITOR_ANS_KRB4, m);
+
+       auth_method = "kerberos";
+
+       /* Causes monitor loop to terminate if authenticated */
+       return (success);
+}
+#endif
 
 #ifdef KRB5
 int
@@ -1298,7 +1350,9 @@ mm_answer_krb5(int socket, Buffer *m)
        tkt.data = buffer_get_string(m, &len);
        tkt.length = len;
 
-       success = auth_krb5(authctxt, &tkt, &client_user, &reply);
+       success = options.kerberos_authentication &&
+           authctxt->valid &&
+           auth_krb5(authctxt, &tkt, &client_user, &reply);
 
        if (tkt.length)
                xfree(tkt.data);
@@ -1497,7 +1551,7 @@ mm_get_keystate(struct monitor *pmonitor)
 void *
 mm_zalloc(struct mm_master *mm, u_int ncount, u_int size)
 {
-       size_t len = size * ncount;
+       size_t len = (size_t) size * ncount;
        void *address;
 
        if (len == 0 || ncount > SIZE_T_MAX / size)
This page took 0.114734 seconds and 4 git commands to generate.