sshutils.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Supporting routines used in common by all the various components of
  3. * the SSH system.
  4. */
  5. #include <assert.h>
  6. #include <stdlib.h>
  7. #include "putty.h"
  8. #include "ssh.h"
  9. #include "ssh/channel.h"
  10. /* ----------------------------------------------------------------------
  11. * Centralised standard methods for other channel implementations to
  12. * borrow.
  13. */
  14. void chan_remotely_opened_confirmation(Channel *chan)
  15. {
  16. unreachable("this channel type should never receive OPEN_CONFIRMATION");
  17. }
  18. void chan_remotely_opened_failure(Channel *chan, const char *errtext)
  19. {
  20. unreachable("this channel type should never receive OPEN_FAILURE");
  21. }
  22. bool chan_default_want_close(
  23. Channel *chan, bool sent_local_eof, bool rcvd_remote_eof)
  24. {
  25. /*
  26. * Default close policy: we start initiating the CHANNEL_CLOSE
  27. * procedure as soon as both sides of the channel have seen EOF.
  28. */
  29. return sent_local_eof && rcvd_remote_eof;
  30. }
  31. bool chan_no_exit_status(Channel *chan, int status)
  32. {
  33. return false;
  34. }
  35. bool chan_no_exit_signal(
  36. Channel *chan, ptrlen signame, bool core_dumped, ptrlen msg)
  37. {
  38. return false;
  39. }
  40. bool chan_no_exit_signal_numeric(
  41. Channel *chan, int signum, bool core_dumped, ptrlen msg)
  42. {
  43. return false;
  44. }
  45. bool chan_no_run_shell(Channel *chan)
  46. {
  47. return false;
  48. }
  49. bool chan_no_run_command(Channel *chan, ptrlen command)
  50. {
  51. return false;
  52. }
  53. bool chan_no_run_subsystem(Channel *chan, ptrlen subsys)
  54. {
  55. return false;
  56. }
  57. bool chan_no_enable_x11_forwarding(
  58. Channel *chan, bool oneshot, ptrlen authproto, ptrlen authdata,
  59. unsigned screen_number)
  60. {
  61. return false;
  62. }
  63. bool chan_no_enable_agent_forwarding(Channel *chan)
  64. {
  65. return false;
  66. }
  67. bool chan_no_allocate_pty(
  68. Channel *chan, ptrlen termtype, unsigned width, unsigned height,
  69. unsigned pixwidth, unsigned pixheight, struct ssh_ttymodes modes)
  70. {
  71. return false;
  72. }
  73. bool chan_no_set_env(Channel *chan, ptrlen var, ptrlen value)
  74. {
  75. return false;
  76. }
  77. bool chan_no_send_break(Channel *chan, unsigned length)
  78. {
  79. return false;
  80. }
  81. bool chan_no_send_signal(Channel *chan, ptrlen signame)
  82. {
  83. return false;
  84. }
  85. bool chan_no_change_window_size(
  86. Channel *chan, unsigned width, unsigned height,
  87. unsigned pixwidth, unsigned pixheight)
  88. {
  89. return false;
  90. }
  91. void chan_no_request_response(Channel *chan, bool success)
  92. {
  93. unreachable("this channel type should never send a want-reply request");
  94. }
  95. /* ----------------------------------------------------------------------
  96. * Other miscellaneous utility functions.
  97. */
  98. void free_rportfwd(struct ssh_rportfwd *rpf)
  99. {
  100. if (rpf) {
  101. sfree(rpf->log_description);
  102. sfree(rpf->shost);
  103. sfree(rpf->dhost);
  104. sfree(rpf);
  105. }
  106. }