1*1c7715ddSchristos /* $NetBSD: monitor_wrap.h,v 1.24 2024/07/08 22:33:43 christos Exp $ */ 2*1c7715ddSchristos /* $OpenBSD: monitor_wrap.h,v 1.51 2024/05/17 06:42:04 jsg 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 _MM_WRAP_H_ 30ca32bd8dSchristos #define _MM_WRAP_H_ 31ca32bd8dSchristos 32ee85abc4Schristos enum mm_keytype { MM_NOKEY, MM_HOSTKEY, MM_USERKEY }; 33ca32bd8dSchristos 34aa36fcacSchristos struct ssh; 35ca32bd8dSchristos struct monitor; 36ca32bd8dSchristos struct Authctxt; 37ffae97bbSchristos struct sshkey; 38ffae97bbSchristos struct sshauthopt; 39ed75d7a8Schristos struct sshkey_sig_details; 40ca32bd8dSchristos 41e8c0841bSchristos void mm_log_handler(LogLevel, int, const char *, void *); 42ca32bd8dSchristos int mm_is_monitor(void); 43cd4ada6aSchristos #ifdef WITH_OPENSSL 44ca32bd8dSchristos DH *mm_choose_dh(int, int, int); 45cd4ada6aSchristos #endif 46aa36fcacSchristos int mm_sshkey_sign(struct ssh *, struct sshkey *, u_char **, size_t *, 472d3b0f52Schristos const u_char *, size_t, const char *, const char *, 482d3b0f52Schristos const char *, u_int compat); 49ca32bd8dSchristos void mm_inform_authserv(char *, char *); 50aa36fcacSchristos struct passwd *mm_getpwnamallow(struct ssh *, const char *); 51ca32bd8dSchristos char *mm_auth2_read_banner(void); 52ffae97bbSchristos int mm_auth_password(struct ssh *, const char *); 53ffae97bbSchristos int mm_key_allowed(enum mm_keytype, const char *, const char *, struct sshkey *, 54ffae97bbSchristos int, struct sshauthopt **); 55e160b4e8Schristos int mm_user_key_allowed(struct ssh *ssh, struct passwd *, struct sshkey *, int, 56ffae97bbSchristos struct sshauthopt **); 57aa36fcacSchristos int mm_hostbased_key_allowed(struct ssh *, struct passwd *, const char *, 587a183406Schristos const char *, struct sshkey *); 597a183406Schristos int mm_sshkey_verify(const struct sshkey *, const u_char *, size_t, 60ed75d7a8Schristos const u_char *, size_t, const char *, u_int, struct sshkey_sig_details **); 61ca32bd8dSchristos 62*1c7715ddSchristos void mm_decode_activate_server_options(struct ssh *ssh, struct sshbuf *m); 63*1c7715ddSchristos 64ca32bd8dSchristos #ifdef GSSAPI 65ca32bd8dSchristos OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID); 66ca32bd8dSchristos OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *, 67ca32bd8dSchristos gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); 68ca32bd8dSchristos int mm_ssh_gssapi_userok(char *user); 69ca32bd8dSchristos OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); 70ca32bd8dSchristos #endif 71ca32bd8dSchristos 72313c6c94Schristos #ifdef USE_PAM 73aa36fcacSchristos void mm_start_pam(struct ssh *); 74313c6c94Schristos u_int mm_do_pam_account(void); 75313c6c94Schristos void *mm_sshpam_init_ctx(struct Authctxt *); 76313c6c94Schristos int mm_sshpam_query(void *, char **, char **, u_int *, char ***, u_int **); 77313c6c94Schristos int mm_sshpam_respond(void *, u_int, char **); 78313c6c94Schristos void mm_sshpam_free_ctx(void *); 79313c6c94Schristos #endif 80313c6c94Schristos 81ca32bd8dSchristos struct Session; 82ca32bd8dSchristos void mm_terminate(void); 83ca32bd8dSchristos int mm_pty_allocate(int *, int *, char *, size_t); 84ca32bd8dSchristos void mm_session_pty_cleanup2(struct Session *); 85ca32bd8dSchristos 86aa36fcacSchristos void mm_send_keystate(struct ssh *, struct monitor*); 87ca32bd8dSchristos 88ca32bd8dSchristos /* bsdauth */ 89ca32bd8dSchristos int mm_bsdauth_query(void *, char **, char **, u_int *, char ***, u_int **); 90ca32bd8dSchristos int mm_bsdauth_respond(void *, u_int, char **); 91ca32bd8dSchristos 92ca32bd8dSchristos /* skey */ 93ca32bd8dSchristos int mm_skey_query(void *, char **, char **, u_int *, char ***, u_int **); 94ca32bd8dSchristos int mm_skey_respond(void *, u_int, char **); 95ca32bd8dSchristos 96313c6c94Schristos /* auth_krb */ 97313c6c94Schristos #ifdef KRB5 98313c6c94Schristos /* auth and reply are really krb5_data objects, but we don't want to 99313c6c94Schristos * include all of the krb5 headers here */ 100313c6c94Schristos int mm_auth_krb5(void *authctxt, void *auth, char **client, void *reply); 101313c6c94Schristos #endif 102*1c7715ddSchristos 103*1c7715ddSchristos /* config / channels glue */ 104*1c7715ddSchristos void server_process_permitopen(struct ssh *); 105*1c7715ddSchristos void server_process_channel_timeouts(struct ssh *ssh); 106*1c7715ddSchristos struct connection_info * 107*1c7715ddSchristos server_get_connection_info(struct ssh *, int, int); 108*1c7715ddSchristos 109ca32bd8dSchristos #endif /* _MM_WRAP_H_ */ 110