[BACK]Return to monitor.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/monitor.c between version 1.49 and 1.49.2.2

version 1.49, 2003/08/28 12:54:34 version 1.49.2.2, 2004/08/19 22:37:31
Line 57 
Line 57 
 #include "bufaux.h"  #include "bufaux.h"
 #include "compat.h"  #include "compat.h"
 #include "ssh2.h"  #include "ssh2.h"
 #include "mpaux.h"  
   
 #ifdef GSSAPI  #ifdef GSSAPI
 #include "ssh-gss.h"  #include "ssh-gss.h"
Line 74 
Line 73 
 extern Buffer input, output;  extern Buffer input, output;
 extern Buffer auth_debug;  extern Buffer auth_debug;
 extern int auth_debug_init;  extern int auth_debug_init;
   extern Buffer loginmsg;
   
 /* State exported from the child */  /* State exported from the child */
   
Line 125 
Line 125 
 int mm_answer_gss_setup_ctx(int, Buffer *);  int mm_answer_gss_setup_ctx(int, Buffer *);
 int mm_answer_gss_accept_ctx(int, Buffer *);  int mm_answer_gss_accept_ctx(int, Buffer *);
 int mm_answer_gss_userok(int, Buffer *);  int mm_answer_gss_userok(int, Buffer *);
   int mm_answer_gss_checkmic(int, Buffer *);
 #endif  #endif
   
 static Authctxt *authctxt;  static Authctxt *authctxt;
Line 176 
Line 177 
     {MONITOR_REQ_GSSSETUP, MON_ISAUTH, mm_answer_gss_setup_ctx},      {MONITOR_REQ_GSSSETUP, MON_ISAUTH, mm_answer_gss_setup_ctx},
     {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},      {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},
     {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},      {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
       {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
 #endif  #endif
     {0, 0, NULL}      {0, 0, NULL}
 };  };
Line 247 
Line 249 
         }          }
 }  }
   
 Authctxt *  void
 monitor_child_preauth(struct monitor *pmonitor)  monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
 {  {
         struct mon_table *ent;          struct mon_table *ent;
         int authenticated = 0;          int authenticated = 0;
   
         debug3("preauth child monitor started");          debug3("preauth child monitor started");
   
           authctxt = _authctxt;
           memset(authctxt, 0, sizeof(*authctxt));
   
         if (compat20) {          if (compat20) {
                 mon_dispatch = mon_dispatch_proto20;                  mon_dispatch = mon_dispatch_proto20;
   
Line 267 
Line 272 
                 monitor_permit(mon_dispatch, MONITOR_REQ_SESSKEY, 1);                  monitor_permit(mon_dispatch, MONITOR_REQ_SESSKEY, 1);
         }          }
   
         authctxt = authctxt_new();  
   
         /* The first few requests do not require asynchronous access */          /* The first few requests do not require asynchronous access */
         while (!authenticated) {          while (!authenticated) {
                 authenticated = monitor_read(pmonitor, mon_dispatch, &ent);                  authenticated = monitor_read(pmonitor, mon_dispatch, &ent);
Line 296 
Line 299 
             __func__, authctxt->user);              __func__, authctxt->user);
   
         mm_get_keystate(pmonitor);          mm_get_keystate(pmonitor);
   
         return (authctxt);  
 }  }
   
 static void  static void
Line 307 
Line 308 
 }  }
   
 static void  static void
 monitor_child_handler(int signal)  monitor_child_handler(int sig)
 {  {
         kill(monitor_child_pid, signal);          kill(monitor_child_pid, sig);
 }  }
   
 void  void
