1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

Move half of sshcommon.c out into sshutils.c.

Like other 'utils' modules, the point is that sshutils.c has no
external dependencies, so it's safe to include in a tool without
requiring you to bring in a cascade of other modules you didn't really
want.

Right now I'm only planning to use this change in an out-of-tree
experiment, but it's harmless to commit the change itself here.
This commit is contained in:
Simon Tatham 2020-02-07 19:19:27 +00:00
parent 630cac3aa2
commit 66e6bc4a79
3 changed files with 132 additions and 118 deletions

2
Recipe
View File

@ -262,7 +262,7 @@ SSHCRYPTO = ARITH sshmd5 sshsha sshsh256 sshsh512
+ sshdes sshblowf sshaes sshccp ssharcf
+ sshdh sshcrc sshcrcda sshauxcrypt
+ sshhmac
SSHCOMMON = sshcommon sshprng sshrand SSHCRYPTO
SSHCOMMON = sshcommon sshutils sshprng sshrand SSHCRYPTO
+ sshverstring
+ sshpubk sshzlib
+ sshmac marshal nullplug

View File

@ -356,109 +356,6 @@ static bool zombiechan_want_close(Channel *chan, bool sent_eof, bool rcvd_eof)
return true;
}
/* ----------------------------------------------------------------------
* Centralised standard methods for other channel implementations to
* borrow.
*/
void chan_remotely_opened_confirmation(Channel *chan)
{
unreachable("this channel type should never receive OPEN_CONFIRMATION");
}
void chan_remotely_opened_failure(Channel *chan, const char *errtext)
{
unreachable("this channel type should never receive OPEN_FAILURE");
}
bool chan_default_want_close(
Channel *chan, bool sent_local_eof, bool rcvd_remote_eof)
{
/*
* Default close policy: we start initiating the CHANNEL_CLOSE
* procedure as soon as both sides of the channel have seen EOF.
*/
return sent_local_eof && rcvd_remote_eof;
}
bool chan_no_exit_status(Channel *chan, int status)
{
return false;
}
bool chan_no_exit_signal(
Channel *chan, ptrlen signame, bool core_dumped, ptrlen msg)
{
return false;
}
bool chan_no_exit_signal_numeric(
Channel *chan, int signum, bool core_dumped, ptrlen msg)
{
return false;
}
bool chan_no_run_shell(Channel *chan)
{
return false;
}
bool chan_no_run_command(Channel *chan, ptrlen command)
{
return false;
}
bool chan_no_run_subsystem(Channel *chan, ptrlen subsys)
{
return false;
}
bool chan_no_enable_x11_forwarding(
Channel *chan, bool oneshot, ptrlen authproto, ptrlen authdata,
unsigned screen_number)
{
return false;
}
bool chan_no_enable_agent_forwarding(Channel *chan)
{
return false;
}
bool chan_no_allocate_pty(
Channel *chan, ptrlen termtype, unsigned width, unsigned height,
unsigned pixwidth, unsigned pixheight, struct ssh_ttymodes modes)
{
return false;
}
bool chan_no_set_env(Channel *chan, ptrlen var, ptrlen value)
{
return false;
}
bool chan_no_send_break(Channel *chan, unsigned length)
{
return false;
}
bool chan_no_send_signal(Channel *chan, ptrlen signame)
{
return false;
}
bool chan_no_change_window_size(
Channel *chan, unsigned width, unsigned height,
unsigned pixwidth, unsigned pixheight)
{
return false;
}
void chan_no_request_response(Channel *chan, bool success)
{
unreachable("this channel type should never send a want-reply request");
}
/* ----------------------------------------------------------------------
* Common routines for handling SSH tty modes.
*/
@ -1047,17 +944,3 @@ void ssh1_compute_session_id(
put_data(hash, cookie, 8);
ssh_hash_final(hash, session_id);
}
/* ----------------------------------------------------------------------
* Other miscellaneous utility functions.
*/
void free_rportfwd(struct ssh_rportfwd *rpf)
{
if (rpf) {
sfree(rpf->log_description);
sfree(rpf->shost);
sfree(rpf->dhost);
sfree(rpf);
}
}

131
sshutils.c Normal file
View File

@ -0,0 +1,131 @@
/*
* Supporting routines used in common by all the various components of
* the SSH system.
*/
#include <assert.h>
#include <stdlib.h>
#include "putty.h"
#include "mpint.h"
#include "ssh.h"
#include "sshbpp.h"
#include "sshppl.h"
#include "sshchan.h"
/* ----------------------------------------------------------------------
* Centralised standard methods for other channel implementations to
* borrow.
*/
void chan_remotely_opened_confirmation(Channel *chan)
{
unreachable("this channel type should never receive OPEN_CONFIRMATION");
}
void chan_remotely_opened_failure(Channel *chan, const char *errtext)
{
unreachable("this channel type should never receive OPEN_FAILURE");
}
bool chan_default_want_close(
Channel *chan, bool sent_local_eof, bool rcvd_remote_eof)
{
/*
* Default close policy: we start initiating the CHANNEL_CLOSE
* procedure as soon as both sides of the channel have seen EOF.
*/
return sent_local_eof && rcvd_remote_eof;
}
bool chan_no_exit_status(Channel *chan, int status)
{
return false;
}
bool chan_no_exit_signal(
Channel *chan, ptrlen signame, bool core_dumped, ptrlen msg)
{
return false;
}
bool chan_no_exit_signal_numeric(
Channel *chan, int signum, bool core_dumped, ptrlen msg)
{
return false;
}
bool chan_no_run_shell(Channel *chan)
{
return false;
}
bool chan_no_run_command(Channel *chan, ptrlen command)
{
return false;
}
bool chan_no_run_subsystem(Channel *chan, ptrlen subsys)
{
return false;
}
bool chan_no_enable_x11_forwarding(
Channel *chan, bool oneshot, ptrlen authproto, ptrlen authdata,
unsigned screen_number)
{
return false;
}
bool chan_no_enable_agent_forwarding(Channel *chan)
{
return false;
}
bool chan_no_allocate_pty(
Channel *chan, ptrlen termtype, unsigned width, unsigned height,
unsigned pixwidth, unsigned pixheight, struct ssh_ttymodes modes)
{
return false;
}
bool chan_no_set_env(Channel *chan, ptrlen var, ptrlen value)
{
return false;
}
bool chan_no_send_break(Channel *chan, unsigned length)
{
return false;
}
bool chan_no_send_signal(Channel *chan, ptrlen signame)
{
return false;
}
bool chan_no_change_window_size(
Channel *chan, unsigned width, unsigned height,
unsigned pixwidth, unsigned pixheight)
{
return false;
}
void chan_no_request_response(Channel *chan, bool success)
{
unreachable("this channel type should never send a want-reply request");
}
/* ----------------------------------------------------------------------
* Other miscellaneous utility functions.
*/
void free_rportfwd(struct ssh_rportfwd *rpf)
{
if (rpf) {
sfree(rpf->log_description);
sfree(rpf->shost);
sfree(rpf->dhost);
sfree(rpf);
}
}