1*1c7715ddSchristos /* $NetBSD: monitor.h,v 1.14 2024/07/08 22:33:43 christos Exp $ */ 2*1c7715ddSchristos /* $OpenBSD: monitor.h,v 1.24 2024/05/17 00:30:24 djm Exp $ */ 3ca32bd8dSchristos 4ca32bd8dSchristos /* 5ca32bd8dSchristos * Copyright 2002 Niels Provos <provos@citi.umich.edu> 6ca32bd8dSchristos * All rights reserved. 7ca32bd8dSchristos * 8ca32bd8dSchristos * Redistribution and use in source and binary forms, with or without 9ca32bd8dSchristos * modification, are permitted provided that the following conditions 10ca32bd8dSchristos * are met: 11ca32bd8dSchristos * 1. Redistributions of source code must retain the above copyright 12ca32bd8dSchristos * notice, this list of conditions and the following disclaimer. 13ca32bd8dSchristos * 2. Redistributions in binary form must reproduce the above copyright 14ca32bd8dSchristos * notice, this list of conditions and the following disclaimer in the 15ca32bd8dSchristos * documentation and/or other materials provided with the distribution. 16ca32bd8dSchristos * 17ca32bd8dSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18ca32bd8dSchristos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19ca32bd8dSchristos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20ca32bd8dSchristos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21ca32bd8dSchristos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22ca32bd8dSchristos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23ca32bd8dSchristos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24ca32bd8dSchristos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25ca32bd8dSchristos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26ca32bd8dSchristos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27ca32bd8dSchristos */ 28ca32bd8dSchristos 29ca32bd8dSchristos #ifndef _MONITOR_H_ 30ca32bd8dSchristos #define _MONITOR_H_ 31ca32bd8dSchristos 32ce11a51fSchristos /* Please keep *_REQ_* values on even numbers and *_ANS_* on odd numbers */ 33ca32bd8dSchristos enum monitor_reqtype { 34ce11a51fSchristos MONITOR_REQ_MODULI = 0, MONITOR_ANS_MODULI = 1, 35ce11a51fSchristos MONITOR_REQ_FREE = 2, 36ce11a51fSchristos MONITOR_REQ_AUTHSERV = 4, 37ce11a51fSchristos MONITOR_REQ_SIGN = 6, MONITOR_ANS_SIGN = 7, 38ce11a51fSchristos MONITOR_REQ_PWNAM = 8, MONITOR_ANS_PWNAM = 9, 39ce11a51fSchristos MONITOR_REQ_AUTH2_READ_BANNER = 10, MONITOR_ANS_AUTH2_READ_BANNER = 11, 40ce11a51fSchristos MONITOR_REQ_AUTHPASSWORD = 12, MONITOR_ANS_AUTHPASSWORD = 13, 41ce11a51fSchristos MONITOR_REQ_BSDAUTHQUERY = 14, MONITOR_ANS_BSDAUTHQUERY = 15, 42ce11a51fSchristos MONITOR_REQ_BSDAUTHRESPOND = 16, MONITOR_ANS_BSDAUTHRESPOND = 17, 43ce11a51fSchristos MONITOR_REQ_SKEYQUERY = 18, MONITOR_ANS_SKEYQUERY = 19, 44ce11a51fSchristos MONITOR_REQ_SKEYRESPOND = 20, MONITOR_ANS_SKEYRESPOND = 21, 45ce11a51fSchristos MONITOR_REQ_KEYALLOWED = 22, MONITOR_ANS_KEYALLOWED = 23, 46ce11a51fSchristos MONITOR_REQ_KEYVERIFY = 24, MONITOR_ANS_KEYVERIFY = 25, 47ce11a51fSchristos MONITOR_REQ_KEYEXPORT = 26, 48ce11a51fSchristos MONITOR_REQ_PTY = 28, MONITOR_ANS_PTY = 29, 49ce11a51fSchristos MONITOR_REQ_PTYCLEANUP = 30, 50ce11a51fSchristos MONITOR_REQ_SESSKEY = 32, MONITOR_ANS_SESSKEY = 33, 51ce11a51fSchristos MONITOR_REQ_SESSID = 34, 52ce11a51fSchristos MONITOR_REQ_RSAKEYALLOWED = 36, MONITOR_ANS_RSAKEYALLOWED = 37, 53ce11a51fSchristos MONITOR_REQ_RSACHALLENGE = 38, MONITOR_ANS_RSACHALLENGE = 39, 54ce11a51fSchristos MONITOR_REQ_RSARESPONSE = 40, MONITOR_ANS_RSARESPONSE = 41, 55ce11a51fSchristos MONITOR_REQ_GSSSETUP = 42, MONITOR_ANS_GSSSETUP = 43, 56ce11a51fSchristos MONITOR_REQ_GSSSTEP = 44, MONITOR_ANS_GSSSTEP = 45, 57ce11a51fSchristos MONITOR_REQ_GSSUSEROK = 46, MONITOR_ANS_GSSUSEROK = 47, 58ce11a51fSchristos MONITOR_REQ_GSSCHECKMIC = 48, MONITOR_ANS_GSSCHECKMIC = 49, 59ce11a51fSchristos MONITOR_REQ_TERM = 50, 60ce11a51fSchristos MONITOR_REQ_JPAKE_STEP1 = 52, MONITOR_ANS_JPAKE_STEP1 = 53, 61ce11a51fSchristos MONITOR_REQ_JPAKE_GET_PWDATA = 54, MONITOR_ANS_JPAKE_GET_PWDATA = 55, 62ce11a51fSchristos MONITOR_REQ_JPAKE_STEP2 = 56, MONITOR_ANS_JPAKE_STEP2 = 57, 63ce11a51fSchristos MONITOR_REQ_JPAKE_KEY_CONFIRM = 58, MONITOR_ANS_JPAKE_KEY_CONFIRM = 59, 64ce11a51fSchristos MONITOR_REQ_JPAKE_CHECK_CONFIRM = 60, MONITOR_ANS_JPAKE_CHECK_CONFIRM = 61, 65ce11a51fSchristos 66ce11a51fSchristos MONITOR_REQ_PAM_START = 100, 67ce11a51fSchristos MONITOR_REQ_PAM_ACCOUNT = 102, MONITOR_ANS_PAM_ACCOUNT = 103, 68ce11a51fSchristos MONITOR_REQ_PAM_INIT_CTX = 104, MONITOR_ANS_PAM_INIT_CTX = 105, 69ce11a51fSchristos MONITOR_REQ_PAM_QUERY = 106, MONITOR_ANS_PAM_QUERY = 107, 70ce11a51fSchristos MONITOR_REQ_PAM_RESPOND = 108, MONITOR_ANS_PAM_RESPOND = 109, 71ce11a51fSchristos MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111, 72ce11a51fSchristos MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113, 73ce11a51fSchristos 74ce11a51fSchristos MONITOR_REQ_KRB4 = 200, MONITOR_ANS_KRB4 = 201, 75ce11a51fSchristos MONITOR_REQ_KRB5 = 202, MONITOR_ANS_KRB5 = 203, 76ce11a51fSchristos 77ca32bd8dSchristos }; 78ca32bd8dSchristos 79aa36fcacSchristos struct ssh; 80*1c7715ddSchristos struct sshbuf; 81aa36fcacSchristos 82ca32bd8dSchristos struct monitor { 83ca32bd8dSchristos int m_recvfd; 84ca32bd8dSchristos int m_sendfd; 856f47b660Schristos int m_log_recvfd; 866f47b660Schristos int m_log_sendfd; 87e4d43b82Schristos struct kex **m_pkex; 88ca32bd8dSchristos pid_t m_pid; 89ca32bd8dSchristos }; 90ca32bd8dSchristos 91ca32bd8dSchristos struct monitor *monitor_init(void); 92ca32bd8dSchristos void monitor_reinit(struct monitor *); 93ca32bd8dSchristos 94ca32bd8dSchristos struct Authctxt; 95aa36fcacSchristos void monitor_child_preauth(struct ssh *, struct monitor *); 965d52ec40Schristos void monitor_child_postauth(struct ssh *, struct monitor *) 975d52ec40Schristos __attribute__((__noreturn__)); 98ca32bd8dSchristos 99aa36fcacSchristos void monitor_clear_keystate(struct ssh *, struct monitor *); 100aa36fcacSchristos void monitor_apply_keystate(struct ssh *, struct monitor *); 101ca32bd8dSchristos 102ca32bd8dSchristos /* Prototypes for request sending and receiving */ 10355a4608bSchristos void mm_request_send(int, enum monitor_reqtype, struct sshbuf *); 10455a4608bSchristos void mm_request_receive(int, struct sshbuf *); 10555a4608bSchristos void mm_request_receive_expect(int, enum monitor_reqtype, struct sshbuf *); 106aa36fcacSchristos void mm_get_keystate(struct ssh *, struct monitor *); 107ca32bd8dSchristos 108*1c7715ddSchristos /* XXX: should be returned via a monitor call rather than config_fd */ 109*1c7715ddSchristos void mm_encode_server_options(struct sshbuf *); 110*1c7715ddSchristos 111ca32bd8dSchristos #endif /* _MONITOR_H_ */ 112