Line 424 
Line 425 
 }  }
   
 int  int
 mm_answer_moduli(int socket, Buffer *m)  mm_answer_moduli(int sock, Buffer *m)
 {  {
         DH *dh;          DH *dh;
         int min, want, max;          int min, want, max;
Line 454 
Line 455 
   
                 DH_free(dh);                  DH_free(dh);
         }          }
         mm_request_send(socket, MONITOR_ANS_MODULI, m);          mm_request_send(sock, MONITOR_ANS_MODULI, m);
         return (0);          return (0);
 }  }
   
 int  int
 mm_answer_sign(int socket, Buffer *m)  mm_answer_sign(int sock, Buffer *m)
 {  {
         Key *key;          Key *key;
         u_char *p;          u_char *p;
Line 495 
Line 496 
         xfree(p);          xfree(p);
         xfree(signature);          xfree(signature);
   
         mm_request_send(socket, MONITOR_ANS_SIGN, m);          mm_request_send(sock, MONITOR_ANS_SIGN, m);
   
         /* Turn on permissions for getpwnam */          /* Turn on permissions for getpwnam */
         monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);          monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
Line 506 
Line 507 
 /* Retrieves the password entry and also checks if the user is permitted */  /* Retrieves the password entry and also checks if the user is permitted */
   
 int  int
 mm_answer_pwnamallow(int socket, Buffer *m)  mm_answer_pwnamallow(int sock, Buffer *m)
 {  {
         char *login;          char *username;
         struct passwd *pwent;          struct passwd *pwent;
         int allowed = 0;          int allowed = 0;
   
Line 517 
Line 518 
         if (authctxt->attempt++ != 0)          if (authctxt->attempt++ != 0)
                 fatal("%s: multiple attempts for getpwnam", __func__);                  fatal("%s: multiple attempts for getpwnam", __func__);
   
         login = buffer_get_string(m, NULL);          username = buffer_get_string(m, NULL);
   
         pwent = getpwnamallow(login);          pwent = getpwnamallow(username);
   
         authctxt->user = xstrdup(login);          authctxt->user = xstrdup(username);
         setproctitle("%s [priv]", pwent ? login : "unknown");          setproctitle("%s [priv]", pwent ? username : "unknown");
         xfree(login);          xfree(username);
   
         buffer_clear(m);          buffer_clear(m);
   
         if (pwent == NULL) {          if (pwent == NULL) {
                 buffer_put_char(m, 0);                  buffer_put_char(m, 0);
                   authctxt->pw = fakepw();
                 goto out;                  goto out;
         }          }
   
Line 547 
Line 549 
   
  out:   out:
         debug3("%s: sending MONITOR_ANS_PWNAM: %d", __func__, allowed);          debug3("%s: sending MONITOR_ANS_PWNAM: %d", __func__, allowed);
         mm_request_send(socket, MONITOR_ANS_PWNAM, m);          mm_request_send(sock, MONITOR_ANS_PWNAM, m);
   
         /* For SSHv1 allow authentication now */          /* For SSHv1 allow authentication now */
         if (!compat20)          if (!compat20)
Line 562 
Line 564 
         return (0);          return (0);
 }  }
   
 int mm_answer_auth2_read_banner(int socket, Buffer *m)  int mm_answer_auth2_read_banner(int sock, Buffer *m)
 {  {
         char *banner;          char *banner;
   
         buffer_clear(m);          buffer_clear(m);
         banner = auth2_read_banner();          banner = auth2_read_banner();
         buffer_put_cstring(m, banner != NULL ? banner : "");          buffer_put_cstring(m, banner != NULL ? banner : "");
         mm_request_send(socket, MONITOR_ANS_AUTH2_READ_BANNER, m);          mm_request_send(sock, MONITOR_ANS_AUTH2_READ_BANNER, m);
   
         if (banner != NULL)          if (banner != NULL)
                 xfree(banner);                  xfree(banner);
Line 578 
Line 580 
 }  }
   
 int  int
 mm_answer_authserv(int socket, Buffer *m)  mm_answer_authserv(int sock, Buffer *m)
 {  {
         monitor_permit_authentications(1);          monitor_permit_authentications(1);
   
Line 596 
Line 598 
 }  }
   
 int  int
 mm_answer_authpassword(int socket, Buffer *m)  mm_answer_authpassword(int sock, Buffer *m)
 {  {
         static int call_count;          static int call_count;
         char *passwd;          char *passwd;
Line 614 
Line 616 
         buffer_put_int(m, authenticated);          buffer_put_int(m, authenticated);
   
         debug3("%s: sending result %d", __func__, authenticated);          debug3("%s: sending result %d", __func__, authenticated);
         mm_request_send(socket, MONITOR_ANS_AUTHPASSWORD, m);          mm_request_send(sock, MONITOR_ANS_AUTHPASSWORD, m);
   
         call_count++;          call_count++;
         if (plen == 0 && call_count == 1)          if (plen == 0 && call_count == 1)
Line 628 
Line 630 
   
 #ifdef BSD_AUTH  #ifdef BSD_AUTH
 int  int
 mm_answer_bsdauthquery(int socket, Buffer *m)  mm_answer_bsdauthquery(int sock, Buffer *m)
 {  {
         char *name, *infotxt;          char *name, *infotxt;
         u_int numprompts;          u_int numprompts;
Line 645 
Line 647 
                 buffer_put_cstring(m, prompts[0]);                  buffer_put_cstring(m, prompts[0]);
   
         debug3("%s: sending challenge success: %u", __func__, success);          debug3("%s: sending challenge success: %u", __func__, success);
         mm_request_send(socket, MONITOR_ANS_BSDAUTHQUERY, m);          mm_request_send(sock, MONITOR_ANS_BSDAUTHQUERY, m);
   
         if (success) {          if (success) {
                 xfree(name);                  xfree(name);
Line 658 
Line 660 
 }  }
   
 int  int
 mm_answer_bsdauthrespond(int socket, Buffer *m)  mm_answer_bsdauthrespond(int sock, Buffer *m)
 {  {
         char *response;          char *response;
         int authok;          int authok;
Line 677 
Line 679 
         buffer_put_int(m, authok);          buffer_put_int(m, authok);
   
         debug3("%s: sending authenticated: %d", __func__, authok);          debug3("%s: sending authenticated: %d", __func__, authok);
         mm_request_send(socket, MONITOR_ANS_BSDAUTHRESPOND, m);          mm_request_send(sock, MONITOR_ANS_BSDAUTHRESPOND, m);
   
         auth_method = "bsdauth";          auth_method = "bsdauth";
   
Line 687 
Line 689 
   
 #ifdef SKEY  #ifdef SKEY
 int  int
 mm_answer_skeyquery(int socket, Buffer *m)  mm_answer_skeyquery(int sock, Buffer *m)
 {  {
         struct skey skey;          struct skey skey;
         char challenge[1024];          char challenge[1024];
Line 701 
Line 703 
                 buffer_put_cstring(m, challenge);                  buffer_put_cstring(m, challenge);
   
         debug3("%s: sending challenge success: %u", __func__, success);          debug3("%s: sending challenge success: %u", __func__, success);
         mm_request_send(socket, MONITOR_ANS_SKEYQUERY, m);          mm_request_send(sock, MONITOR_ANS_SKEYQUERY, m);
   
         return (0);          return (0);
 }  }
   
 int  int
 mm_answer_skeyrespond(int socket, Buffer *m)  mm_answer_skeyrespond(int sock, Buffer *m)
 {  {
         char *response;          char *response;
         int authok;          int authok;
Line 725 
Line 727 
         buffer_put_int(m, authok);          buffer_put_int(m, authok);
   
         debug3("%s: sending authenticated: %d", __func__, authok);          debug3("%s: sending authenticated: %d", __func__, authok);
         mm_request_send(socket, MONITOR_ANS_SKEYRESPOND, m);          mm_request_send(sock, MONITOR_ANS_SKEYRESPOND, m);
   
         auth_method = "skey";          auth_method = "skey";
   
Line 745 
Line 747 
 }  }
   
 int  int
 mm_answer_keyallowed(int socket, Buffer *m)  mm_answer_keyallowed(int sock, Buffer *m)
 {  {
         Key *key;          Key *key;
         char *cuser, *chost;          char *cuser, *chost;
Line 769 
Line 771 
   
         debug3("%s: key_from_blob: %p", __func__, key);          debug3("%s: key_from_blob: %p", __func__, key);
   
         if (key != NULL && authctxt->pw != NULL) {          if (key != NULL && authctxt->valid) {
                 switch(type) {                  switch(type) {
                 case MM_USERKEY:                  case MM_USERKEY:
                         allowed = options.pubkey_authentication &&                          allowed = options.pubkey_authentication &&
Line 815 
Line 817 
   
         mm_append_debug(m);          mm_append_debug(m);
   
         mm_request_send(socket, MONITOR_ANS_KEYALLOWED, m);          mm_request_send(sock, MONITOR_ANS_KEYALLOWED, m);
   
         if (type == MM_RSAHOSTKEY)          if (type == MM_RSAHOSTKEY)
                 monitor_permit(mon_dispatch, MONITOR_REQ_RSACHALLENGE, allowed);                  monitor_permit(mon_dispatch, MONITOR_REQ_RSACHALLENGE, allowed);
Line 936 
Line 938 
 }  }
   
 int  int
 mm_answer_keyverify(int socket, Buffer *m)  mm_answer_keyverify(int sock, Buffer *m)
 {  {
         Key *key;          Key *key;
         u_char *signature, *data, *blob;          u_char *signature, *data, *blob;
Line 986 
Line 988 
   
         buffer_clear(m);          buffer_clear(m);
         buffer_put_int(m, verified);          buffer_put_int(m, verified);
         mm_request_send(socket, MONITOR_ANS_KEYVERIFY, m);          mm_request_send(sock, MONITOR_ANS_KEYVERIFY, m);
   
         return (verified);          return (verified);
 }  }
Line 1007 
Line 1009 
                 if (getpeername(packet_get_connection_in(),                  if (getpeername(packet_get_connection_in(),
                         (struct sockaddr *) & from, &fromlen) < 0) {                          (struct sockaddr *) & from, &fromlen) < 0) {
                         debug("getpeername: %.100s", strerror(errno));                          debug("getpeername: %.100s", strerror(errno));
                         fatal_cleanup();                          cleanup_exit(255);
                 }                  }
         }          }
         /* Record that there was a login on that tty from the remote host. */          /* Record that there was a login on that tty from the remote host. */
Line 1022 
Line 1024 
         debug3("%s: session %d pid %ld", __func__, s->self, (long)s->pid);          debug3("%s: session %d pid %ld", __func__, s->self, (long)s->pid);
         if (s->ttyfd != -1) {          if (s->ttyfd != -1) {
                 debug3("%s: tty %s ptyfd %d",  __func__, s->tty, s->ptyfd);                  debug3("%s: tty %s ptyfd %d",  __func__, s->tty, s->ptyfd);
                 fatal_remove_cleanup(session_pty_cleanup2, (void *)s);  
                 session_pty_cleanup2(s);                  session_pty_cleanup2(s);
         }          }
         s->used = 0;          s->used = 0;
 }  }
   
 int  int
 mm_answer_pty(int socket, Buffer *m)  mm_answer_pty(int sock, Buffer *m)
 {  {
         extern struct monitor *pmonitor;          extern struct monitor *pmonitor;
         Session *s;          Session *s;
Line 1047 
Line 1048 
         res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));          res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
         if (res == 0)          if (res == 0)
                 goto error;                  goto error;
         fatal_add_cleanup(session_pty_cleanup2, (void *)s);  
         pty_setowner(authctxt->pw, s->tty);          pty_setowner(authctxt->pw, s->tty);
   
         buffer_put_int(m, 1);          buffer_put_int(m, 1);
         buffer_put_cstring(m, s->tty);          buffer_put_cstring(m, s->tty);
         mm_request_send(socket, MONITOR_ANS_PTY, m);  
   
         mm_send_fd(socket, s->ptyfd);  
         mm_send_fd(socket, s->ttyfd);  
   
         /* We need to trick ttyslot */          /* We need to trick ttyslot */
         if (dup2(s->ttyfd, 0) == -1)          if (dup2(s->ttyfd, 0) == -1)
                 fatal("%s: dup2", __func__);                  fatal("%s: dup2", __func__);
Line 1066 
Line 1062 
         /* Now we can close the file descriptor again */          /* Now we can close the file descriptor again */
         close(0);          close(0);
   
           /* send messages generated by record_login */
           buffer_put_string(m, buffer_ptr(&loginmsg), buffer_len(&loginmsg));
           buffer_clear(&loginmsg);
   
           mm_request_send(sock, MONITOR_ANS_PTY, m);
   
           mm_send_fd(sock, s->ptyfd);
           mm_send_fd(sock, s->ttyfd);
   
         /* make sure nothing uses fd 0 */          /* make sure nothing uses fd 0 */
         if ((fd0 = open(_PATH_DEVNULL, O_RDONLY)) < 0)          if ((fd0 = open(_PATH_DEVNULL, O_RDONLY)) < 0)
                 fatal("%s: open(/dev/null): %s", __func__, strerror(errno));                  fatal("%s: open(/dev/null): %s", __func__, strerror(errno));
Line 1086 
Line 1091 
         if (s != NULL)          if (s != NULL)
                 mm_session_close(s);                  mm_session_close(s);
         buffer_put_int(m, 0);          buffer_put_int(m, 0);
         mm_request_send(socket, MONITOR_ANS_PTY, m);          mm_request_send(sock, MONITOR_ANS_PTY, m);
         return (0);          return (0);
 }  }
   
 int  int
 mm_answer_pty_cleanup(int socket, Buffer *m)  mm_answer_pty_cleanup(int sock, Buffer *m)
 {  {
         Session *s;          Session *s;
         char *tty;          char *tty;
Line 1107 
Line 1112 
 }  }
   
 int  int
 mm_answer_sesskey(int socket, Buffer *m)  mm_answer_sesskey(int sock, Buffer *m)
 {  {
         BIGNUM *p;          BIGNUM *p;
         int rsafail;          int rsafail;
Line 1128 
Line 1133 
   
         BN_clear_free(p);          BN_clear_free(p);
   
         mm_request_send(socket, MONITOR_ANS_SESSKEY, m);          mm_request_send(sock, MONITOR_ANS_SESSKEY, m);
   
         /* Turn on permissions for sessid passing */          /* Turn on permissions for sessid passing */
         monitor_permit(mon_dispatch, MONITOR_REQ_SESSID, 1);          monitor_permit(mon_dispatch, MONITOR_REQ_SESSID, 1);
Line 1137 
Line 1142 
 }  }
   
 int  int
 mm_answer_sessid(int socket, Buffer *m)  mm_answer_sessid(int sock, Buffer *m)
 {  {
         int i;          int i;
   
Line 1155 
Line 1160 
 }  }
   
 int  int
 mm_answer_rsa_keyallowed(int socket, Buffer *m)  mm_answer_rsa_keyallowed(int sock, Buffer *m)
 {  {
         BIGNUM *client_n;          BIGNUM *client_n;
         Key *key = NULL;          Key *key = NULL;
Line 1195 
Line 1200 
   
         mm_append_debug(m);          mm_append_debug(m);
   
         mm_request_send(socket, MONITOR_ANS_RSAKEYALLOWED, m);          mm_request_send(sock, MONITOR_ANS_RSAKEYALLOWED, m);
   
         monitor_permit(mon_dispatch, MONITOR_REQ_RSACHALLENGE, allowed);          monitor_permit(mon_dispatch, MONITOR_REQ_RSACHALLENGE, allowed);
         monitor_permit(mon_dispatch, MONITOR_REQ_RSARESPONSE, 0);          monitor_permit(mon_dispatch, MONITOR_REQ_RSARESPONSE, 0);
Line 1203 
Line 1208 
 }  }
   
 int  int
 mm_answer_rsa_challenge(int socket, Buffer *m)  mm_answer_rsa_challenge(int sock, Buffer *m)
 {  {
         Key *key = NULL;          Key *key = NULL;
         u_char *blob;          u_char *blob;
Line 1229 
Line 1234 
         buffer_put_bignum2(m, ssh1_challenge);          buffer_put_bignum2(m, ssh1_challenge);
   
         debug3("%s sending reply", __func__);          debug3("%s sending reply", __func__);
         mm_request_send(socket, MONITOR_ANS_RSACHALLENGE, m);          mm_request_send(sock, MONITOR_ANS_RSACHALLENGE, m);
   
         monitor_permit(mon_dispatch, MONITOR_REQ_RSARESPONSE, 1);          monitor_permit(mon_dispatch, MONITOR_REQ_RSARESPONSE, 1);
   
Line 1239 
Line 1244 
 }  }
   
 int  int
 mm_answer_rsa_response(int socket, Buffer *m)  mm_answer_rsa_response(int sock, Buffer *m)
 {  {
         Key *key = NULL;          Key *key = NULL;
         u_char *blob, *response;          u_char *blob, *response;
Line 1278 
Line 1283 
   
         buffer_clear(m);          buffer_clear(m);
         buffer_put_int(m, success);          buffer_put_int(m, success);
         mm_request_send(socket, MONITOR_ANS_RSARESPONSE, m);          mm_request_send(sock, MONITOR_ANS_RSARESPONSE, m);
   
         return (success);          return (success);
 }  }
   
 int  int
 mm_answer_term(int socket, Buffer *req)  mm_answer_term(int sock, Buffer *req)
 {  {
         extern struct monitor *pmonitor;          extern struct monitor *pmonitor;
         int res, status;          int res, status;
Line 1301 
Line 1306 
         res = WIFEXITED(status) ? WEXITSTATUS(status) : 1;          res = WIFEXITED(status) ? WEXITSTATUS(status) : 1;
   
         /* Terminate process */          /* Terminate process */
         exit (res);          exit(res);
 }  }
   
 void  void
Line 1368 
Line 1373 
                 fatal("mm_get_get: internal error: bad session id");                  fatal("mm_get_get: internal error: bad session id");
         kex->we_need = buffer_get_int(m);          kex->we_need = buffer_get_int(m);
         kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;          kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
           kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
         kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;          kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
         kex->server = 1;          kex->server = 1;
         kex->hostkey_type = buffer_get_int(m);          kex->hostkey_type = buffer_get_int(m);
Line 1525 
Line 1531 
   
         mon = xmalloc(sizeof(*mon));          mon = xmalloc(sizeof(*mon));
   
           mon->m_pid = 0;
         monitor_socketpair(pair);          monitor_socketpair(pair);
   
         mon->m_recvfd = pair[0];          mon->m_recvfd = pair[0];
Line 1555 
Line 1562 
   
 #ifdef GSSAPI  #ifdef GSSAPI
 int  int
 mm_answer_gss_setup_ctx(int socket, Buffer *m)  mm_answer_gss_setup_ctx(int sock, Buffer *m)
 {  {
         gss_OID_desc oid;          gss_OID_desc goid;
         OM_uint32 major;          OM_uint32 major;
         u_int len;          u_int len;
   
         oid.elements = buffer_get_string(m, &len);          goid.elements = buffer_get_string(m, &len);
         oid.length = len;          goid.length = len;
   
         major = ssh_gssapi_server_ctx(&gsscontext, &oid);          major = ssh_gssapi_server_ctx(&gsscontext, &goid);
   
         xfree(oid.elements);          xfree(goid.elements);
   
         buffer_clear(m);          buffer_clear(m);
         buffer_put_int(m, major);          buffer_put_int(m, major);
   
         mm_request_send(socket,MONITOR_ANS_GSSSETUP, m);          mm_request_send(sock,MONITOR_ANS_GSSSETUP, m);
   
         /* Now we have a context, enable the step */          /* Now we have a context, enable the step */
         monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 1);          monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 1);
Line 1580 
Line 1587 
 }  }
   
 int  int
 mm_answer_gss_accept_ctx(int socket, Buffer *m)  mm_answer_gss_accept_ctx(int sock, Buffer *m)
 {  {
         gss_buffer_desc in;          gss_buffer_desc in;
         gss_buffer_desc out = GSS_C_EMPTY_BUFFER;          gss_buffer_desc out = GSS_C_EMPTY_BUFFER;
Line 1597 
Line 1604 
         buffer_put_int(m, major);          buffer_put_int(m, major);
         buffer_put_string(m, out.value, out.length);          buffer_put_string(m, out.value, out.length);
         buffer_put_int(m, flags);          buffer_put_int(m, flags);
         mm_request_send(socket, MONITOR_ANS_GSSSTEP, m);          mm_request_send(sock, MONITOR_ANS_GSSSTEP, m);
   
         gss_release_buffer(&minor, &out);          gss_release_buffer(&minor, &out);
   
         /* Complete - now we can do signing */  
         if (major==GSS_S_COMPLETE) {          if (major==GSS_S_COMPLETE) {
                 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);                  monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
                 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);                  monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
                   monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
         }          }
         return (0);          return (0);
 }  }
   
 int  int
 mm_answer_gss_userok(int socket, Buffer *m)  mm_answer_gss_checkmic(int sock, Buffer *m)
 {  {
           gss_buffer_desc gssbuf, mic;
           OM_uint32 ret;
           u_int len;
   
           gssbuf.value = buffer_get_string(m, &len);
           gssbuf.length = len;
           mic.value = buffer_get_string(m, &len);
           mic.length = len;
   
           ret = ssh_gssapi_checkmic(gsscontext, &gssbuf, &mic);
   
           xfree(gssbuf.value);
           xfree(mic.value);
   
           buffer_clear(m);
           buffer_put_int(m, ret);
   
           mm_request_send(sock, MONITOR_ANS_GSSCHECKMIC, m);
   
           if (!GSS_ERROR(ret))
                   monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
   
           return (0);
   }
   
   int
   mm_answer_gss_userok(int sock, Buffer *m)
   {
         int authenticated;          int authenticated;
   
         authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);          authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);
Line 1620 
Line 1655 
         buffer_put_int(m, authenticated);          buffer_put_int(m, authenticated);
   
         debug3("%s: sending result %d", __func__, authenticated);          debug3("%s: sending result %d", __func__, authenticated);
         mm_request_send(socket, MONITOR_ANS_GSSUSEROK, m);          mm_request_send(sock, MONITOR_ANS_GSSUSEROK, m);
   
         auth_method="gssapi";          auth_method="gssapi-with-mic";
   
         /* Monitor loop will terminate if authenticated */          /* Monitor loop will terminate if authenticated */
         return (authenticated);          return (authenticated);

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.49.2.2