Mercurial > dropbear
changeset 657:16af1decaf4c
- Merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 21 Feb 2012 23:00:30 +0800 |
parents | 67fbba2c2a85 (current diff) 818108bf7749 (diff) |
children | d4d0279710b9 |
files | dbutil.c svr-chansession.c |
diffstat | 11 files changed, 42 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/auth.h Tue Feb 21 22:57:19 2012 +0800 +++ b/auth.h Tue Feb 21 23:00:30 2012 +0800 @@ -133,7 +133,6 @@ int no_pty_flag; /* "command=" option. */ unsigned char * forced_command; - unsigned char * original_command; }; #endif
--- a/channel.h Tue Feb 21 22:57:19 2012 +0800 +++ b/channel.h Tue Feb 21 23:00:30 2012 +0800 @@ -69,6 +69,10 @@ int sent_close, recv_close; int recv_eof, sent_eof; + /* Set after running the ChanType-specific close hander + * to ensure we don't run it twice (nor type->checkclose()). */ + int close_handler_done; + int initconn; /* used for TCP forwarding, whether the channel has been fully initialised */
--- a/chansession.h Tue Feb 21 22:57:19 2012 +0800 +++ b/chansession.h Tue Feb 21 23:00:30 2012 +0800 @@ -69,6 +69,10 @@ char * agentfile; char * agentdir; #endif + +#ifdef ENABLE_SVR_PUBKEY_OPTIONS + char *original_command; +#endif }; struct ChildPid {
--- a/cli-agentfwd.c Tue Feb 21 22:57:19 2012 +0800 +++ b/cli-agentfwd.c Tue Feb 21 23:00:30 2012 +0800 @@ -260,7 +260,7 @@ const unsigned char *data, unsigned int len) { buffer *request_data = NULL; buffer *response = NULL; - unsigned int keylen, siglen; + unsigned int siglen; int packet_type; /* Request format @@ -271,7 +271,6 @@ */ request_data = buf_new(MAX_PUBKEY_SIZE + len + 12); buf_put_pub_key(request_data, key, key->type); - keylen = request_data->len - 4; buf_putstring(request_data, data, len); buf_putint(request_data, 0);
--- a/common-channel.c Tue Feb 21 22:57:19 2012 +0800 +++ b/common-channel.c Tue Feb 21 23:00:30 2012 +0800 @@ -138,6 +138,7 @@ newchan->index = i; newchan->sent_close = newchan->recv_close = 0; newchan->sent_eof = newchan->recv_eof = 0; + newchan->close_handler_done = 0; newchan->remotechan = remotechan; newchan->transwindow = transwindow; @@ -270,7 +271,9 @@ cbuf_getused(channel->writebuf), channel->extrabuf ? cbuf_getused(channel->extrabuf) : 0)) - if (!channel->flushing && channel->type->check_close + if (!channel->flushing + && !channel->close_handler_done + && channel->type->check_close && channel->type->check_close(channel)) { channel->flushing = 1; @@ -281,7 +284,8 @@ channel, to ensure that the shell has exited (and the exit status retrieved) before we close things up. */ if (!channel->type->check_close - || channel->type->check_close(channel)) { + || channel->close_handler_done + || channel->type->check_close(channel)) { close_allowed = 1; } @@ -363,9 +367,11 @@ /* Send the close message and set the channel as closed */ static void send_msg_channel_close(struct Channel *channel) { - TRACE(("enter send_msg_channel_close")) - if (channel->type->closehandler) { + TRACE(("enter send_msg_channel_close %p", channel)) + if (channel->type->closehandler + && !channel->close_handler_done) { channel->type->closehandler(channel); + channel->close_handler_done = 1; } CHECKCLEARTOWRITE(); @@ -568,16 +574,17 @@ struct Channel *channel; - TRACE(("enter recv_msg_channel_request")) - channel = getchannel(); + TRACE(("enter recv_msg_channel_request %p", channel)) + if (channel->sent_close) { TRACE(("leave recv_msg_channel_request: already closed channel")) return; } - if (channel->type->reqhandler) { + if (channel->type->reqhandler + && !channel->close_handler_done) { channel->type->reqhandler(channel); } else { send_msg_channel_failure(channel);
--- a/dbutil.c Tue Feb 21 22:57:19 2012 +0800 +++ b/dbutil.c Tue Feb 21 23:00:30 2012 +0800 @@ -800,12 +800,6 @@ return ret; } -void __m_free(void* ptr) { - if (ptr != NULL) { - free(ptr); - } -} - void * m_realloc(void* ptr, size_t size) { void *ret;
--- a/dbutil.h Tue Feb 21 22:57:19 2012 +0800 +++ b/dbutil.h Tue Feb 21 23:00:30 2012 +0800 @@ -83,8 +83,7 @@ void * m_malloc(size_t size); void * m_strdup(const char * str); void * m_realloc(void* ptr, size_t size); -#define m_free(X) __m_free(X); (X) = NULL; -void __m_free(void* ptr); +#define m_free(X) free(X); (X) = NULL; void m_burn(void* data, unsigned int len); void setnonblocking(int fd); void disallow_core();
--- a/signkey.c Tue Feb 21 22:57:19 2012 +0800 +++ b/signkey.c Tue Feb 21 23:00:30 2012 +0800 @@ -105,11 +105,11 @@ m_free(ident); if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) { - TRACE(("buf_get_pub_key bad type - got %d, expected %d", keytype, type)) + TRACE(("buf_get_pub_key bad type - got %d, expected %d", keytype, *type)) return DROPBEAR_FAILURE; } - TRACE(("buf_get_pub_key keytype is %d")) + TRACE(("buf_get_pub_key keytype is %d", keytype)) *type = keytype;
--- a/svr-authpubkeyoptions.c Tue Feb 21 22:57:19 2012 +0800 +++ b/svr-authpubkeyoptions.c Tue Feb 21 23:00:30 2012 +0800 @@ -92,14 +92,15 @@ * by any 'command' public key option. */ void svr_pubkey_set_forced_command(struct ChanSess *chansess) { if (ses.authstate.pubkey_options) { - ses.authstate.pubkey_options->original_command = chansess->cmd; - if (!chansess->cmd) - { - ses.authstate.pubkey_options->original_command = m_strdup(""); + if (chansess->cmd) { + /* original_command takes ownership */ + chansess->original_command = chansess->cmd; + } else { + chansess->original_command = m_strdup(""); } - chansess->cmd = ses.authstate.pubkey_options->forced_command; + chansess->cmd = m_strdup(ses.authstate.pubkey_options->forced_command); #ifdef LOG_COMMANDS - dropbear_log(LOG_INFO, "Command forced to '%s'", ses.authstate.pubkey_options->original_command); + dropbear_log(LOG_INFO, "Command forced to '%s'", chansess->original_command); #endif } }
--- a/svr-chansession.c Tue Feb 21 22:57:19 2012 +0800 +++ b/svr-chansession.c Tue Feb 21 23:00:30 2012 +0800 @@ -218,6 +218,8 @@ struct ChanSess *chansess; + TRACE(("new chansess %p", channel)) + dropbear_assert(channel->typedata == NULL); chansess = (struct ChanSess*)m_malloc(sizeof(struct ChanSess)); @@ -280,6 +282,10 @@ m_free(chansess->cmd); m_free(chansess->term); +#ifdef ENABLE_SVR_PUBKEY_OPTIONS + m_free(chansess->original_command); +#endif + if (chansess->tty) { /* write the utmp/wtmp login record */ li = chansess_login_alloc(chansess); @@ -925,10 +931,8 @@ } #ifdef ENABLE_SVR_PUBKEY_OPTIONS - if (ses.authstate.pubkey_options && - ses.authstate.pubkey_options->original_command) { - addnewvar("SSH_ORIGINAL_COMMAND", - ses.authstate.pubkey_options->original_command); + if (chansess->original_command) { + addnewvar("SSH_ORIGINAL_COMMAND", chansess->original_command); } #endif
--- a/svr-x11fwd.c Tue Feb 21 22:57:19 2012 +0800 +++ b/svr-x11fwd.c Tue Feb 21 23:00:30 2012 +0800 @@ -175,7 +175,7 @@ m_free(chansess->x11authprot); m_free(chansess->x11authcookie); - TRACE(("chansess %s", chansess)) + TRACE(("chansess %x", chansess)) if (chansess->x11listener != NULL) { remove_listener(chansess->x11listener); chansess->x11listener = NULL;