diff options
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | session.h | 3 | ||||
-rw-r--r-- | svr-agentfwd.c | 8 | ||||
-rw-r--r-- | svr-session.c | 29 |
4 files changed, 24 insertions, 23 deletions
@@ -62,8 +62,11 @@ int main(int argc, char ** argv) struct sigaction sa_chld; + _dropbear_exit = svr_dropbear_exit; + _dropbear_log = svr_dropbear_log; + /* get commandline options */ - opts = getrunopts(argc, argv); + opts = svr_getopts(argc, argv); /* fork */ if (opts->forkbg) { @@ -239,7 +242,7 @@ int main(int argc, char ** argv) dropbear_exit("Couldn't close socket"); } /* start the session */ - child_session(childsock, opts, childpipe[1], &remoteaddr); + svr_session(childsock, opts, childpipe[1], &remoteaddr); /* don't return */ assert(0); } @@ -48,6 +48,9 @@ extern void(*session_remoteclosed)(); /* Server */ void svr_session(int sock, runopts *opts, int childpipe, struct sockaddr *remoteaddr); +void svr_dropbear_exit(int exitcode, const char* format, va_list param); +void svr_dropbear_log(int priority, const char* format, va_list param); + struct key_context { diff --git a/svr-agentfwd.c b/svr-agentfwd.c index c4958c4..f8af30e 100644 --- a/svr-agentfwd.c +++ b/svr-agentfwd.c @@ -141,8 +141,8 @@ void agentcleanup(struct ChanSess * chansess) { * for themselves */ uid = getuid(); gid = getgid(); - if ((setegid(ses.authstate.pw->pw_gid)) < 0 || - (seteuid(ses.authstate.pw->pw_uid)) < 0) { + if ((setegid(svr_ses.authstate.pw->pw_gid)) < 0 || + (seteuid(svr_ses.authstate.pw->pw_uid)) < 0) { dropbear_exit("failed to set euid"); } @@ -194,8 +194,8 @@ static int bindagent(struct ChanSess * chansess) { /* drop to user privs to make the dir/file */ uid = getuid(); gid = getgid(); - if ((setegid(ses.authstate.pw->pw_gid)) < 0 || - (seteuid(ses.authstate.pw->pw_uid)) < 0) { + if ((setegid(svr_ses.authstate.pw->pw_gid)) < 0 || + (seteuid(svr_ses.authstate.pw->pw_uid)) < 0) { dropbear_exit("failed to set euid"); } diff --git a/svr-session.c b/svr-session.c index bc24487..1aade1f 100644 --- a/svr-session.c +++ b/svr-session.c @@ -37,8 +37,6 @@ #include "atomicio.h" static void svr_remoteclosed(); -static void svr_dropbear_exit(int exitcode, const char* format, va_list param); -static void svr_dropbear_log(int priority, const char* format, va_list param); struct serversession svr_ses; @@ -68,8 +66,6 @@ void svr_session(int sock, runopts *opts, int childpipe, /* set up messages etc */ session_remoteclosed = svr_remoteclosed; - _dropbear_exit = svr_dropbear_exit; - _dropbear_log = svr_dropbear_log; /* We're ready to go now */ sessinitdone = 1; @@ -153,19 +149,8 @@ void svr_session(int sock, runopts *opts, int childpipe, } /* for(;;) */ } - - -/* called when the remote side closes the connection */ -static void svr_remoteclosed() { - - close(ses.sock); - ses.sock = -1; - dropbear_close("Exited normally"); - -} - /* failure exit - format must be <= 100 chars */ -static void svr_dropbear_exit(int exitcode, const char* format, va_list param) { +void svr_dropbear_exit(int exitcode, const char* format, va_list param) { char fmtbuf[300]; @@ -205,7 +190,7 @@ static void svr_dropbear_exit(int exitcode, const char* format, va_list param) { } /* priority is priority as with syslog() */ -static void svr_dropbear_log(int priority, const char* format, va_list param) { +void svr_dropbear_log(int priority, const char* format, va_list param) { char printbuf[1024]; char datestr[20]; @@ -236,3 +221,13 @@ static void svr_dropbear_log(int priority, const char* format, va_list param) { fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf); } } + +/* called when the remote side closes the connection */ +static void svr_remoteclosed() { + + close(ses.sock); + ses.sock = -1; + dropbear_close("Exited normally"); + +} + |