Mercurial > dropbear
diff svr-agentfwd.c @ 641:2b1bb792cd4d dropbear-tfm
- Update tfm changes to current default tip
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 21 Nov 2011 19:52:28 +0800 |
parents | 81def6b732c7 |
children | 220f55d540ae |
line wrap: on
line diff
--- a/svr-agentfwd.c Mon Nov 21 19:19:57 2011 +0800 +++ b/svr-agentfwd.c Mon Nov 21 19:52:28 2011 +0800 @@ -27,7 +27,7 @@ #include "includes.h" -#ifndef DISABLE_AGENTFWD +#ifdef ENABLE_SVR_AGENTFWD #include "agentfwd.h" #include "session.h" @@ -49,9 +49,8 @@ /* Handles client requests to start agent forwarding, sets up listening socket. * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ -int agentreq(struct ChanSess * chansess) { - - int fd; +int svr_agentreq(struct ChanSess * chansess) { + int fd = -1; if (!svr_pubkey_allows_agentfwd()) { return DROPBEAR_FAILURE; @@ -91,8 +90,9 @@ return DROPBEAR_SUCCESS; fail: + m_close(fd); /* cleanup */ - agentcleanup(chansess); + svr_agentcleanup(chansess); return DROPBEAR_FAILURE; } @@ -118,7 +118,7 @@ /* set up the environment variable pointing to the socket. This is called * just before command/shell execution, after dropping priveleges */ -void agentset(struct ChanSess * chansess) { +void svr_agentset(struct ChanSess * chansess) { char *path = NULL; int len; @@ -137,7 +137,7 @@ } /* close the socket, remove the socket-file */ -void agentcleanup(struct ChanSess * chansess) { +void svr_agentcleanup(struct ChanSess * chansess) { char *path = NULL; uid_t uid; @@ -157,7 +157,7 @@ gid = getgid(); if ((setegid(ses.authstate.pw_gid)) < 0 || (seteuid(ses.authstate.pw_uid)) < 0) { - dropbear_exit("failed to set euid"); + dropbear_exit("Failed to set euid"); } /* 2 for "/" and "\0" */ @@ -172,7 +172,7 @@ if ((seteuid(uid)) < 0 || (setegid(gid)) < 0) { - dropbear_exit("failed to revert euid"); + dropbear_exit("Failed to revert euid"); } m_free(chansess->agentfile); @@ -181,7 +181,7 @@ } -static const struct ChanType chan_agent = { +static const struct ChanType chan_svr_agent = { 0, /* sepfds */ "[email protected]", NULL, @@ -194,7 +194,7 @@ /* helper for accepting an agent request */ static int send_msg_channel_open_agent(int fd) { - if (send_msg_channel_open_init(fd, &chan_agent) == DROPBEAR_SUCCESS) { + if (send_msg_channel_open_init(fd, &chan_svr_agent) == DROPBEAR_SUCCESS) { encrypt_packet(); return DROPBEAR_SUCCESS; } else { @@ -220,7 +220,7 @@ gid = getgid(); if ((setegid(ses.authstate.pw_gid)) < 0 || (seteuid(ses.authstate.pw_uid)) < 0) { - dropbear_exit("failed to set euid"); + dropbear_exit("Failed to set euid"); } memset((void*)&addr, 0x0, sizeof(addr)); @@ -263,7 +263,7 @@ out: if ((seteuid(uid)) < 0 || (setegid(gid)) < 0) { - dropbear_exit("failed to revert euid"); + dropbear_exit("Failed to revert euid"); } return ret; }