xref: /dragonfly/crypto/openssh/session.h (revision 664f4763)
1664f4763Szrj /* $OpenBSD: session.h,v 1.36 2018/10/02 12:40:07 djm Exp $ */
218de8d7fSPeter Avalos 
318de8d7fSPeter Avalos /*
418de8d7fSPeter Avalos  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
518de8d7fSPeter Avalos  *
618de8d7fSPeter Avalos  * Redistribution and use in source and binary forms, with or without
718de8d7fSPeter Avalos  * modification, are permitted provided that the following conditions
818de8d7fSPeter Avalos  * are met:
918de8d7fSPeter Avalos  * 1. Redistributions of source code must retain the above copyright
1018de8d7fSPeter Avalos  *    notice, this list of conditions and the following disclaimer.
1118de8d7fSPeter Avalos  * 2. Redistributions in binary form must reproduce the above copyright
1218de8d7fSPeter Avalos  *    notice, this list of conditions and the following disclaimer in the
1318de8d7fSPeter Avalos  *    documentation and/or other materials provided with the distribution.
1418de8d7fSPeter Avalos  *
1518de8d7fSPeter Avalos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1618de8d7fSPeter Avalos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1718de8d7fSPeter Avalos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1818de8d7fSPeter Avalos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1918de8d7fSPeter Avalos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2018de8d7fSPeter Avalos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2118de8d7fSPeter Avalos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2218de8d7fSPeter Avalos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2318de8d7fSPeter Avalos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2418de8d7fSPeter Avalos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2518de8d7fSPeter Avalos  */
2618de8d7fSPeter Avalos #ifndef SESSION_H
2718de8d7fSPeter Avalos #define SESSION_H
2818de8d7fSPeter Avalos 
2918de8d7fSPeter Avalos #define TTYSZ 64
3018de8d7fSPeter Avalos typedef struct Session Session;
3118de8d7fSPeter Avalos struct Session {
3218de8d7fSPeter Avalos 	int	used;
3318de8d7fSPeter Avalos 	int	self;
3418de8d7fSPeter Avalos 	int	next_unused;
3518de8d7fSPeter Avalos 	struct passwd *pw;
3618de8d7fSPeter Avalos 	Authctxt *authctxt;
3718de8d7fSPeter Avalos 	pid_t	pid;
38664f4763Szrj 	int	forced;
3918de8d7fSPeter Avalos 
4018de8d7fSPeter Avalos 	/* tty */
4118de8d7fSPeter Avalos 	char	*term;
4218de8d7fSPeter Avalos 	int	ptyfd, ttyfd, ptymaster;
4318de8d7fSPeter Avalos 	u_int	row, col, xpixel, ypixel;
4418de8d7fSPeter Avalos 	char	tty[TTYSZ];
4518de8d7fSPeter Avalos 
4618de8d7fSPeter Avalos 	/* X11 */
4718de8d7fSPeter Avalos 	u_int	display_number;
4818de8d7fSPeter Avalos 	char	*display;
4918de8d7fSPeter Avalos 	u_int	screen;
5018de8d7fSPeter Avalos 	char	*auth_display;
5118de8d7fSPeter Avalos 	char	*auth_proto;
5218de8d7fSPeter Avalos 	char	*auth_data;
5318de8d7fSPeter Avalos 	int	single_connection;
5418de8d7fSPeter Avalos 
5518de8d7fSPeter Avalos 	int	chanid;
5618de8d7fSPeter Avalos 	int	*x11_chanids;
5718de8d7fSPeter Avalos 	int	is_subsystem;
5836e94dc5SPeter Avalos 	char	*subsys;
5918de8d7fSPeter Avalos 	u_int	num_env;
6018de8d7fSPeter Avalos 	struct {
6118de8d7fSPeter Avalos 		char	*name;
6218de8d7fSPeter Avalos 		char	*val;
6318de8d7fSPeter Avalos 	} *env;
6418de8d7fSPeter Avalos };
6518de8d7fSPeter Avalos 
66ce74bacaSMatthew Dillon void	 do_authenticated(struct ssh *, Authctxt *);
67ce74bacaSMatthew Dillon void	 do_cleanup(struct ssh *, Authctxt *);
6818de8d7fSPeter Avalos 
6918de8d7fSPeter Avalos int	 session_open(Authctxt *, int);
7018de8d7fSPeter Avalos void	 session_unused(int);
71ce74bacaSMatthew Dillon int	 session_input_channel_req(struct ssh *, Channel *, const char *);
72ce74bacaSMatthew Dillon void	 session_close_by_pid(struct ssh *ssh, pid_t, int);
73ce74bacaSMatthew Dillon void	 session_close_by_channel(struct ssh *, int, void *);
74ce74bacaSMatthew Dillon void	 session_destroy_all(struct ssh *, void (*)(Session *));
7518de8d7fSPeter Avalos void	 session_pty_cleanup2(Session *);
7618de8d7fSPeter Avalos 
7718de8d7fSPeter Avalos Session	*session_new(void);
7818de8d7fSPeter Avalos Session	*session_by_tty(char *);
79ce74bacaSMatthew Dillon void	 session_close(struct ssh *, Session *);
8018de8d7fSPeter Avalos void	 do_setusercontext(struct passwd *);
8118de8d7fSPeter Avalos 
82e9778795SPeter Avalos const char	*session_get_remote_name_or_ip(struct ssh *, u_int, int);
83e9778795SPeter Avalos 
8418de8d7fSPeter Avalos #endif
85