mirror of
https://github.com/clearml/dropbear
synced 2025-04-19 21:55:41 +00:00
propagate from branch 'au.asn.ucc.matt.dropbear' (head 138a11bc1e2babcd8b1182e6cb2a85d4e9404b11)
to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 12b2f59db65e7339d340e95ac67d6d9ddb193c2b) --HG-- branch : agent-client extra : convert_revision : d82c25da2f7e4fb6da510d806c64344e80bb270d
This commit is contained in:
commit
1e26b86f15
@ -69,7 +69,8 @@ AR=@AR@
|
|||||||
RANLIB=@RANLIB@
|
RANLIB=@RANLIB@
|
||||||
STRIP=@STRIP@
|
STRIP=@STRIP@
|
||||||
INSTALL=@INSTALL@
|
INSTALL=@INSTALL@
|
||||||
CFLAGS=-I. -I$(srcdir)/libtomcrypt/src/headers/ @CFLAGS@
|
CPPFLAGS=@CPPFLAGS@
|
||||||
|
CFLAGS=-I. -I$(srcdir)/libtomcrypt/src/headers/ $(CPPFLAGS) @CFLAGS@
|
||||||
LIBS=$(LTC) $(LTM) @LIBS@
|
LIBS=$(LTC) $(LTM) @LIBS@
|
||||||
LDFLAGS=@LDFLAGS@
|
LDFLAGS=@LDFLAGS@
|
||||||
|
|
||||||
|
@ -236,8 +236,8 @@ void recv_msg_userauth_success() {
|
|||||||
|
|
||||||
void cli_auth_try() {
|
void cli_auth_try() {
|
||||||
|
|
||||||
TRACE(("enter cli_auth_try"))
|
|
||||||
int finished = 0;
|
int finished = 0;
|
||||||
|
TRACE(("enter cli_auth_try"))
|
||||||
|
|
||||||
CHECKCLEARTOWRITE();
|
CHECKCLEARTOWRITE();
|
||||||
|
|
||||||
|
@ -162,8 +162,6 @@ void cli_tty_cleanup() {
|
|||||||
|
|
||||||
static void put_termcodes() {
|
static void put_termcodes() {
|
||||||
|
|
||||||
TRACE(("enter put_termcodes"))
|
|
||||||
|
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
unsigned int sshcode;
|
unsigned int sshcode;
|
||||||
const struct TermCode *termcode;
|
const struct TermCode *termcode;
|
||||||
@ -172,6 +170,8 @@ static void put_termcodes() {
|
|||||||
|
|
||||||
unsigned int bufpos1, bufpos2;
|
unsigned int bufpos1, bufpos2;
|
||||||
|
|
||||||
|
TRACE(("enter put_termcodes"))
|
||||||
|
|
||||||
if (tcgetattr(STDIN_FILENO, &tio) == -1) {
|
if (tcgetattr(STDIN_FILENO, &tio) == -1) {
|
||||||
dropbear_log(LOG_WARNING, "Failed reading termmodes");
|
dropbear_log(LOG_WARNING, "Failed reading termmodes");
|
||||||
buf_putint(ses.writepayload, 1); /* Just the terminator */
|
buf_putint(ses.writepayload, 1); /* Just the terminator */
|
||||||
|
20
cli-kex.c
20
cli-kex.c
@ -145,6 +145,7 @@ static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
|
|||||||
FILE *hostsfile = NULL;
|
FILE *hostsfile = NULL;
|
||||||
int readonly = 0;
|
int readonly = 0;
|
||||||
struct passwd *pw = NULL;
|
struct passwd *pw = NULL;
|
||||||
|
char * homedir = NULL;
|
||||||
unsigned int hostlen, algolen;
|
unsigned int hostlen, algolen;
|
||||||
unsigned long len;
|
unsigned long len;
|
||||||
const char *algoname = NULL;
|
const char *algoname = NULL;
|
||||||
@ -153,14 +154,21 @@ static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
|
|||||||
|
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
|
||||||
if (pw == NULL) {
|
if (pw)
|
||||||
dropbear_exit("Failed to get homedir");
|
homedir = pw->pw_dir;
|
||||||
|
}
|
||||||
|
pw = NULL;
|
||||||
|
|
||||||
|
if (!homedir)
|
||||||
|
homedir = getenv("HOME");
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(pw->pw_dir);
|
if (homedir) {
|
||||||
|
|
||||||
|
len = strlen(homedir);
|
||||||
filename = m_malloc(len + 18); /* "/.ssh/known_hosts" and null-terminator*/
|
filename = m_malloc(len + 18); /* "/.ssh/known_hosts" and null-terminator*/
|
||||||
|
|
||||||
snprintf(filename, len+18, "%s/.ssh", pw->pw_dir);
|
snprintf(filename, len+18, "%s/.ssh", homedir);
|
||||||
/* Check that ~/.ssh exists - easiest way is just to mkdir */
|
/* Check that ~/.ssh exists - easiest way is just to mkdir */
|
||||||
if (mkdir(filename, S_IRWXU) != 0) {
|
if (mkdir(filename, S_IRWXU) != 0) {
|
||||||
if (errno != EEXIST) {
|
if (errno != EEXIST) {
|
||||||
@ -172,7 +180,7 @@ static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(filename, len+18, "%s/.ssh/known_hosts", pw->pw_dir);
|
snprintf(filename, len+18, "%s/.ssh/known_hosts", homedir);
|
||||||
hostsfile = fopen(filename, "a+");
|
hostsfile = fopen(filename, "a+");
|
||||||
|
|
||||||
if (hostsfile != NULL) {
|
if (hostsfile != NULL) {
|
||||||
@ -185,9 +193,11 @@ static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
|
|||||||
hostsfile = fopen(filename, "r");
|
hostsfile = fopen(filename, "r");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hostsfile == NULL) {
|
if (hostsfile == NULL) {
|
||||||
TRACE(("hostsfile didn't open: %s", strerror(errno)))
|
TRACE(("hostsfile didn't open: %s", strerror(errno)))
|
||||||
|
dropbear_log(LOG_WARNING, "Failed to open ~/.ssh/known_hosts");
|
||||||
ask_to_confirm(keyblob, keybloblen);
|
ask_to_confirm(keyblob, keybloblen);
|
||||||
goto out; /* We only get here on success */
|
goto out; /* We only get here on success */
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ static void checkclose(struct Channel *channel) {
|
|||||||
TRACE(("checkclose: writefd %d, readfd %d, errfd %d, sentclosed %d, recvclosed %d",
|
TRACE(("checkclose: writefd %d, readfd %d, errfd %d, sentclosed %d, recvclosed %d",
|
||||||
channel->writefd, channel->readfd,
|
channel->writefd, channel->readfd,
|
||||||
channel->errfd, channel->sentclosed, channel->recvclosed))
|
channel->errfd, channel->sentclosed, channel->recvclosed))
|
||||||
TRACE(("writebuf %d extrabuf %s extrabuf %d",
|
TRACE(("writebuf size %d extrabuf ptr 0x%x extrabuf size %d",
|
||||||
cbuf_getused(channel->writebuf),
|
cbuf_getused(channel->writebuf),
|
||||||
channel->writebuf,
|
channel->writebuf,
|
||||||
channel->writebuf ? 0 : cbuf_getused(channel->extrabuf)))
|
channel->writebuf ? 0 : cbuf_getused(channel->extrabuf)))
|
||||||
|
6
random.c
6
random.c
@ -31,7 +31,8 @@ static int donerandinit = 0;
|
|||||||
|
|
||||||
/* this is used to generate unique output from the same hashpool */
|
/* this is used to generate unique output from the same hashpool */
|
||||||
static uint32_t counter = 0;
|
static uint32_t counter = 0;
|
||||||
#define MAX_COUNTER 1<<31 /* the max value for the counter, so it won't loop */
|
/* the max value for the counter, so it won't integer overflow */
|
||||||
|
#define MAX_COUNTER 1<<30
|
||||||
|
|
||||||
static unsigned char hashpool[SHA1_HASH_SIZE];
|
static unsigned char hashpool[SHA1_HASH_SIZE];
|
||||||
|
|
||||||
@ -153,6 +154,7 @@ void seedrandom() {
|
|||||||
void reseedrandom() {
|
void reseedrandom() {
|
||||||
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
hash_state hs;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
if (!donerandinit) {
|
if (!donerandinit) {
|
||||||
@ -162,8 +164,6 @@ void reseedrandom() {
|
|||||||
pid = getpid();
|
pid = getpid();
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
|
|
||||||
hash_state hs;
|
|
||||||
unsigned char hash[SHA1_HASH_SIZE];
|
|
||||||
sha1_init(&hs);
|
sha1_init(&hs);
|
||||||
sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
|
sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
|
||||||
sha1_process(&hs, (void*)&pid, sizeof(pid));
|
sha1_process(&hs, (void*)&pid, sizeof(pid));
|
||||||
|
@ -315,14 +315,15 @@ void send_msg_userauth_failure(int partial, int incrfail) {
|
|||||||
buf_setpos(typebuf, 0);
|
buf_setpos(typebuf, 0);
|
||||||
buf_putstring(ses.writepayload, buf_getptr(typebuf, typebuf->len),
|
buf_putstring(ses.writepayload, buf_getptr(typebuf, typebuf->len),
|
||||||
typebuf->len);
|
typebuf->len);
|
||||||
|
|
||||||
|
TRACE(("auth fail: methods %d, '%s'", ses.authstate.authtypes,
|
||||||
|
buf_getptr(typebuf, typebuf->len)));
|
||||||
|
|
||||||
buf_free(typebuf);
|
buf_free(typebuf);
|
||||||
|
|
||||||
buf_putbyte(ses.writepayload, partial ? 1 : 0);
|
buf_putbyte(ses.writepayload, partial ? 1 : 0);
|
||||||
encrypt_packet();
|
encrypt_packet();
|
||||||
|
|
||||||
TRACE(("auth fail: methods %d, '%s'", ses.authstate.authtypes,
|
|
||||||
buf_getptr(typebuf, typebuf->len)));
|
|
||||||
|
|
||||||
if (incrfail) {
|
if (incrfail) {
|
||||||
usleep(300000); /* XXX improve this */
|
usleep(300000); /* XXX improve this */
|
||||||
ses.authstate.failcount++;
|
ses.authstate.failcount++;
|
||||||
|
@ -410,7 +410,7 @@ static int sessionwinchange(struct ChanSess *chansess) {
|
|||||||
|
|
||||||
pty_change_window_size(chansess->master, termr, termc, termw, termh);
|
pty_change_window_size(chansess->master, termr, termc, termw, termh);
|
||||||
|
|
||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_termmodes(struct ChanSess *chansess) {
|
static void get_termmodes(struct ChanSess *chansess) {
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "signkey.h"
|
#include "signkey.h"
|
||||||
#include "runopts.h"
|
#include "runopts.h"
|
||||||
|
#include "random.h"
|
||||||
|
|
||||||
static size_t listensockets(int *sock, size_t sockcount, int *maxfd);
|
static size_t listensockets(int *sock, size_t sockcount, int *maxfd);
|
||||||
static void sigchld_handler(int dummy);
|
static void sigchld_handler(int dummy);
|
||||||
|
Loading…
Reference in New Issue
Block a user