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");
}
}
if (typelen == 3 && !memcmp(type, "x11", 3)) {
char *addrstr;
- char *x11err;
ssh_pkt_getstring(pktin, &peeraddr, &peeraddrlen);
addrstr = snewn(peeraddrlen+1, char);
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);
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);
}
/*
- * 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,
/*
* Open socket.
*/
- xconn = *xconnret = snew(struct X11Connection);
+ xconn = snew(struct X11Connection);
xconn->fn = &fn_table;
xconn->auth_protocol = NULL;
xconn->authtree = authtree;
xconn->peer_addr = peeraddr ? dupstr(peeraddr) : NULL;
xconn->peer_port = peerport;
- return NULL;
+ return xconn;
}
void x11_close(struct X11Connection *xconn)