1 /* $OpenBSD: monitor_wrap.c,v 1.94 2017/10/02 19:33:20 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"
88 extern z_stream incoming_stream
;
89 extern z_stream outgoing_stream
;
90 extern struct monitor
*pmonitor
;
91 extern Buffer loginmsg
;
92 extern ServerOptions options
;
95 mm_log_handler(LogLevel level
, const char *msg
, void *ctx
)
98 struct monitor
*mon
= (struct monitor
*)ctx
;
100 if (mon
->m_log_sendfd
== -1)
101 fatal("%s: no log channel", __func__
);
103 buffer_init(&log_msg
);
105 * Placeholder for packet length. Will be filled in with the actual
106 * packet length once the packet has been constucted. This saves
109 buffer_put_int(&log_msg
, 0);
111 buffer_put_int(&log_msg
, level
);
112 buffer_put_cstring(&log_msg
, msg
);
113 put_u32(buffer_ptr(&log_msg
), buffer_len(&log_msg
) - 4);
114 if (atomicio(vwrite
, mon
->m_log_sendfd
, buffer_ptr(&log_msg
),
115 buffer_len(&log_msg
)) != buffer_len(&log_msg
))
116 fatal("%s: write: %s", __func__
, strerror(errno
));
117 buffer_free(&log_msg
);
124 * m_pid is only set in the privileged part, and
125 * points to the unprivileged child.
127 return (pmonitor
&& pmonitor
->m_pid
> 0);
131 mm_request_send(int sock
, enum monitor_reqtype type
, Buffer
*m
)
133 u_int mlen
= buffer_len(m
);
136 debug3("%s entering: type %d", __func__
, type
);
138 put_u32(buf
, mlen
+ 1);
139 buf
[4] = (u_char
) type
; /* 1st byte of payload is mesg-type */
140 if (atomicio(vwrite
, sock
, buf
, sizeof(buf
)) != sizeof(buf
))
141 fatal("%s: write: %s", __func__
, strerror(errno
));
142 if (atomicio(vwrite
, sock
, buffer_ptr(m
), mlen
) != mlen
)
143 fatal("%s: write: %s", __func__
, strerror(errno
));
147 mm_request_receive(int sock
, Buffer
*m
)
152 debug3("%s entering", __func__
);
154 if (atomicio(read
, sock
, buf
, sizeof(buf
)) != sizeof(buf
)) {
157 fatal("%s: read: %s", __func__
, strerror(errno
));
159 msg_len
= get_u32(buf
);
160 if (msg_len
> 256 * 1024)
161 fatal("%s: read: bad msg_len %d", __func__
, msg_len
);
163 buffer_append_space(m
, msg_len
);
164 if (atomicio(read
, sock
, buffer_ptr(m
), msg_len
) != msg_len
)
165 fatal("%s: read: %s", __func__
, strerror(errno
));
169 mm_request_receive_expect(int sock
, enum monitor_reqtype type
, Buffer
*m
)
173 debug3("%s entering: type %d", __func__
, type
);
175 mm_request_receive(sock
, m
);
176 rtype
= buffer_get_char(m
);
178 fatal("%s: read: rtype %d != type %d", __func__
,
184 mm_choose_dh(int min
, int nbits
, int max
)
191 buffer_put_int(&m
, min
);
192 buffer_put_int(&m
, nbits
);
193 buffer_put_int(&m
, max
);
195 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_MODULI
, &m
);
197 debug3("%s: waiting for MONITOR_ANS_MODULI", __func__
);
198 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_MODULI
, &m
);
200 success
= buffer_get_char(&m
);
202 fatal("%s: MONITOR_ANS_MODULI failed", __func__
);
204 if ((p
= BN_new()) == NULL
)
205 fatal("%s: BN_new failed", __func__
);
206 if ((g
= BN_new()) == NULL
)
207 fatal("%s: BN_new failed", __func__
);
208 buffer_get_bignum2(&m
, p
);
209 buffer_get_bignum2(&m
, g
);
211 debug3("%s: remaining %d", __func__
, buffer_len(&m
));
214 return (dh_new_group(g
, p
));
219 mm_key_sign(struct sshkey
*key
, u_char
**sigp
, u_int
*lenp
,
220 const u_char
*data
, u_int datalen
, const char *hostkey_alg
)
222 struct kex
*kex
= *pmonitor
->m_pkex
;
225 debug3("%s entering", __func__
);
228 buffer_put_int(&m
, kex
->host_key_index(key
, 0, active_state
));
229 buffer_put_string(&m
, data
, datalen
);
230 buffer_put_cstring(&m
, hostkey_alg
);
232 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_SIGN
, &m
);
234 debug3("%s: waiting for MONITOR_ANS_SIGN", __func__
);
235 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_SIGN
, &m
);
236 *sigp
= buffer_get_string(&m
, lenp
);
243 mm_getpwnamallow(const char *username
)
245 struct ssh
*ssh
= active_state
; /* XXX */
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 #define M_CP_STRARRAYOPT_ALLOC(x, nx) do { \
294 newopts->x = newopts->nx == 0 ? \
295 NULL : xcalloc(newopts->nx, sizeof(*newopts->x)); \
296 M_CP_STRARRAYOPT(x, nx); \
298 /* See comment in servconf.h */
299 COPY_MATCH_STRING_OPTS();
301 #undef M_CP_STRARRAYOPT
302 #undef M_CP_STRARRAYOPT_ALLOC
304 copy_set_server_options(&options
, newopts
, 1);
305 log_change_level(options
.log_level
);
306 process_permitopen(ssh
, &options
);
315 mm_auth2_read_banner(void)
320 debug3("%s entering", __func__
);
323 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_AUTH2_READ_BANNER
, &m
);
326 mm_request_receive_expect(pmonitor
->m_recvfd
,
327 MONITOR_ANS_AUTH2_READ_BANNER
, &m
);
328 banner
= buffer_get_string(&m
, NULL
);
331 /* treat empty banner as missing banner */
332 if (strlen(banner
) == 0) {
339 /* Inform the privileged process about service and style */
342 mm_inform_authserv(char *service
, char *style
)
346 debug3("%s entering", __func__
);
349 buffer_put_cstring(&m
, service
);
350 buffer_put_cstring(&m
, style
? style
: "");
352 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_AUTHSERV
, &m
);
357 /* Do the password authentication */
359 mm_auth_password(Authctxt
*authctxt
, char *password
)
362 int authenticated
= 0;
364 debug3("%s entering", __func__
);
367 buffer_put_cstring(&m
, password
);
368 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_AUTHPASSWORD
, &m
);
370 debug3("%s: waiting for MONITOR_ANS_AUTHPASSWORD", __func__
);
371 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_AUTHPASSWORD
, &m
);
373 authenticated
= buffer_get_int(&m
);
375 sshpam_set_maxtries_reached(buffer_get_int(&m
));
380 debug3("%s: user %sauthenticated",
381 __func__
, authenticated
? "" : "not ");
382 return (authenticated
);
386 mm_user_key_allowed(struct passwd
*pw
, struct sshkey
*key
,
387 int pubkey_auth_attempt
)
389 return (mm_key_allowed(MM_USERKEY
, NULL
, NULL
, key
,
390 pubkey_auth_attempt
));
394 mm_hostbased_key_allowed(struct passwd
*pw
, const char *user
, const char *host
,
397 return (mm_key_allowed(MM_HOSTKEY
, user
, host
, key
, 0));
401 mm_key_allowed(enum mm_keytype type
, const char *user
, const char *host
,
402 struct sshkey
*key
, int pubkey_auth_attempt
)
407 int allowed
= 0, have_forced
= 0;
409 debug3("%s entering", __func__
);
411 /* Convert the key to a blob and the pass it over */
412 if (!key_to_blob(key
, &blob
, &len
))
416 buffer_put_int(&m
, type
);
417 buffer_put_cstring(&m
, user
? user
: "");
418 buffer_put_cstring(&m
, host
? host
: "");
419 buffer_put_string(&m
, blob
, len
);
420 buffer_put_int(&m
, pubkey_auth_attempt
);
423 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_KEYALLOWED
, &m
);
425 debug3("%s: waiting for MONITOR_ANS_KEYALLOWED", __func__
);
426 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_KEYALLOWED
, &m
);
428 allowed
= buffer_get_int(&m
);
430 /* fake forced command */
431 auth_clear_options();
432 have_forced
= buffer_get_int(&m
);
433 forced_command
= have_forced
? xstrdup("true") : NULL
;
441 * This key verify needs to send the key type along, because the
442 * privileged parent makes the decision if the key is allowed
443 * for authentication.
447 mm_sshkey_verify(const struct sshkey
*key
, const u_char
*sig
, size_t siglen
,
448 const u_char
*data
, size_t datalen
, u_int compat
)
453 u_int encoded_ret
= 0;
455 debug3("%s entering", __func__
);
457 /* Convert the key to a blob and the pass it over */
458 if (!key_to_blob(key
, &blob
, &len
))
462 buffer_put_string(&m
, blob
, len
);
463 buffer_put_string(&m
, sig
, siglen
);
464 buffer_put_string(&m
, data
, datalen
);
467 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_KEYVERIFY
, &m
);
469 debug3("%s: waiting for MONITOR_ANS_KEYVERIFY", __func__
);
470 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_KEYVERIFY
, &m
);
472 encoded_ret
= buffer_get_int(&m
);
476 if (encoded_ret
!= 0)
477 return SSH_ERR_SIGNATURE_INVALID
;
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
);
714 mm_chall_setup(char **name
, char **infotxt
, u_int
*numprompts
,
715 char ***prompts
, u_int
**echo_on
)
718 *infotxt
= xstrdup("");
720 *prompts
= xcalloc(*numprompts
, sizeof(char *));
721 *echo_on
= xcalloc(*numprompts
, sizeof(u_int
));
726 mm_bsdauth_query(void *ctx
, char **name
, char **infotxt
,
727 u_int
*numprompts
, char ***prompts
, u_int
**echo_on
)
733 debug3("%s: entering", __func__
);
736 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_BSDAUTHQUERY
, &m
);
738 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_BSDAUTHQUERY
,
740 success
= buffer_get_int(&m
);
742 debug3("%s: no challenge", __func__
);
747 /* Get the challenge, and format the response */
748 challenge
= buffer_get_string(&m
, NULL
);
751 mm_chall_setup(name
, infotxt
, numprompts
, prompts
, echo_on
);
752 (*prompts
)[0] = challenge
;
754 debug3("%s: received challenge: %s", __func__
, challenge
);
760 mm_bsdauth_respond(void *ctx
, u_int numresponses
, char **responses
)
765 debug3("%s: entering", __func__
);
766 if (numresponses
!= 1)
770 buffer_put_cstring(&m
, responses
[0]);
771 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_BSDAUTHRESPOND
, &m
);
773 mm_request_receive_expect(pmonitor
->m_recvfd
,
774 MONITOR_ANS_BSDAUTHRESPOND
, &m
);
776 authok
= buffer_get_int(&m
);
779 return ((authok
== 0) ? -1 : 0);
784 mm_skey_query(void *ctx
, char **name
, char **infotxt
,
785 u_int
*numprompts
, char ***prompts
, u_int
**echo_on
)
791 debug3("%s: entering", __func__
);
794 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_SKEYQUERY
, &m
);
796 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_SKEYQUERY
,
798 success
= buffer_get_int(&m
);
800 debug3("%s: no challenge", __func__
);
805 /* Get the challenge, and format the response */
806 challenge
= buffer_get_string(&m
, NULL
);
809 debug3("%s: received challenge: %s", __func__
, challenge
);
811 mm_chall_setup(name
, infotxt
, numprompts
, prompts
, echo_on
);
813 xasprintf(*prompts
, "%s%s", challenge
, SKEY_PROMPT
);
820 mm_skey_respond(void *ctx
, u_int numresponses
, char **responses
)
825 debug3("%s: entering", __func__
);
826 if (numresponses
!= 1)
830 buffer_put_cstring(&m
, responses
[0]);
831 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_SKEYRESPOND
, &m
);
833 mm_request_receive_expect(pmonitor
->m_recvfd
,
834 MONITOR_ANS_SKEYRESPOND
, &m
);
836 authok
= buffer_get_int(&m
);
839 return ((authok
== 0) ? -1 : 0);
843 #ifdef SSH_AUDIT_EVENTS
845 mm_audit_event(ssh_audit_event_t event
)
849 debug3("%s entering", __func__
);
852 buffer_put_int(&m
, event
);
854 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_AUDIT_EVENT
, &m
);
859 mm_audit_run_command(const char *command
)
863 debug3("%s entering command %s", __func__
, command
);
866 buffer_put_cstring(&m
, command
);
868 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_AUDIT_COMMAND
, &m
);
871 #endif /* SSH_AUDIT_EVENTS */
875 mm_ssh_gssapi_server_ctx(Gssctxt
**ctx
, gss_OID goid
)
880 /* Client doesn't get to see the context */
884 buffer_put_string(&m
, goid
->elements
, goid
->length
);
886 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_GSSSETUP
, &m
);
887 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_GSSSETUP
, &m
);
889 major
= buffer_get_int(&m
);
896 mm_ssh_gssapi_accept_ctx(Gssctxt
*ctx
, gss_buffer_desc
*in
,
897 gss_buffer_desc
*out
, OM_uint32
*flags
)
904 buffer_put_string(&m
, in
->value
, in
->length
);
906 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_GSSSTEP
, &m
);
907 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_GSSSTEP
, &m
);
909 major
= buffer_get_int(&m
);
910 out
->value
= buffer_get_string(&m
, &len
);
913 *flags
= buffer_get_int(&m
);
921 mm_ssh_gssapi_checkmic(Gssctxt
*ctx
, gss_buffer_t gssbuf
, gss_buffer_t gssmic
)
927 buffer_put_string(&m
, gssbuf
->value
, gssbuf
->length
);
928 buffer_put_string(&m
, gssmic
->value
, gssmic
->length
);
930 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_GSSCHECKMIC
, &m
);
931 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_GSSCHECKMIC
,
934 major
= buffer_get_int(&m
);
940 mm_ssh_gssapi_userok(char *user
)
943 int authenticated
= 0;
947 mm_request_send(pmonitor
->m_recvfd
, MONITOR_REQ_GSSUSEROK
, &m
);
948 mm_request_receive_expect(pmonitor
->m_recvfd
, MONITOR_ANS_GSSUSEROK
,
951 authenticated
= buffer_get_int(&m
);
954 debug3("%s: user %sauthenticated",__func__
, authenticated
? "" : "not ");
955 return (authenticated
);