1 1.1 christos /* $NetBSD: session.h,v 1.10 2023/07/26 17:58:15 christos Exp $ */ 2 1.10 christos /* $OpenBSD: session.h,v 1.37 2023/01/06 02:39:59 djm Exp $ */ 3 1.1 christos 4 1.1 christos /* 5 1.1 christos * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 6 1.1 christos * 7 1.1 christos * Redistribution and use in source and binary forms, with or without 8 1.1 christos * modification, are permitted provided that the following conditions 9 1.1 christos * are met: 10 1.1 christos * 1. Redistributions of source code must retain the above copyright 11 1.1 christos * notice, this list of conditions and the following disclaimer. 12 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 christos * notice, this list of conditions and the following disclaimer in the 14 1.1 christos * documentation and/or other materials provided with the distribution. 15 1.1 christos * 16 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 christos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 1.1 christos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 1.1 christos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 1.1 christos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 1.1 christos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 1.1 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 1.1 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 1.1 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 1.1 christos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 1.1 christos */ 27 1.1 christos #ifndef SESSION_H 28 1.1 christos #define SESSION_H 29 1.1 christos 30 1.2 christos #include <tzfile.h> 31 1.2 christos 32 1.1 christos #define TTYSZ 64 33 1.1 christos typedef struct Session Session; 34 1.1 christos struct Session { 35 1.1 christos int used; 36 1.1 christos int self; 37 1.1 christos int next_unused; 38 1.1 christos struct passwd *pw; 39 1.1 christos Authctxt *authctxt; 40 1.1 christos pid_t pid; 41 1.9 christos int forced; 42 1.1 christos 43 1.1 christos /* tty */ 44 1.1 christos char *term; 45 1.1 christos int ptyfd, ttyfd, ptymaster; 46 1.1 christos u_int row, col, xpixel, ypixel; 47 1.1 christos char tty[TTYSZ]; 48 1.1 christos 49 1.1 christos /* X11 */ 50 1.1 christos u_int display_number; 51 1.1 christos char *display; 52 1.1 christos u_int screen; 53 1.1 christos char *auth_display; 54 1.1 christos char *auth_proto; 55 1.1 christos char *auth_data; 56 1.1 christos int single_connection; 57 1.1 christos 58 1.1 christos int chanid; 59 1.1 christos int *x11_chanids; 60 1.1 christos int is_subsystem; 61 1.3 christos char *subsys; 62 1.1 christos u_int num_env; 63 1.1 christos struct { 64 1.1 christos char *name; 65 1.1 christos char *val; 66 1.1 christos } *env; 67 1.1 christos }; 68 1.1 christos 69 1.8 christos void do_authenticated(struct ssh *, Authctxt *); 70 1.8 christos void do_cleanup(struct ssh *, Authctxt *); 71 1.1 christos 72 1.1 christos int session_open(Authctxt *, int); 73 1.1 christos void session_unused(int); 74 1.8 christos int session_input_channel_req(struct ssh *, Channel *, const char *); 75 1.8 christos void session_close_by_pid(struct ssh *ssh, pid_t, int); 76 1.10 christos void session_close_by_channel(struct ssh *, int, int, void *); 77 1.8 christos void session_destroy_all(struct ssh *, void (*)(Session *)); 78 1.1 christos void session_pty_cleanup2(Session *); 79 1.1 christos 80 1.1 christos Session *session_new(void); 81 1.1 christos Session *session_by_tty(char *); 82 1.8 christos void session_close(struct ssh *, Session *); 83 1.1 christos void do_setusercontext(struct passwd *); 84 1.1 christos 85 1.5 christos const char *session_get_remote_name_or_ip(struct ssh *, u_int, int); 86 1.5 christos 87 1.1 christos #endif 88