diff --git a/mainchan.c b/mainchan.c index 41c3bb72..8653ad02 100644 --- a/mainchan.c +++ b/mainchan.c @@ -236,7 +236,6 @@ static void mainchan_request_response(Channel *chan, bool success) if (success) { ppl_logevent("Agent forwarding enabled"); - ssh_enable_agent_fwd(mc->cl); } else { ppl_logevent("Agent forwarding refused"); } diff --git a/ssh.h b/ssh.h index fe9eb394..f43aa5ac 100644 --- a/ssh.h +++ b/ssh.h @@ -294,11 +294,10 @@ struct ConnectionLayerVtable { * channel) what its preference for line-discipline options is. */ void (*set_ldisc_option)(ConnectionLayer *cl, int option, bool value); - /* Communicate to the connection layer whether X and agent - * forwarding were successfully enabled (for purposes of - * knowing whether to accept subsequent channel-opens). */ + /* Communicate to the connection layer whether X forwarding was + * successfully enabled (for purposes of knowing whether to accept + * subsequent channel-opens). */ void (*enable_x_fwd)(ConnectionLayer *cl); - void (*enable_agent_fwd)(ConnectionLayer *cl); /* Communicate to the connection layer whether the main session * channel currently wants user input. */ @@ -370,8 +369,6 @@ static inline void ssh_set_ldisc_option(ConnectionLayer *cl, int opt, bool val) { cl->vt->set_ldisc_option(cl, opt, val); } static inline void ssh_enable_x_fwd(ConnectionLayer *cl) { cl->vt->enable_x_fwd(cl); } -static inline void ssh_enable_agent_fwd(ConnectionLayer *cl) -{ cl->vt->enable_agent_fwd(cl); } static inline void ssh_set_wants_user_input(ConnectionLayer *cl, bool wanted) { cl->vt->set_wants_user_input(cl, wanted); } diff --git a/ssh1connection-client.c b/ssh1connection-client.c index b9504940..cf7dd04e 100644 --- a/ssh1connection-client.c +++ b/ssh1connection-client.c @@ -151,7 +151,7 @@ bool ssh1_handle_direction_specific_packet( remid = get_uint32(pktin); /* Refuse if agent forwarding is disabled. */ - if (!s->agent_fwd_enabled) { + if (!ssh_agent_forwarding_permitted(&s->cl)) { pktout = ssh_bpp_new_pktout( s->ppl.bpp, SSH1_MSG_CHANNEL_OPEN_FAILURE); put_uint32(pktout, remid); diff --git a/ssh1connection.c b/ssh1connection.c index d2a9039f..d805dd29 100644 --- a/ssh1connection.c +++ b/ssh1connection.c @@ -62,7 +62,6 @@ static void ssh1_throttle_all_channels(ConnectionLayer *cl, bool throttled); static bool ssh1_ldisc_option(ConnectionLayer *cl, int option); static void ssh1_set_ldisc_option(ConnectionLayer *cl, int option, bool value); static void ssh1_enable_x_fwd(ConnectionLayer *cl); -static void ssh1_enable_agent_fwd(ConnectionLayer *cl); static void ssh1_set_wants_user_input(ConnectionLayer *cl, bool wanted); static const ConnectionLayerVtable ssh1_connlayer_vtable = { @@ -81,7 +80,6 @@ static const ConnectionLayerVtable ssh1_connlayer_vtable = { .ldisc_option = ssh1_ldisc_option, .set_ldisc_option = ssh1_set_ldisc_option, .enable_x_fwd = ssh1_enable_x_fwd, - .enable_agent_fwd = ssh1_enable_agent_fwd, .set_wants_user_input = ssh1_set_wants_user_input, /* other methods are NULL */ }; @@ -770,14 +768,6 @@ static void ssh1_enable_x_fwd(ConnectionLayer *cl) s->X11_fwd_enabled = true; } -static void ssh1_enable_agent_fwd(ConnectionLayer *cl) -{ - struct ssh1_connection_state *s = - container_of(cl, struct ssh1_connection_state, cl); - - s->agent_fwd_enabled = true; -} - static void ssh1_set_wants_user_input(ConnectionLayer *cl, bool wanted) { struct ssh1_connection_state *s = diff --git a/ssh1connection.h b/ssh1connection.h index 670ba779..44370787 100644 --- a/ssh1connection.h +++ b/ssh1connection.h @@ -31,8 +31,6 @@ struct ssh1_connection_state { struct X11FakeAuth *x11auth; tree234 *x11authtree; - bool agent_fwd_enabled; - tree234 *rportfwds; PortFwdManager *portfwdmgr; bool portfwdmgr_configured; diff --git a/ssh2connection-client.c b/ssh2connection-client.c index be3aafe8..0b13efe6 100644 --- a/ssh2connection-client.c +++ b/ssh2connection-client.c @@ -89,7 +89,7 @@ static ChanopenResult chan_open_forwarded_tcpip( static ChanopenResult chan_open_auth_agent( struct ssh2_connection_state *s, SshChannel *sc) { - if (!s->agent_fwd_enabled) { + if (!ssh_agent_forwarding_permitted(&s->cl)) { CHANOPEN_RETURN_FAILURE( SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED, ("Agent forwarding is not enabled")); diff --git a/ssh2connection.c b/ssh2connection.c index 74e96d15..1c9454cb 100644 --- a/ssh2connection.c +++ b/ssh2connection.c @@ -62,7 +62,6 @@ static void ssh2_throttle_all_channels(ConnectionLayer *cl, bool throttled); static bool ssh2_ldisc_option(ConnectionLayer *cl, int option); static void ssh2_set_ldisc_option(ConnectionLayer *cl, int option, bool value); static void ssh2_enable_x_fwd(ConnectionLayer *cl); -static void ssh2_enable_agent_fwd(ConnectionLayer *cl); static void ssh2_set_wants_user_input(ConnectionLayer *cl, bool wanted); static const ConnectionLayerVtable ssh2_connlayer_vtable = { @@ -88,7 +87,6 @@ static const ConnectionLayerVtable ssh2_connlayer_vtable = { .ldisc_option = ssh2_ldisc_option, .set_ldisc_option = ssh2_set_ldisc_option, .enable_x_fwd = ssh2_enable_x_fwd, - .enable_agent_fwd = ssh2_enable_agent_fwd, .set_wants_user_input = ssh2_set_wants_user_input, }; @@ -1694,14 +1692,6 @@ static void ssh2_enable_x_fwd(ConnectionLayer *cl) s->X11_fwd_enabled = true; } -static void ssh2_enable_agent_fwd(ConnectionLayer *cl) -{ - struct ssh2_connection_state *s = - container_of(cl, struct ssh2_connection_state, cl); - - s->agent_fwd_enabled = true; -} - static void ssh2_set_wants_user_input(ConnectionLayer *cl, bool wanted) { struct ssh2_connection_state *s = diff --git a/ssh2connection.h b/ssh2connection.h index 4b82a1a7..f0afb676 100644 --- a/ssh2connection.h +++ b/ssh2connection.h @@ -29,7 +29,6 @@ struct ssh2_connection_state { tree234 *x11authtree; bool got_pty; - bool agent_fwd_enabled; tree234 *rportfwds; PortFwdManager *portfwdmgr;