mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Get rid of the error-return mechanism from x11_init.
Now that it doesn't actually make a network connection because that's deferred until after the X authorisation exchange, there's no point in having it return an error message and write the real output through a pointer argument. Instead, we can just have it return xconn directly and simplify the call sites. [originally from svn r10081]
This commit is contained in:
parent
94e8f97d3f
commit
e5a3e28eec
51
ssh.c
51
ssh.c
@ -4887,34 +4887,22 @@ static void ssh1_smsg_x11_open(Ssh ssh, struct Packet *pktin)
|
||||
PKT_INT, remoteid, PKT_END);
|
||||
logevent("Rejected X11 connect request");
|
||||
} else {
|
||||
char *err;
|
||||
|
||||
c = snew(struct ssh_channel);
|
||||
c->ssh = ssh;
|
||||
|
||||
if ((err = x11_init(&c->u.x11.xconn, ssh->x11authtree, c,
|
||||
NULL, -1)) != NULL) {
|
||||
logeventf(ssh, "Opening X11 forward connection failed: %s", err);
|
||||
sfree(err);
|
||||
sfree(c);
|
||||
send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_FAILURE,
|
||||
PKT_INT, remoteid, PKT_END);
|
||||
} else {
|
||||
logevent
|
||||
("Opening X11 forward connection succeeded");
|
||||
c->remoteid = remoteid;
|
||||
c->halfopen = FALSE;
|
||||
c->localid = alloc_channel_id(ssh);
|
||||
c->closes = 0;
|
||||
c->pending_eof = FALSE;
|
||||
c->throttling_conn = 0;
|
||||
c->type = CHAN_X11; /* identify channel type */
|
||||
add234(ssh->channels, c);
|
||||
send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION,
|
||||
PKT_INT, c->remoteid, PKT_INT,
|
||||
c->localid, PKT_END);
|
||||
logevent("Opened X11 forward channel");
|
||||
}
|
||||
c->u.x11.xconn = x11_init(ssh->x11authtree, c, NULL, -1);
|
||||
c->remoteid = remoteid;
|
||||
c->halfopen = FALSE;
|
||||
c->localid = alloc_channel_id(ssh);
|
||||
c->closes = 0;
|
||||
c->pending_eof = FALSE;
|
||||
c->throttling_conn = 0;
|
||||
c->type = CHAN_X11; /* identify channel type */
|
||||
add234(ssh->channels, c);
|
||||
send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION,
|
||||
PKT_INT, c->remoteid, PKT_INT,
|
||||
c->localid, PKT_END);
|
||||
logevent("Opened X11 forward channel");
|
||||
}
|
||||
}
|
||||
|
||||
@ -7563,7 +7551,6 @@ static void ssh2_msg_channel_open(Ssh ssh, struct Packet *pktin)
|
||||
|
||||
if (typelen == 3 && !memcmp(type, "x11", 3)) {
|
||||
char *addrstr;
|
||||
char *x11err;
|
||||
|
||||
ssh_pkt_getstring(pktin, &peeraddr, &peeraddrlen);
|
||||
addrstr = snewn(peeraddrlen+1, char);
|
||||
@ -7576,14 +7563,12 @@ static void ssh2_msg_channel_open(Ssh ssh, struct Packet *pktin)
|
||||
|
||||
if (!ssh->X11_fwd_enabled)
|
||||
error = "X11 forwarding is not enabled";
|
||||
else if ((x11err = x11_init(&c->u.x11.xconn, ssh->x11authtree, c,
|
||||
addrstr, peerport)) != NULL) {
|
||||
logeventf(ssh, "Local X11 connection failed: %s", x11err);
|
||||
sfree(x11err);
|
||||
error = "Unable to open an X11 connection";
|
||||
} else {
|
||||
logevent("Opening X11 forward connection succeeded");
|
||||
else {
|
||||
c->u.x11.xconn = x11_init(ssh->x11authtree, c,
|
||||
addrstr, peerport);
|
||||
c->type = CHAN_X11;
|
||||
|
||||
logevent("Opened X11 forward channel");
|
||||
}
|
||||
|
||||
sfree(addrstr);
|
||||
|
3
ssh.h
3
ssh.h
@ -418,8 +418,7 @@ void x11_free_display(struct X11Display *disp);
|
||||
struct X11FakeAuth *x11_invent_fake_auth(tree234 *t, int authtype);
|
||||
void x11_free_fake_auth(struct X11FakeAuth *auth);
|
||||
struct X11Connection; /* opaque outside x11fwd.c */
|
||||
extern char *x11_init(struct X11Connection **, tree234 *authtree,
|
||||
void *, const char *, int);
|
||||
struct X11Connection *x11_init(tree234 *authtree, void *, const char *, int);
|
||||
extern void x11_close(struct X11Connection *);
|
||||
extern int x11_send(struct X11Connection *, char *, int);
|
||||
extern void x11_send_eof(struct X11Connection *s);
|
||||
|
15
x11fwd.c
15
x11fwd.c
@ -649,14 +649,11 @@ int x11_get_screen_number(char *display)
|
||||
}
|
||||
|
||||
/*
|
||||
* Called to set up the raw connection.
|
||||
*
|
||||
* On success, returns NULL and fills in *xconnret. On error, returns
|
||||
* a dynamically allocated error message string.
|
||||
* Called to set up the X11Connection structure, though this does not
|
||||
* yet connect to an actual server.
|
||||
*/
|
||||
extern char *x11_init(struct X11Connection **xconnret,
|
||||
tree234 *authtree, void *c,
|
||||
const char *peeraddr, int peerport)
|
||||
struct X11Connection *x11_init(tree234 *authtree, void *c,
|
||||
const char *peeraddr, int peerport)
|
||||
{
|
||||
static const struct plug_function_table fn_table = {
|
||||
x11_log,
|
||||
@ -671,7 +668,7 @@ extern char *x11_init(struct X11Connection **xconnret,
|
||||
/*
|
||||
* Open socket.
|
||||
*/
|
||||
xconn = *xconnret = snew(struct X11Connection);
|
||||
xconn = snew(struct X11Connection);
|
||||
xconn->fn = &fn_table;
|
||||
xconn->auth_protocol = NULL;
|
||||
xconn->authtree = authtree;
|
||||
@ -698,7 +695,7 @@ extern char *x11_init(struct X11Connection **xconnret,
|
||||
xconn->peer_addr = peeraddr ? dupstr(peeraddr) : NULL;
|
||||
xconn->peer_port = peerport;
|
||||
|
||||
return NULL;
|
||||
return xconn;
|
||||
}
|
||||
|
||||
void x11_close(struct X11Connection *xconn)
|
||||
|
Loading…
Reference in New Issue
Block a user