1 /* $OpenBSD: monitor_wrap.c,v 1.99 2018/03/03 03:15:51 djm Exp $ */ 2 /* 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include <sys/types.h> 29 #include <sys/uio.h> 30 #include <sys/queue.h> 31 32 #include <errno.h> 33 #include <pwd.h> 34 #include <signal.h> 35 #include <stdio.h> 36 #include <string.h> 37 #include <unistd.h> 38 39 #ifdef WITH_OPENSSL 40 #include <openssl/bn.h> 41 #include <openssl/dh.h> 42 #endif 43 44 #include "xmalloc.h" 45 #include "ssh.h" 46 #ifdef WITH_OPENSSL 47 #include "dh.h" 48 #endif 49 #include "buffer.h" 50 #include "key.h" 51 #include "cipher.h" 52 #include "kex.h" 53 #include "hostfile.h" 54 #include "auth.h" 55 #include "auth-options.h" 56 #include "packet.h" 57 #include "mac.h" 58 #include "log.h" 59 #include <zlib.h> 60 #include "monitor.h" 61 #ifdef GSSAPI 62 #include "ssh-gss.h" 63 #endif 64 #include "monitor_wrap.h" 65 #include "atomicio.h" 66 #include "monitor_fdpass.h" 67 #include "misc.h" 68 69 #include "channels.h" 70 #include "session.h" 71 #include "servconf.h" 72 73 #include "ssherr.h" 74 75 /* Imports */ 76 extern z_stream incoming_stream; 77 extern z_stream outgoing_stream; 78 extern struct monitor *pmonitor; 79 extern Buffer loginmsg; 80 extern ServerOptions options; 81 82 void 83 mm_log_handler(LogLevel level, const char *msg, void *ctx) 84 { 85 Buffer log_msg; 86 struct monitor *mon = (struct monitor *)ctx; 87 88 if (mon->m_log_sendfd == -1) 89 fatal("%s: no log channel", __func__); 90 91 buffer_init(&log_msg); 92 /* 93 * Placeholder for packet length. Will be filled in with the actual 94 * packet length once the packet has been constucted. This saves 95 * fragile math. 96 */ 97 buffer_put_int(&log_msg, 0); 98 99 buffer_put_int(&log_msg, level); 100 buffer_put_cstring(&log_msg, msg); 101 put_u32(buffer_ptr(&log_msg), buffer_len(&log_msg) - 4); 102 if (atomicio(vwrite, mon->m_log_sendfd, buffer_ptr(&log_msg), 103 buffer_len(&log_msg)) != buffer_len(&log_msg)) 104 fatal("%s: write: %s", __func__, strerror(errno)); 105 buffer_free(&log_msg); 106 } 107 108 int 109 mm_is_monitor(void) 110 { 111 /* 112 * m_pid is only set in the privileged part, and 113 * points to the unprivileged child. 114 */ 115 return (pmonitor && pmonitor->m_pid > 0); 116 } 117 118 void 119 mm_request_send(int sock, enum monitor_reqtype type, Buffer *m) 120 { 121 u_int mlen = buffer_len(m); 122 u_char buf[5]; 123 124 debug3("%s entering: type %d", __func__, type); 125 126 put_u32(buf, mlen + 1); 127 buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ 128 if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) 129 fatal("%s: write: %s", __func__, strerror(errno)); 130 if (atomicio(vwrite, sock, buffer_ptr(m), mlen) != mlen) 131 fatal("%s: write: %s", __func__, strerror(errno)); 132 } 133 134 void 135 mm_request_receive(int sock, Buffer *m) 136 { 137 u_char buf[4]; 138 u_int msg_len; 139 140 debug3("%s entering", __func__); 141 142 if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) { 143 if (errno == EPIPE) 144 cleanup_exit(255); 145 fatal("%s: read: %s", __func__, strerror(errno)); 146 } 147 msg_len = get_u32(buf); 148 if (msg_len > 256 * 1024) 149 fatal("%s: read: bad msg_len %d", __func__, msg_len); 150 buffer_clear(m); 151 buffer_append_space(m, msg_len); 152 if (atomicio(read, sock, buffer_ptr(m), msg_len) != msg_len) 153 fatal("%s: read: %s", __func__, strerror(errno)); 154 } 155 156 void 157 mm_request_receive_expect(int sock, enum monitor_reqtype type, Buffer *m) 158 { 159 u_char rtype; 160 161 debug3("%s entering: type %d", __func__, type); 162 163 mm_request_receive(sock, m); 164 rtype = buffer_get_char(m); 165 if (rtype != type) 166 fatal("%s: read: rtype %d != type %d", __func__, 167 rtype, type); 168 } 169 170 #ifdef WITH_OPENSSL 171 DH * 172 mm_choose_dh(int min, int nbits, int max) 173 { 174 BIGNUM *p, *g; 175 int success = 0; 176 Buffer m; 177 178 buffer_init(&m); 179 buffer_put_int(&m, min); 180 buffer_put_int(&m, nbits); 181 buffer_put_int(&m, max); 182 183 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_MODULI, &m); 184 185 debug3("%s: waiting for MONITOR_ANS_MODULI", __func__); 186 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_MODULI, &m); 187 188 success = buffer_get_char(&m); 189 if (success == 0) 190 fatal("%s: MONITOR_ANS_MODULI failed", __func__); 191 192 if ((p = BN_new()) == NULL) 193 fatal("%s: BN_new failed", __func__); 194 if ((g = BN_new()) == NULL) 195 fatal("%s: BN_new failed", __func__); 196 buffer_get_bignum2(&m, p); 197 buffer_get_bignum2(&m, g); 198 199 debug3("%s: remaining %d", __func__, buffer_len(&m)); 200 buffer_free(&m); 201 202 return (dh_new_group(g, p)); 203 } 204 #endif 205 206 int 207 mm_key_sign(struct sshkey *key, u_char **sigp, u_int *lenp, 208 const u_char *data, u_int datalen, const char *hostkey_alg) 209 { 210 struct kex *kex = *pmonitor->m_pkex; 211 Buffer m; 212 213 debug3("%s entering", __func__); 214 215 buffer_init(&m); 216 buffer_put_int(&m, kex->host_key_index(key, 0, active_state)); 217 buffer_put_string(&m, data, datalen); 218 buffer_put_cstring(&m, hostkey_alg); 219 220 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SIGN, &m); 221 222 debug3("%s: waiting for MONITOR_ANS_SIGN", __func__); 223 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SIGN, &m); 224 *sigp = buffer_get_string(&m, lenp); 225 buffer_free(&m); 226 227 return (0); 228 } 229 230 struct passwd * 231 mm_getpwnamallow(const char *username) 232 { 233 struct ssh *ssh = active_state; /* XXX */ 234 Buffer m; 235 struct passwd *pw; 236 u_int len, i; 237 ServerOptions *newopts; 238 239 debug3("%s entering", __func__); 240 241 buffer_init(&m); 242 buffer_put_cstring(&m, username); 243 244 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PWNAM, &m); 245 246 debug3("%s: waiting for MONITOR_ANS_PWNAM", __func__); 247 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PWNAM, &m); 248 249 if (buffer_get_char(&m) == 0) { 250 pw = NULL; 251 goto out; 252 } 253 pw = buffer_get_string(&m, &len); 254 if (len != sizeof(struct passwd)) 255 fatal("%s: struct passwd size mismatch", __func__); 256 pw->pw_name = buffer_get_string(&m, NULL); 257 pw->pw_passwd = buffer_get_string(&m, NULL); 258 pw->pw_gecos = buffer_get_string(&m, NULL); 259 pw->pw_class = buffer_get_string(&m, NULL); 260 pw->pw_dir = buffer_get_string(&m, NULL); 261 pw->pw_shell = buffer_get_string(&m, NULL); 262 263 out: 264 /* copy options block as a Match directive may have changed some */ 265 newopts = buffer_get_string(&m, &len); 266 if (len != sizeof(*newopts)) 267 fatal("%s: option block size mismatch", __func__); 268 269 #define M_CP_STROPT(x) do { \ 270 if (newopts->x != NULL) \ 271 newopts->x = buffer_get_string(&m, NULL); \ 272 } while (0) 273 #define M_CP_STRARRAYOPT(x, nx) do { \ 274 newopts->x = newopts->nx == 0 ? \ 275 NULL : xcalloc(newopts->nx, sizeof(*newopts->x)); \ 276 for (i = 0; i < newopts->nx; i++) \ 277 newopts->x[i] = buffer_get_string(&m, NULL); \ 278 } while (0) 279 /* See comment in servconf.h */ 280 COPY_MATCH_STRING_OPTS(); 281 #undef M_CP_STROPT 282 #undef M_CP_STRARRAYOPT 283 284 copy_set_server_options(&options, newopts, 1); 285 log_change_level(options.log_level); 286 process_permitopen(ssh, &options); 287 free(newopts); 288 289 buffer_free(&m); 290 291 return (pw); 292 } 293 294 char * 295 mm_auth2_read_banner(void) 296 { 297 Buffer m; 298 char *banner; 299 300 debug3("%s entering", __func__); 301 302 buffer_init(&m); 303 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTH2_READ_BANNER, &m); 304 buffer_clear(&m); 305 306 mm_request_receive_expect(pmonitor->m_recvfd, 307 MONITOR_ANS_AUTH2_READ_BANNER, &m); 308 banner = buffer_get_string(&m, NULL); 309 buffer_free(&m); 310 311 /* treat empty banner as missing banner */ 312 if (strlen(banner) == 0) { 313 free(banner); 314 banner = NULL; 315 } 316 return (banner); 317 } 318 319 /* Inform the privileged process about service and style */ 320 321 void 322 mm_inform_authserv(char *service, char *style) 323 { 324 Buffer m; 325 326 debug3("%s entering", __func__); 327 328 buffer_init(&m); 329 buffer_put_cstring(&m, service); 330 buffer_put_cstring(&m, style ? style : ""); 331 332 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, &m); 333 334 buffer_free(&m); 335 } 336 337 /* Do the password authentication */ 338 int 339 mm_auth_password(struct ssh *ssh, char *password) 340 { 341 Buffer m; 342 int authenticated = 0; 343 344 debug3("%s entering", __func__); 345 346 buffer_init(&m); 347 buffer_put_cstring(&m, password); 348 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHPASSWORD, &m); 349 350 debug3("%s: waiting for MONITOR_ANS_AUTHPASSWORD", __func__); 351 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUTHPASSWORD, &m); 352 353 authenticated = buffer_get_int(&m); 354 355 buffer_free(&m); 356 357 debug3("%s: user %sauthenticated", 358 __func__, authenticated ? "" : "not "); 359 return (authenticated); 360 } 361 362 int 363 mm_user_key_allowed(struct ssh *ssh, struct passwd *pw, struct sshkey *key, 364 int pubkey_auth_attempt, struct sshauthopt **authoptp) 365 { 366 return (mm_key_allowed(MM_USERKEY, NULL, NULL, key, 367 pubkey_auth_attempt, authoptp)); 368 } 369 370 int 371 mm_hostbased_key_allowed(struct passwd *pw, const char *user, const char *host, 372 struct sshkey *key) 373 { 374 return (mm_key_allowed(MM_HOSTKEY, user, host, key, 0, NULL)); 375 } 376 377 int 378 mm_key_allowed(enum mm_keytype type, const char *user, const char *host, 379 struct sshkey *key, int pubkey_auth_attempt, struct sshauthopt **authoptp) 380 { 381 Buffer m; 382 u_char *blob; 383 u_int len; 384 int r, allowed = 0; 385 struct sshauthopt *opts = NULL; 386 387 debug3("%s entering", __func__); 388 389 if (authoptp != NULL) 390 *authoptp = NULL; 391 392 /* Convert the key to a blob and the pass it over */ 393 if (!key_to_blob(key, &blob, &len)) 394 return 0; 395 396 buffer_init(&m); 397 buffer_put_int(&m, type); 398 buffer_put_cstring(&m, user ? user : ""); 399 buffer_put_cstring(&m, host ? host : ""); 400 buffer_put_string(&m, blob, len); 401 buffer_put_int(&m, pubkey_auth_attempt); 402 free(blob); 403 404 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYALLOWED, &m); 405 406 debug3("%s: waiting for MONITOR_ANS_KEYALLOWED", __func__); 407 mm_request_receive_expect(pmonitor->m_recvfd, 408 MONITOR_ANS_KEYALLOWED, &m); 409 410 allowed = buffer_get_int(&m); 411 if (allowed && type == MM_USERKEY) { 412 if ((r = sshauthopt_deserialise(&m, &opts)) != 0) 413 fatal("%s: sshauthopt_deserialise: %s", 414 __func__, ssh_err(r)); 415 } 416 buffer_free(&m); 417 418 if (authoptp != NULL) { 419 *authoptp = opts; 420 opts = NULL; 421 } 422 sshauthopt_free(opts); 423 424 return allowed; 425 } 426 427 /* 428 * This key verify needs to send the key type along, because the 429 * privileged parent makes the decision if the key is allowed 430 * for authentication. 431 */ 432 433 int 434 mm_sshkey_verify(const struct sshkey *key, const u_char *sig, size_t siglen, 435 const u_char *data, size_t datalen, const char *sigalg, u_int compat) 436 { 437 Buffer m; 438 u_char *blob; 439 u_int len; 440 u_int encoded_ret = 0; 441 442 debug3("%s entering", __func__); 443 444 /* Convert the key to a blob and the pass it over */ 445 if (!key_to_blob(key, &blob, &len)) 446 return (0); 447 448 buffer_init(&m); 449 buffer_put_string(&m, blob, len); 450 buffer_put_string(&m, sig, siglen); 451 buffer_put_string(&m, data, datalen); 452 buffer_put_cstring(&m, sigalg == NULL ? "" : sigalg); 453 free(blob); 454 455 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYVERIFY, &m); 456 457 debug3("%s: waiting for MONITOR_ANS_KEYVERIFY", __func__); 458 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KEYVERIFY, &m); 459 460 encoded_ret = buffer_get_int(&m); 461 462 buffer_free(&m); 463 464 if (encoded_ret != 0) 465 return SSH_ERR_SIGNATURE_INVALID; 466 return 0; 467 } 468 469 void 470 mm_send_keystate(struct monitor *monitor) 471 { 472 struct ssh *ssh = active_state; /* XXX */ 473 struct sshbuf *m; 474 int r; 475 476 if ((m = sshbuf_new()) == NULL) 477 fatal("%s: sshbuf_new failed", __func__); 478 if ((r = ssh_packet_get_state(ssh, m)) != 0) 479 fatal("%s: get_state failed: %s", 480 __func__, ssh_err(r)); 481 mm_request_send(monitor->m_recvfd, MONITOR_REQ_KEYEXPORT, m); 482 debug3("%s: Finished sending state", __func__); 483 sshbuf_free(m); 484 } 485 486 int 487 mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen) 488 { 489 Buffer m; 490 char *p, *msg; 491 int success = 0, tmp1 = -1, tmp2 = -1; 492 493 /* Kludge: ensure there are fds free to receive the pty/tty */ 494 if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 || 495 (tmp2 = dup(pmonitor->m_recvfd)) == -1) { 496 error("%s: cannot allocate fds for pty", __func__); 497 if (tmp1 > 0) 498 close(tmp1); 499 if (tmp2 > 0) 500 close(tmp2); 501 return 0; 502 } 503 close(tmp1); 504 close(tmp2); 505 506 buffer_init(&m); 507 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTY, &m); 508 509 debug3("%s: waiting for MONITOR_ANS_PTY", __func__); 510 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PTY, &m); 511 512 success = buffer_get_int(&m); 513 if (success == 0) { 514 debug3("%s: pty alloc failed", __func__); 515 buffer_free(&m); 516 return (0); 517 } 518 p = buffer_get_string(&m, NULL); 519 msg = buffer_get_string(&m, NULL); 520 buffer_free(&m); 521 522 strlcpy(namebuf, p, namebuflen); /* Possible truncation */ 523 free(p); 524 525 buffer_append(&loginmsg, msg, strlen(msg)); 526 free(msg); 527 528 if ((*ptyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1 || 529 (*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1) 530 fatal("%s: receive fds failed", __func__); 531 532 /* Success */ 533 return (1); 534 } 535 536 void 537 mm_session_pty_cleanup2(Session *s) 538 { 539 Buffer m; 540 541 if (s->ttyfd == -1) 542 return; 543 buffer_init(&m); 544 buffer_put_cstring(&m, s->tty); 545 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTYCLEANUP, &m); 546 buffer_free(&m); 547 548 /* closed dup'ed master */ 549 if (s->ptymaster != -1 && close(s->ptymaster) < 0) 550 error("close(s->ptymaster/%d): %s", 551 s->ptymaster, strerror(errno)); 552 553 /* unlink pty from session */ 554 s->ttyfd = -1; 555 } 556 557 /* Request process termination */ 558 559 void 560 mm_terminate(void) 561 { 562 Buffer m; 563 564 buffer_init(&m); 565 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_TERM, &m); 566 buffer_free(&m); 567 } 568 569 static void 570 mm_chall_setup(char **name, char **infotxt, u_int *numprompts, 571 char ***prompts, u_int **echo_on) 572 { 573 *name = xstrdup(""); 574 *infotxt = xstrdup(""); 575 *numprompts = 1; 576 *prompts = xcalloc(*numprompts, sizeof(char *)); 577 *echo_on = xcalloc(*numprompts, sizeof(u_int)); 578 (*echo_on)[0] = 0; 579 } 580 581 int 582 mm_bsdauth_query(void *ctx, char **name, char **infotxt, 583 u_int *numprompts, char ***prompts, u_int **echo_on) 584 { 585 Buffer m; 586 u_int success; 587 char *challenge; 588 589 debug3("%s: entering", __func__); 590 591 buffer_init(&m); 592 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHQUERY, &m); 593 594 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_BSDAUTHQUERY, 595 &m); 596 success = buffer_get_int(&m); 597 if (success == 0) { 598 debug3("%s: no challenge", __func__); 599 buffer_free(&m); 600 return (-1); 601 } 602 603 /* Get the challenge, and format the response */ 604 challenge = buffer_get_string(&m, NULL); 605 buffer_free(&m); 606 607 mm_chall_setup(name, infotxt, numprompts, prompts, echo_on); 608 (*prompts)[0] = challenge; 609 610 debug3("%s: received challenge: %s", __func__, challenge); 611 612 return (0); 613 } 614 615 int 616 mm_bsdauth_respond(void *ctx, u_int numresponses, char **responses) 617 { 618 Buffer m; 619 int authok; 620 621 debug3("%s: entering", __func__); 622 if (numresponses != 1) 623 return (-1); 624 625 buffer_init(&m); 626 buffer_put_cstring(&m, responses[0]); 627 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHRESPOND, &m); 628 629 mm_request_receive_expect(pmonitor->m_recvfd, 630 MONITOR_ANS_BSDAUTHRESPOND, &m); 631 632 authok = buffer_get_int(&m); 633 buffer_free(&m); 634 635 return ((authok == 0) ? -1 : 0); 636 } 637 638 #ifdef GSSAPI 639 OM_uint32 640 mm_ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID goid) 641 { 642 Buffer m; 643 OM_uint32 major; 644 645 /* Client doesn't get to see the context */ 646 *ctx = NULL; 647 648 buffer_init(&m); 649 buffer_put_string(&m, goid->elements, goid->length); 650 651 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSETUP, &m); 652 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSETUP, &m); 653 654 major = buffer_get_int(&m); 655 656 buffer_free(&m); 657 return (major); 658 } 659 660 OM_uint32 661 mm_ssh_gssapi_accept_ctx(Gssctxt *ctx, gss_buffer_desc *in, 662 gss_buffer_desc *out, OM_uint32 *flags) 663 { 664 Buffer m; 665 OM_uint32 major; 666 u_int len; 667 668 buffer_init(&m); 669 buffer_put_string(&m, in->value, in->length); 670 671 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSTEP, &m); 672 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSTEP, &m); 673 674 major = buffer_get_int(&m); 675 out->value = buffer_get_string(&m, &len); 676 out->length = len; 677 if (flags) 678 *flags = buffer_get_int(&m); 679 680 buffer_free(&m); 681 682 return (major); 683 } 684 685 OM_uint32 686 mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) 687 { 688 Buffer m; 689 OM_uint32 major; 690 691 buffer_init(&m); 692 buffer_put_string(&m, gssbuf->value, gssbuf->length); 693 buffer_put_string(&m, gssmic->value, gssmic->length); 694 695 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSCHECKMIC, &m); 696 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSCHECKMIC, 697 &m); 698 699 major = buffer_get_int(&m); 700 buffer_free(&m); 701 return(major); 702 } 703 704 int 705 mm_ssh_gssapi_userok(char *user) 706 { 707 Buffer m; 708 int authenticated = 0; 709 710 buffer_init(&m); 711 712 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUSEROK, &m); 713 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSUSEROK, 714 &m); 715 716 authenticated = buffer_get_int(&m); 717 718 buffer_free(&m); 719 debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not "); 720 return (authenticated); 721 } 722 #endif /* GSSAPI */ 723 724