mirror of
https://github.com/clearml/dropbear
synced 2025-03-09 21:41:07 +00:00
- Merge
This commit is contained in:
commit
6c4390c848
1
auth.h
1
auth.h
@ -133,7 +133,6 @@ struct PubKeyOptions {
|
|||||||
int no_pty_flag;
|
int no_pty_flag;
|
||||||
/* "command=" option. */
|
/* "command=" option. */
|
||||||
unsigned char * forced_command;
|
unsigned char * forced_command;
|
||||||
unsigned char * original_command;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -69,6 +69,10 @@ struct Channel {
|
|||||||
int sent_close, recv_close;
|
int sent_close, recv_close;
|
||||||
int recv_eof, sent_eof;
|
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
|
int initconn; /* used for TCP forwarding, whether the channel has been
|
||||||
fully initialised */
|
fully initialised */
|
||||||
|
|
||||||
|
@ -69,6 +69,10 @@ struct ChanSess {
|
|||||||
char * agentfile;
|
char * agentfile;
|
||||||
char * agentdir;
|
char * agentdir;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_SVR_PUBKEY_OPTIONS
|
||||||
|
char *original_command;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ChildPid {
|
struct ChildPid {
|
||||||
|
@ -260,7 +260,7 @@ void agent_buf_sign(buffer *sigblob, sign_key *key,
|
|||||||
const unsigned char *data, unsigned int len) {
|
const unsigned char *data, unsigned int len) {
|
||||||
buffer *request_data = NULL;
|
buffer *request_data = NULL;
|
||||||
buffer *response = NULL;
|
buffer *response = NULL;
|
||||||
unsigned int keylen, siglen;
|
unsigned int siglen;
|
||||||
int packet_type;
|
int packet_type;
|
||||||
|
|
||||||
/* Request format
|
/* Request format
|
||||||
@ -271,7 +271,6 @@ void agent_buf_sign(buffer *sigblob, sign_key *key,
|
|||||||
*/
|
*/
|
||||||
request_data = buf_new(MAX_PUBKEY_SIZE + len + 12);
|
request_data = buf_new(MAX_PUBKEY_SIZE + len + 12);
|
||||||
buf_put_pub_key(request_data, key, key->type);
|
buf_put_pub_key(request_data, key, key->type);
|
||||||
keylen = request_data->len - 4;
|
|
||||||
|
|
||||||
buf_putstring(request_data, data, len);
|
buf_putstring(request_data, data, len);
|
||||||
buf_putint(request_data, 0);
|
buf_putint(request_data, 0);
|
||||||
|
@ -138,6 +138,7 @@ struct Channel* newchannel(unsigned int remotechan,
|
|||||||
newchan->index = i;
|
newchan->index = i;
|
||||||
newchan->sent_close = newchan->recv_close = 0;
|
newchan->sent_close = newchan->recv_close = 0;
|
||||||
newchan->sent_eof = newchan->recv_eof = 0;
|
newchan->sent_eof = newchan->recv_eof = 0;
|
||||||
|
newchan->close_handler_done = 0;
|
||||||
|
|
||||||
newchan->remotechan = remotechan;
|
newchan->remotechan = remotechan;
|
||||||
newchan->transwindow = transwindow;
|
newchan->transwindow = transwindow;
|
||||||
@ -270,7 +271,9 @@ static void check_close(struct Channel *channel) {
|
|||||||
cbuf_getused(channel->writebuf),
|
cbuf_getused(channel->writebuf),
|
||||||
channel->extrabuf ? cbuf_getused(channel->extrabuf) : 0))
|
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->type->check_close(channel))
|
||||||
{
|
{
|
||||||
channel->flushing = 1;
|
channel->flushing = 1;
|
||||||
@ -281,7 +284,8 @@ static void check_close(struct Channel *channel) {
|
|||||||
channel, to ensure that the shell has exited (and the exit status
|
channel, to ensure that the shell has exited (and the exit status
|
||||||
retrieved) before we close things up. */
|
retrieved) before we close things up. */
|
||||||
if (!channel->type->check_close
|
if (!channel->type->check_close
|
||||||
|| channel->type->check_close(channel)) {
|
|| channel->close_handler_done
|
||||||
|
|| channel->type->check_close(channel)) {
|
||||||
close_allowed = 1;
|
close_allowed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,9 +367,11 @@ static void check_in_progress(struct Channel *channel) {
|
|||||||
/* Send the close message and set the channel as closed */
|
/* Send the close message and set the channel as closed */
|
||||||
static void send_msg_channel_close(struct Channel *channel) {
|
static void send_msg_channel_close(struct Channel *channel) {
|
||||||
|
|
||||||
TRACE(("enter send_msg_channel_close"))
|
TRACE(("enter send_msg_channel_close %p", channel))
|
||||||
if (channel->type->closehandler) {
|
if (channel->type->closehandler
|
||||||
|
&& !channel->close_handler_done) {
|
||||||
channel->type->closehandler(channel);
|
channel->type->closehandler(channel);
|
||||||
|
channel->close_handler_done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECKCLEARTOWRITE();
|
CHECKCLEARTOWRITE();
|
||||||
@ -568,16 +574,17 @@ void recv_msg_channel_request() {
|
|||||||
|
|
||||||
struct Channel *channel;
|
struct Channel *channel;
|
||||||
|
|
||||||
TRACE(("enter recv_msg_channel_request"))
|
|
||||||
|
|
||||||
channel = getchannel();
|
channel = getchannel();
|
||||||
|
|
||||||
|
TRACE(("enter recv_msg_channel_request %p", channel))
|
||||||
|
|
||||||
if (channel->sent_close) {
|
if (channel->sent_close) {
|
||||||
TRACE(("leave recv_msg_channel_request: already closed channel"))
|
TRACE(("leave recv_msg_channel_request: already closed channel"))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->type->reqhandler) {
|
if (channel->type->reqhandler
|
||||||
|
&& !channel->close_handler_done) {
|
||||||
channel->type->reqhandler(channel);
|
channel->type->reqhandler(channel);
|
||||||
} else {
|
} else {
|
||||||
send_msg_channel_failure(channel);
|
send_msg_channel_failure(channel);
|
||||||
|
6
dbutil.c
6
dbutil.c
@ -800,12 +800,6 @@ void * m_strdup(const char * str) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __m_free(void* ptr) {
|
|
||||||
if (ptr != NULL) {
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void * m_realloc(void* ptr, size_t size) {
|
void * m_realloc(void* ptr, size_t size) {
|
||||||
|
|
||||||
void *ret;
|
void *ret;
|
||||||
|
3
dbutil.h
3
dbutil.h
@ -83,8 +83,7 @@ void m_close(int fd);
|
|||||||
void * m_malloc(size_t size);
|
void * m_malloc(size_t size);
|
||||||
void * m_strdup(const char * str);
|
void * m_strdup(const char * str);
|
||||||
void * m_realloc(void* ptr, size_t size);
|
void * m_realloc(void* ptr, size_t size);
|
||||||
#define m_free(X) __m_free(X); (X) = NULL;
|
#define m_free(X) free(X); (X) = NULL;
|
||||||
void __m_free(void* ptr);
|
|
||||||
void m_burn(void* data, unsigned int len);
|
void m_burn(void* data, unsigned int len);
|
||||||
void setnonblocking(int fd);
|
void setnonblocking(int fd);
|
||||||
void disallow_core();
|
void disallow_core();
|
||||||
|
@ -105,11 +105,11 @@ int buf_get_pub_key(buffer *buf, sign_key *key, int *type) {
|
|||||||
m_free(ident);
|
m_free(ident);
|
||||||
|
|
||||||
if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) {
|
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;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(("buf_get_pub_key keytype is %d"))
|
TRACE(("buf_get_pub_key keytype is %d", keytype))
|
||||||
|
|
||||||
*type = keytype;
|
*type = keytype;
|
||||||
|
|
||||||
|
@ -92,14 +92,15 @@ int svr_pubkey_allows_pty() {
|
|||||||
* by any 'command' public key option. */
|
* by any 'command' public key option. */
|
||||||
void svr_pubkey_set_forced_command(struct ChanSess *chansess) {
|
void svr_pubkey_set_forced_command(struct ChanSess *chansess) {
|
||||||
if (ses.authstate.pubkey_options) {
|
if (ses.authstate.pubkey_options) {
|
||||||
ses.authstate.pubkey_options->original_command = chansess->cmd;
|
if (chansess->cmd) {
|
||||||
if (!chansess->cmd)
|
/* original_command takes ownership */
|
||||||
{
|
chansess->original_command = chansess->cmd;
|
||||||
ses.authstate.pubkey_options->original_command = m_strdup("");
|
} 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
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,6 +218,8 @@ static int newchansess(struct Channel *channel) {
|
|||||||
|
|
||||||
struct ChanSess *chansess;
|
struct ChanSess *chansess;
|
||||||
|
|
||||||
|
TRACE(("new chansess %p", channel))
|
||||||
|
|
||||||
dropbear_assert(channel->typedata == NULL);
|
dropbear_assert(channel->typedata == NULL);
|
||||||
|
|
||||||
chansess = (struct ChanSess*)m_malloc(sizeof(struct ChanSess));
|
chansess = (struct ChanSess*)m_malloc(sizeof(struct ChanSess));
|
||||||
@ -280,6 +282,10 @@ static void closechansess(struct Channel *channel) {
|
|||||||
m_free(chansess->cmd);
|
m_free(chansess->cmd);
|
||||||
m_free(chansess->term);
|
m_free(chansess->term);
|
||||||
|
|
||||||
|
#ifdef ENABLE_SVR_PUBKEY_OPTIONS
|
||||||
|
m_free(chansess->original_command);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (chansess->tty) {
|
if (chansess->tty) {
|
||||||
/* write the utmp/wtmp login record */
|
/* write the utmp/wtmp login record */
|
||||||
li = chansess_login_alloc(chansess);
|
li = chansess_login_alloc(chansess);
|
||||||
@ -925,10 +931,8 @@ static void execchild(void *user_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_SVR_PUBKEY_OPTIONS
|
#ifdef ENABLE_SVR_PUBKEY_OPTIONS
|
||||||
if (ses.authstate.pubkey_options &&
|
if (chansess->original_command) {
|
||||||
ses.authstate.pubkey_options->original_command) {
|
addnewvar("SSH_ORIGINAL_COMMAND", chansess->original_command);
|
||||||
addnewvar("SSH_ORIGINAL_COMMAND",
|
|
||||||
ses.authstate.pubkey_options->original_command);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ void x11cleanup(struct ChanSess *chansess) {
|
|||||||
m_free(chansess->x11authprot);
|
m_free(chansess->x11authprot);
|
||||||
m_free(chansess->x11authcookie);
|
m_free(chansess->x11authcookie);
|
||||||
|
|
||||||
TRACE(("chansess %s", chansess))
|
TRACE(("chansess %x", chansess))
|
||||||
if (chansess->x11listener != NULL) {
|
if (chansess->x11listener != NULL) {
|
||||||
remove_listener(chansess->x11listener);
|
remove_listener(chansess->x11listener);
|
||||||
chansess->x11listener = NULL;
|
chansess->x11listener = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user