1*6d13e39aSdjm /* $OpenBSD: session.h,v 1.30 2008/05/08 12:21:16 djm Exp $ */ 2d4e7c603Sniklas 3607fba6cSderaadt /* 4a4d26d98Smarkus * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 5607fba6cSderaadt * 6607fba6cSderaadt * Redistribution and use in source and binary forms, with or without 7607fba6cSderaadt * modification, are permitted provided that the following conditions 8607fba6cSderaadt * are met: 9607fba6cSderaadt * 1. Redistributions of source code must retain the above copyright 10607fba6cSderaadt * notice, this list of conditions and the following disclaimer. 11607fba6cSderaadt * 2. Redistributions in binary form must reproduce the above copyright 12607fba6cSderaadt * notice, this list of conditions and the following disclaimer in the 13607fba6cSderaadt * documentation and/or other materials provided with the distribution. 14607fba6cSderaadt * 15607fba6cSderaadt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16607fba6cSderaadt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17607fba6cSderaadt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18607fba6cSderaadt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19607fba6cSderaadt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20607fba6cSderaadt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21607fba6cSderaadt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22607fba6cSderaadt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23607fba6cSderaadt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24607fba6cSderaadt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25607fba6cSderaadt */ 26133a7928Smarkus #ifndef SESSION_H 27133a7928Smarkus #define SESSION_H 28133a7928Smarkus 2950c32c83Sprovos #define TTYSZ 64 3050c32c83Sprovos typedef struct Session Session; 3150c32c83Sprovos struct Session { 3250c32c83Sprovos int used; 3350c32c83Sprovos int self; 34*6d13e39aSdjm int next_unused; 3550c32c83Sprovos struct passwd *pw; 3650c32c83Sprovos Authctxt *authctxt; 3750c32c83Sprovos pid_t pid; 38c64ced71Sderaadt 3950c32c83Sprovos /* tty */ 4050c32c83Sprovos char *term; 4150c32c83Sprovos int ptyfd, ttyfd, ptymaster; 426c28c6bcSderaadt u_int row, col, xpixel, ypixel; 4350c32c83Sprovos char tty[TTYSZ]; 44c64ced71Sderaadt 4550c32c83Sprovos /* X11 */ 466c28c6bcSderaadt u_int display_number; 4750c32c83Sprovos char *display; 486c28c6bcSderaadt u_int screen; 4950c32c83Sprovos char *auth_display; 5050c32c83Sprovos char *auth_proto; 5150c32c83Sprovos char *auth_data; 5250c32c83Sprovos int single_connection; 53c64ced71Sderaadt 5450c32c83Sprovos /* proto 2 */ 5550c32c83Sprovos int chanid; 566aa873e0Sdjm int *x11_chanids; 5750c32c83Sprovos int is_subsystem; 58d7d07780Sdjm u_int num_env; 59e6440d8dSdjm struct { 60e6440d8dSdjm char *name; 61e6440d8dSdjm char *val; 62e6440d8dSdjm } *env; 6350c32c83Sprovos }; 6450c32c83Sprovos 6508d1172dSitojun void do_authenticated(Authctxt *); 66b8b8936dSmarkus void do_cleanup(Authctxt *); 67133a7928Smarkus 681b9280a0Smarkus int session_open(Authctxt *, int); 69*6d13e39aSdjm void session_unused(int); 70e07b5efdSmarkus int session_input_channel_req(Channel *, const char *); 7108d1172dSitojun void session_close_by_pid(pid_t, int); 7208d1172dSitojun void session_close_by_channel(int, void *); 7350c32c83Sprovos void session_destroy_all(void (*)(Session *)); 74b8b8936dSmarkus void session_pty_cleanup2(Session *); 754f9037ccSmarkus 7650c32c83Sprovos Session *session_new(void); 7750c32c83Sprovos Session *session_by_tty(char *); 7850c32c83Sprovos void session_close(Session *); 7950c32c83Sprovos void do_setusercontext(struct passwd *); 80c9017d5dSmarkus void child_set_env(char ***envp, u_int *envsizep, const char *name, 81c9017d5dSmarkus const char *value); 82c9017d5dSmarkus 83133a7928Smarkus #endif 84