1 /* $OpenBSD: monitor_wrap.c,v 1.88 2016/03/07 19:02:43 djm Exp $ */
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
30 #include <sys/types.h>
42 #include <openssl/bn.h>
43 #include <openssl/dh.h>
44 #include <openssl/evp.h>
47 #include "openbsd-compat/sys-queue.h"
59 #include "auth-options.h"
64 #ifdef TARGET_OS_MAC /* XXX Broken krb5 headers on Mac */
67 #define TARGET_OS_MAC 1
75 #include "monitor_wrap.h"
77 #include "monitor_fdpass.h"
89 extern z_stream incoming_stream;
90 extern z_stream outgoing_stream;
91 extern struct monitor *pmonitor;
92 extern Buffer loginmsg;
93 extern ServerOptions options;
96 mm_log_handler(LogLevel level, const char *msg, void *ctx)
99 struct monitor *mon = (struct monitor *)ctx;
101 if (mon->m_log_sendfd == -1)
102 fatal("%s: no log channel", __func__);
104 buffer_init(&log_msg);
106 * Placeholder for packet length. Will be filled in with the actual
107 * packet length once the packet has been constucted. This saves
110 buffer_put_int(&log_msg, 0);
112 buffer_put_int(&log_msg, level);
113 buffer_put_cstring(&log_msg, msg);
114 put_u32(buffer_ptr(&log_msg), buffer_len(&log_msg) - 4);
115 if (atomicio(vwrite, mon->m_log_sendfd, buffer_ptr(&log_msg),
116 buffer_len(&log_msg)) != buffer_len(&log_msg))
117 fatal("%s: write: %s", __func__, strerror(errno));
118 buffer_free(&log_msg);
125 * m_pid is only set in the privileged part, and
126 * points to the unprivileged child.
128 return (pmonitor && pmonitor->m_pid > 0);
132 mm_request_send(int sock, enum monitor_reqtype type, Buffer *m)
134 u_int mlen = buffer_len(m);
137 debug3("%s entering: type %d", __func__, type);
139 put_u32(buf, mlen + 1);
140 buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */
141 if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf))
142 fatal("%s: write: %s", __func__, strerror(errno));
143 if (atomicio(vwrite, sock, buffer_ptr(m), mlen) != mlen)
144 fatal("%s: write: %s", __func__, strerror(errno));
148 mm_request_receive(int sock, Buffer *m)
153 debug3("%s entering", __func__);
155 if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) {
158 fatal("%s: read: %s", __func__, strerror(errno));
160 msg_len = get_u32(buf);
161 if (msg_len > 256 * 1024)
162 fatal("%s: read: bad msg_len %d", __func__, msg_len);
164 buffer_append_space(m, msg_len);
165 if (atomicio(read, sock, buffer_ptr(m), msg_len) != msg_len)
166 fatal("%s: read: %s", __func__, strerror(errno));
170 mm_request_receive_expect(int sock, enum monitor_reqtype type, Buffer *m)
174 debug3("%s entering: type %d", __func__, type);
176 mm_request_receive(sock, m);
177 rtype = buffer_get_char(m);
179 fatal("%s: read: rtype %d != type %d", __func__,
185 mm_choose_dh(int min, int nbits, int max)
192 buffer_put_int(&m, min);
193 buffer_put_int(&m, nbits);
194 buffer_put_int(&m, max);
196 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_MODULI, &m);
198 debug3("%s: waiting for MONITOR_ANS_MODULI", __func__);
199 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_MODULI, &m);
201 success = buffer_get_char(&m);
203 fatal("%s: MONITOR_ANS_MODULI failed", __func__);
205 if ((p = BN_new()) == NULL)
206 fatal("%s: BN_new failed", __func__);
207 if ((g = BN_new()) == NULL)
208 fatal("%s: BN_new failed", __func__);
209 buffer_get_bignum2(&m, p);
210 buffer_get_bignum2(&m, g);
212 debug3("%s: remaining %d", __func__, buffer_len(&m));
215 return (dh_new_group(g, p));
220 mm_key_sign(Key *key, u_char **sigp, u_int *lenp,
221 const u_char *data, u_int datalen, const char *hostkey_alg)
223 struct kex *kex = *pmonitor->m_pkex;
226 debug3("%s entering", __func__);
229 buffer_put_int(&m, kex->host_key_index(key, 0, active_state));
230 buffer_put_string(&m, data, datalen);
231 buffer_put_cstring(&m, hostkey_alg);
233 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SIGN, &m);
235 debug3("%s: waiting for MONITOR_ANS_SIGN", __func__);
236 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SIGN, &m);
237 *sigp = buffer_get_string(&m, lenp);
244 mm_getpwnamallow(const char *username)
249 ServerOptions *newopts;
251 debug3("%s entering", __func__);
254 buffer_put_cstring(&m, username);
256 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PWNAM, &m);
258 debug3("%s: waiting for MONITOR_ANS_PWNAM", __func__);
259 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PWNAM, &m);
261 if (buffer_get_char(&m) == 0) {
265 pw = buffer_get_string(&m, &len);
266 if (len != sizeof(struct passwd))
267 fatal("%s: struct passwd size mismatch", __func__);
268 pw->pw_name = buffer_get_string(&m, NULL);
269 pw->pw_passwd = buffer_get_string(&m, NULL);
270 #ifdef HAVE_STRUCT_PASSWD_PW_GECOS
271 pw->pw_gecos = buffer_get_string(&m, NULL);
273 #ifdef HAVE_STRUCT_PASSWD_PW_CLASS
274 pw->pw_class = buffer_get_string(&m, NULL);
276 pw->pw_dir = buffer_get_string(&m, NULL);
277 pw->pw_shell = buffer_get_string(&m, NULL);
280 /* copy options block as a Match directive may have changed some */
281 newopts = buffer_get_string(&m, &len);
282 if (len != sizeof(*newopts))
283 fatal("%s: option block size mismatch", __func__);
285 #define M_CP_STROPT(x) do { \
286 if (newopts->x != NULL) \
287 newopts->x = buffer_get_string(&m, NULL); \
289 #define M_CP_STRARRAYOPT(x, nx) do { \
290 for (i = 0; i < newopts->nx; i++) \
291 newopts->x[i] = buffer_get_string(&m, NULL); \
293 /* See comment in servconf.h */
294 COPY_MATCH_STRING_OPTS();
296 #undef M_CP_STRARRAYOPT
298 copy_set_server_options(&options, newopts, 1);
307 mm_auth2_read_banner(void)
312 debug3("%s entering", __func__);
315 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTH2_READ_BANNER, &m);
318 mm_request_receive_expect(pmonitor->m_recvfd,
319 MONITOR_ANS_AUTH2_READ_BANNER, &m);
320 banner = buffer_get_string(&m, NULL);
323 /* treat empty banner as missing banner */
324 if (strlen(banner) == 0) {
331 /* Inform the privileged process about service and style */
334 mm_inform_authserv(char *service, char *style)
338 debug3("%s entering", __func__);
341 buffer_put_cstring(&m, service);
342 buffer_put_cstring(&m, style ? style : "");
344 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, &m);
349 /* Do the password authentication */
351 mm_auth_password(Authctxt *authctxt, char *password)
354 int authenticated = 0;
356 debug3("%s entering", __func__);
359 buffer_put_cstring(&m, password);
360 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHPASSWORD, &m);
362 debug3("%s: waiting for MONITOR_ANS_AUTHPASSWORD", __func__);
363 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUTHPASSWORD, &m);
365 authenticated = buffer_get_int(&m);
367 sshpam_set_maxtries_reached(buffer_get_int(&m));
372 debug3("%s: user %sauthenticated",
373 __func__, authenticated ? "" : "not ");
374 return (authenticated);
378 mm_user_key_allowed(struct passwd *pw, Key *key, int pubkey_auth_attempt)
380 return (mm_key_allowed(MM_USERKEY, NULL, NULL, key,
381 pubkey_auth_attempt));
385 mm_hostbased_key_allowed(struct passwd *pw, const char *user, const char *host,
388 return (mm_key_allowed(MM_HOSTKEY, user, host, key, 0));
392 mm_auth_rhosts_rsa_key_allowed(struct passwd *pw, const char *user,
393 const char *host, Key *key)
397 key->type = KEY_RSA; /* XXX hack for key_to_blob */
398 ret = mm_key_allowed(MM_RSAHOSTKEY, user, host, key, 0);
399 key->type = KEY_RSA1;
404 mm_key_allowed(enum mm_keytype type, const char *user, const char *host,
405 Key *key, int pubkey_auth_attempt)
410 int allowed = 0, have_forced = 0;
412 debug3("%s entering", __func__);
414 /* Convert the key to a blob and the pass it over */
415 if (!key_to_blob(key, &blob, &len))
419 buffer_put_int(&m, type);
420 buffer_put_cstring(&m, user ? user : "");
421 buffer_put_cstring(&m, host ? host : "");
422 buffer_put_string(&m, blob, len);
423 buffer_put_int(&m, pubkey_auth_attempt);
426 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYALLOWED, &m);
428 debug3("%s: waiting for MONITOR_ANS_KEYALLOWED", __func__);
429 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KEYALLOWED, &m);
431 allowed = buffer_get_int(&m);
433 /* fake forced command */
434 auth_clear_options();
435 have_forced = buffer_get_int(&m);
436 forced_command = have_forced ? xstrdup("true") : NULL;
444 * This key verify needs to send the key type along, because the
445 * privileged parent makes the decision if the key is allowed
446 * for authentication.
450 mm_key_verify(Key *key, u_char *sig, u_int siglen, u_char *data, u_int datalen)
457 debug3("%s entering", __func__);
459 /* Convert the key to a blob and the pass it over */
460 if (!key_to_blob(key, &blob, &len))
464 buffer_put_string(&m, blob, len);
465 buffer_put_string(&m, sig, siglen);
466 buffer_put_string(&m, data, datalen);
469 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYVERIFY, &m);
471 debug3("%s: waiting for MONITOR_ANS_KEYVERIFY", __func__);
472 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KEYVERIFY, &m);
474 verified = buffer_get_int(&m);
482 mm_send_keystate(struct monitor *monitor)
484 struct ssh *ssh = active_state; /* XXX */
488 if ((m = sshbuf_new()) == NULL)
489 fatal("%s: sshbuf_new failed", __func__);
490 if ((r = ssh_packet_get_state(ssh, m)) != 0)
491 fatal("%s: get_state failed: %s",
492 __func__, ssh_err(r));
493 mm_request_send(monitor->m_recvfd, MONITOR_REQ_KEYEXPORT, m);
494 debug3("%s: Finished sending state", __func__);
499 mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
503 int success = 0, tmp1 = -1, tmp2 = -1;
505 /* Kludge: ensure there are fds free to receive the pty/tty */
506 if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
507 (tmp2 = dup(pmonitor->m_recvfd)) == -1) {
508 error("%s: cannot allocate fds for pty", __func__);
519 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTY, &m);
521 debug3("%s: waiting for MONITOR_ANS_PTY", __func__);
522 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PTY, &m);
524 success = buffer_get_int(&m);
526 debug3("%s: pty alloc failed", __func__);
530 p = buffer_get_string(&m, NULL);
531 msg = buffer_get_string(&m, NULL);
534 strlcpy(namebuf, p, namebuflen); /* Possible truncation */
537 buffer_append(&loginmsg, msg, strlen(msg));
540 if ((*ptyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1 ||
541 (*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1)
542 fatal("%s: receive fds failed", __func__);
549 mm_session_pty_cleanup2(Session *s)
556 buffer_put_cstring(&m, s->tty);
557 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTYCLEANUP, &m);
560 /* closed dup'ed master */
561 if (s->ptymaster != -1 && close(s->ptymaster) < 0)
562 error("close(s->ptymaster/%d): %s",
563 s->ptymaster, strerror(errno));
565 /* unlink pty from session */
571 mm_start_pam(Authctxt *authctxt)
575 debug3("%s entering", __func__);
576 if (!options.use_pam)
577 fatal("UsePAM=no, but ended up in %s anyway", __func__);
580 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_START, &m);
586 mm_do_pam_account(void)
592 debug3("%s entering", __func__);
593 if (!options.use_pam)
594 fatal("UsePAM=no, but ended up in %s anyway", __func__);
597 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_ACCOUNT, &m);
599 mm_request_receive_expect(pmonitor->m_recvfd,
600 MONITOR_ANS_PAM_ACCOUNT, &m);
601 ret = buffer_get_int(&m);
602 msg = buffer_get_string(&m, NULL);
603 buffer_append(&loginmsg, msg, strlen(msg));
608 debug3("%s returning %d", __func__, ret);
614 mm_sshpam_init_ctx(Authctxt *authctxt)
619 debug3("%s", __func__);
621 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_INIT_CTX, &m);
622 debug3("%s: waiting for MONITOR_ANS_PAM_INIT_CTX", __func__);
623 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_INIT_CTX, &m);
624 success = buffer_get_int(&m);
626 debug3("%s: pam_init_ctx failed", __func__);
635 mm_sshpam_query(void *ctx, char **name, char **info,
636 u_int *num, char ***prompts, u_int **echo_on)
642 debug3("%s", __func__);
644 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_QUERY, &m);
645 debug3("%s: waiting for MONITOR_ANS_PAM_QUERY", __func__);
646 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_QUERY, &m);
647 ret = buffer_get_int(&m);
648 debug3("%s: pam_query returned %d", __func__, ret);
649 *name = buffer_get_string(&m, NULL);
650 *info = buffer_get_string(&m, NULL);
651 sshpam_set_maxtries_reached(buffer_get_int(&m));
652 *num = buffer_get_int(&m);
653 if (*num > PAM_MAX_NUM_MSG)
654 fatal("%s: recieved %u PAM messages, expected <= %u",
655 __func__, *num, PAM_MAX_NUM_MSG);
656 *prompts = xcalloc((*num + 1), sizeof(char *));
657 *echo_on = xcalloc((*num + 1), sizeof(u_int));
658 for (i = 0; i < *num; ++i) {
659 (*prompts)[i] = buffer_get_string(&m, NULL);
660 (*echo_on)[i] = buffer_get_int(&m);
667 mm_sshpam_respond(void *ctx, u_int num, char **resp)
673 debug3("%s", __func__);
675 buffer_put_int(&m, num);
676 for (i = 0; i < num; ++i)
677 buffer_put_cstring(&m, resp[i]);
678 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_RESPOND, &m);
679 debug3("%s: waiting for MONITOR_ANS_PAM_RESPOND", __func__);
680 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_RESPOND, &m);
681 ret = buffer_get_int(&m);
682 debug3("%s: pam_respond returned %d", __func__, ret);
688 mm_sshpam_free_ctx(void *ctxtp)
692 debug3("%s", __func__);
694 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_FREE_CTX, &m);
695 debug3("%s: waiting for MONITOR_ANS_PAM_FREE_CTX", __func__);
696 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_FREE_CTX, &m);
701 /* Request process termination */
709 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_TERM, &m);
715 mm_ssh1_session_key(BIGNUM *num)
721 buffer_put_bignum2(&m, num);
722 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SESSKEY, &m);
724 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SESSKEY, &m);
726 rsafail = buffer_get_int(&m);
727 buffer_get_bignum2(&m, num);
736 mm_chall_setup(char **name, char **infotxt, u_int *numprompts,
737 char ***prompts, u_int **echo_on)
740 *infotxt = xstrdup("");
742 *prompts = xcalloc(*numprompts, sizeof(char *));
743 *echo_on = xcalloc(*numprompts, sizeof(u_int));
748 mm_bsdauth_query(void *ctx, char **name, char **infotxt,
749 u_int *numprompts, char ***prompts, u_int **echo_on)
755 debug3("%s: entering", __func__);
758 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHQUERY, &m);
760 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_BSDAUTHQUERY,
762 success = buffer_get_int(&m);
764 debug3("%s: no challenge", __func__);
769 /* Get the challenge, and format the response */
770 challenge = buffer_get_string(&m, NULL);
773 mm_chall_setup(name, infotxt, numprompts, prompts, echo_on);
774 (*prompts)[0] = challenge;
776 debug3("%s: received challenge: %s", __func__, challenge);
782 mm_bsdauth_respond(void *ctx, u_int numresponses, char **responses)
787 debug3("%s: entering", __func__);
788 if (numresponses != 1)
792 buffer_put_cstring(&m, responses[0]);
793 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHRESPOND, &m);
795 mm_request_receive_expect(pmonitor->m_recvfd,
796 MONITOR_ANS_BSDAUTHRESPOND, &m);
798 authok = buffer_get_int(&m);
801 return ((authok == 0) ? -1 : 0);
806 mm_skey_query(void *ctx, char **name, char **infotxt,
807 u_int *numprompts, char ***prompts, u_int **echo_on)
813 debug3("%s: entering", __func__);
816 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SKEYQUERY, &m);
818 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SKEYQUERY,
820 success = buffer_get_int(&m);
822 debug3("%s: no challenge", __func__);
827 /* Get the challenge, and format the response */
828 challenge = buffer_get_string(&m, NULL);
831 debug3("%s: received challenge: %s", __func__, challenge);
833 mm_chall_setup(name, infotxt, numprompts, prompts, echo_on);
835 xasprintf(*prompts, "%s%s", challenge, SKEY_PROMPT);
842 mm_skey_respond(void *ctx, u_int numresponses, char **responses)
847 debug3("%s: entering", __func__);
848 if (numresponses != 1)
852 buffer_put_cstring(&m, responses[0]);
853 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SKEYRESPOND, &m);
855 mm_request_receive_expect(pmonitor->m_recvfd,
856 MONITOR_ANS_SKEYRESPOND, &m);
858 authok = buffer_get_int(&m);
861 return ((authok == 0) ? -1 : 0);
866 mm_ssh1_session_id(u_char session_id[16])
871 debug3("%s entering", __func__);
874 for (i = 0; i < 16; i++)
875 buffer_put_char(&m, session_id[i]);
877 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SESSID, &m);
883 mm_auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
889 int allowed = 0, have_forced = 0;
891 debug3("%s entering", __func__);
894 buffer_put_bignum2(&m, client_n);
896 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSAKEYALLOWED, &m);
897 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSAKEYALLOWED, &m);
899 allowed = buffer_get_int(&m);
901 /* fake forced command */
902 auth_clear_options();
903 have_forced = buffer_get_int(&m);
904 forced_command = have_forced ? xstrdup("true") : NULL;
906 if (allowed && rkey != NULL) {
907 blob = buffer_get_string(&m, &blen);
908 if ((key = key_from_blob(blob, blen)) == NULL)
909 fatal("%s: key_from_blob failed", __func__);
919 mm_auth_rsa_generate_challenge(Key *key)
926 debug3("%s entering", __func__);
928 if ((challenge = BN_new()) == NULL)
929 fatal("%s: BN_new failed", __func__);
931 key->type = KEY_RSA; /* XXX cheat for key_to_blob */
932 if (key_to_blob(key, &blob, &blen) == 0)
933 fatal("%s: key_to_blob failed", __func__);
934 key->type = KEY_RSA1;
937 buffer_put_string(&m, blob, blen);
940 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSACHALLENGE, &m);
941 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSACHALLENGE, &m);
943 buffer_get_bignum2(&m, challenge);
950 mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16])
957 debug3("%s entering", __func__);
959 key->type = KEY_RSA; /* XXX cheat for key_to_blob */
960 if (key_to_blob(key, &blob, &blen) == 0)
961 fatal("%s: key_to_blob failed", __func__);
962 key->type = KEY_RSA1;
965 buffer_put_string(&m, blob, blen);
966 buffer_put_string(&m, response, 16);
969 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSARESPONSE, &m);
970 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSARESPONSE, &m);
972 success = buffer_get_int(&m);
979 #ifdef SSH_AUDIT_EVENTS
981 mm_audit_event(ssh_audit_event_t event)
985 debug3("%s entering", __func__);
988 buffer_put_int(&m, event);
990 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_EVENT, &m);
995 mm_audit_run_command(const char *command)
999 debug3("%s entering command %s", __func__, command);
1002 buffer_put_cstring(&m, command);
1004 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_COMMAND, &m);
1007 #endif /* SSH_AUDIT_EVENTS */
1011 mm_ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID goid)
1016 /* Client doesn't get to see the context */
1020 buffer_put_string(&m, goid->elements, goid->length);
1022 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSETUP, &m);
1023 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSETUP, &m);
1025 major = buffer_get_int(&m);
1032 mm_ssh_gssapi_accept_ctx(Gssctxt *ctx, gss_buffer_desc *in,
1033 gss_buffer_desc *out, OM_uint32 *flags)
1040 buffer_put_string(&m, in->value, in->length);
1042 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSTEP, &m);
1043 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSTEP, &m);
1045 major = buffer_get_int(&m);
1046 out->value = buffer_get_string(&m, &len);
1049 *flags = buffer_get_int(&m);
1057 mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
1063 buffer_put_string(&m, gssbuf->value, gssbuf->length);
1064 buffer_put_string(&m, gssmic->value, gssmic->length);
1066 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSCHECKMIC, &m);
1067 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSCHECKMIC,
1070 major = buffer_get_int(&m);
1076 mm_ssh_gssapi_userok(char *user)
1079 int authenticated = 0;
1083 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUSEROK, &m);
1084 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSUSEROK,
1087 authenticated = buffer_get_int(&m);
1090 debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
1091 return (authenticated);