session.h 2.8 KB

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