mirror of
https://github.com/clearml/dropbear
synced 2025-05-16 09:35:53 +00:00
Merge pull request #18 from annulen/dbclient_syslog
Support syslog logging in dbclient.
This commit is contained in:
commit
3d33e65a35
@ -190,7 +190,7 @@ static void ask_to_confirm(unsigned char* keyblob, unsigned int keybloblen,
|
|||||||
|
|
||||||
fp = sign_key_fingerprint(keyblob, keybloblen);
|
fp = sign_key_fingerprint(keyblob, keybloblen);
|
||||||
if (cli_opts.always_accept_key) {
|
if (cli_opts.always_accept_key) {
|
||||||
fprintf(stderr, "\nHost '%s' key accepted unconditionally.\n(%s fingerprint %s)\n",
|
dropbear_log(LOG_INFO, "\nHost '%s' key accepted unconditionally.\n(%s fingerprint %s)\n",
|
||||||
cli_opts.remotehost,
|
cli_opts.remotehost,
|
||||||
algoname,
|
algoname,
|
||||||
fp);
|
fp);
|
||||||
@ -290,7 +290,7 @@ static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (cli_opts.no_hostkey_check) {
|
if (cli_opts.no_hostkey_check) {
|
||||||
fprintf(stderr, "Caution, skipping hostkey check for %s\n", cli_opts.remotehost);
|
dropbear_log(LOG_INFO, "Caution, skipping hostkey check for %s\n", cli_opts.remotehost);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
cli-main.c
14
cli-main.c
@ -60,6 +60,12 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
cli_getopts(argc, argv);
|
cli_getopts(argc, argv);
|
||||||
|
|
||||||
|
#ifndef DISABLE_SYSLOG
|
||||||
|
if (opts.usingsyslog) {
|
||||||
|
startsyslog("dbclient");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TRACE(("user='%s' host='%s' port='%s'", cli_opts.username,
|
TRACE(("user='%s' host='%s' port='%s'", cli_opts.username,
|
||||||
cli_opts.remotehost, cli_opts.remoteport))
|
cli_opts.remotehost, cli_opts.remoteport))
|
||||||
|
|
||||||
@ -118,13 +124,19 @@ static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
|
|||||||
exit(exitcode);
|
exit(exitcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cli_dropbear_log(int UNUSED(priority),
|
static void cli_dropbear_log(int priority,
|
||||||
const char* format, va_list param) {
|
const char* format, va_list param) {
|
||||||
|
|
||||||
char printbuf[1024];
|
char printbuf[1024];
|
||||||
|
|
||||||
vsnprintf(printbuf, sizeof(printbuf), format, param);
|
vsnprintf(printbuf, sizeof(printbuf), format, param);
|
||||||
|
|
||||||
|
#ifndef DISABLE_SYSLOG
|
||||||
|
if (opts.usingsyslog) {
|
||||||
|
syslog(priority, "%s", printbuf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf);
|
fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,9 @@ void cli_getopts(int argc, char ** argv) {
|
|||||||
#ifdef ENABLE_USER_ALGO_LIST
|
#ifdef ENABLE_USER_ALGO_LIST
|
||||||
opts.cipher_list = NULL;
|
opts.cipher_list = NULL;
|
||||||
opts.mac_list = NULL;
|
opts.mac_list = NULL;
|
||||||
|
#endif
|
||||||
|
#ifndef DISABLE_SYSLOG
|
||||||
|
opts.usingsyslog = 0;
|
||||||
#endif
|
#endif
|
||||||
/* not yet
|
/* not yet
|
||||||
opts.ipv4 = 1;
|
opts.ipv4 = 1;
|
||||||
@ -488,7 +491,7 @@ static void loadidentityfile(const char* filename, int warnfail) {
|
|||||||
keytype = DROPBEAR_SIGNKEY_ANY;
|
keytype = DROPBEAR_SIGNKEY_ANY;
|
||||||
if ( readhostkey(filename, key, &keytype) != DROPBEAR_SUCCESS ) {
|
if ( readhostkey(filename, key, &keytype) != DROPBEAR_SUCCESS ) {
|
||||||
if (warnfail) {
|
if (warnfail) {
|
||||||
fprintf(stderr, "Failed loading keyfile '%s'\n", filename);
|
dropbear_log(LOG_WARNING, "Failed loading keyfile '%s'\n", filename);
|
||||||
}
|
}
|
||||||
sign_key_free(key);
|
sign_key_free(key);
|
||||||
} else {
|
} else {
|
||||||
@ -860,6 +863,9 @@ static void add_extendedopt(const char* origstr) {
|
|||||||
dropbear_log(LOG_INFO, "Available options:\n"
|
dropbear_log(LOG_INFO, "Available options:\n"
|
||||||
#ifdef ENABLE_CLI_ANYTCPFWD
|
#ifdef ENABLE_CLI_ANYTCPFWD
|
||||||
"\tExitOnForwardFailure\n"
|
"\tExitOnForwardFailure\n"
|
||||||
|
#endif
|
||||||
|
#ifndef DISABLE_SYSLOG
|
||||||
|
"\tUseSyslog\n"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
@ -872,5 +878,12 @@ static void add_extendedopt(const char* origstr) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_SYSLOG
|
||||||
|
if (match_extendedopt(&optstr, "UseSyslog") == DROPBEAR_SUCCESS) {
|
||||||
|
opts.usingsyslog = parse_flag_value(optstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
dropbear_exit("Bad configuration option '%s'", origstr);
|
dropbear_exit("Bad configuration option '%s'", origstr);
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,11 @@ static void cli_sessionloop() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case USERAUTH_SUCCESS_RCVD:
|
case USERAUTH_SUCCESS_RCVD:
|
||||||
|
#ifndef DISABLE_SYSLOG
|
||||||
|
if (opts.usingsyslog) {
|
||||||
|
dropbear_log(LOG_INFO, "Authentication succeeded.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DROPBEAR_NONE_CIPHER
|
#ifdef DROPBEAR_NONE_CIPHER
|
||||||
if (cli_ses.cipher_none_after_auth)
|
if (cli_ses.cipher_none_after_auth)
|
||||||
|
10
dbclient.1
10
dbclient.1
@ -133,12 +133,14 @@ useful for specifying options for which there is no separate command-line flag.
|
|||||||
For full details of the options listed below, and their possible values, see
|
For full details of the options listed below, and their possible values, see
|
||||||
ssh_config(5).
|
ssh_config(5).
|
||||||
|
|
||||||
For now only following options have been implemented:
|
For now following options have been implemented:
|
||||||
.RS
|
|
||||||
.RS
|
.RS
|
||||||
.TP
|
.TP
|
||||||
ExitOnForwardFailure
|
.B ExitOnForwardFailure
|
||||||
.RE
|
Specifies whether dbclient should terminate the connection if it cannot set up all requested local and remote port forwardings. The argument must be “yes” or “no”. The default is “no”.
|
||||||
|
.TP
|
||||||
|
.B UseSyslog
|
||||||
|
Send dbclient log messages to syslog in addition to stderr.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-s
|
.B \-s
|
||||||
|
4
dbutil.c
4
dbutil.c
@ -84,9 +84,9 @@ int debug_trace = 0;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_SYSLOG
|
#ifndef DISABLE_SYSLOG
|
||||||
void startsyslog() {
|
void startsyslog(const char *ident) {
|
||||||
|
|
||||||
openlog(PROGNAME, LOG_PID, LOG_AUTHPRIV);
|
openlog(ident, LOG_PID, LOG_AUTHPRIV);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* DISABLE_SYSLOG */
|
#endif /* DISABLE_SYSLOG */
|
||||||
|
2
dbutil.h
2
dbutil.h
@ -31,7 +31,7 @@
|
|||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
|
||||||
#ifndef DISABLE_SYSLOG
|
#ifndef DISABLE_SYSLOG
|
||||||
void startsyslog();
|
void startsyslog(const char *ident);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
@ -40,6 +40,7 @@ typedef struct runopts {
|
|||||||
unsigned int recv_window;
|
unsigned int recv_window;
|
||||||
time_t keepalive_secs; /* Time between sending keepalives. 0 is off */
|
time_t keepalive_secs; /* Time between sending keepalives. 0 is off */
|
||||||
time_t idle_timeout_secs; /* Exit if no traffic is sent/received in this time */
|
time_t idle_timeout_secs; /* Exit if no traffic is sent/received in this time */
|
||||||
|
int usingsyslog;
|
||||||
|
|
||||||
#ifndef DISABLE_ZLIB
|
#ifndef DISABLE_ZLIB
|
||||||
/* TODO: add a commandline flag. Currently this is on by default if compression
|
/* TODO: add a commandline flag. Currently this is on by default if compression
|
||||||
@ -70,7 +71,6 @@ typedef struct svr_runopts {
|
|||||||
char * bannerfile;
|
char * bannerfile;
|
||||||
|
|
||||||
int forkbg;
|
int forkbg;
|
||||||
int usingsyslog;
|
|
||||||
|
|
||||||
/* ports and addresses are arrays of the portcount
|
/* ports and addresses are arrays of the portcount
|
||||||
listening ports. strings are malloced. */
|
listening ports. strings are malloced. */
|
||||||
|
@ -145,7 +145,7 @@ void main_noinetd() {
|
|||||||
if (svr_opts.forkbg) {
|
if (svr_opts.forkbg) {
|
||||||
int closefds = 0;
|
int closefds = 0;
|
||||||
#ifndef DEBUG_TRACE
|
#ifndef DEBUG_TRACE
|
||||||
if (!svr_opts.usingsyslog) {
|
if (!opts.usingsyslog) {
|
||||||
closefds = 1;
|
closefds = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -367,8 +367,8 @@ static void commonsetup() {
|
|||||||
|
|
||||||
struct sigaction sa_chld;
|
struct sigaction sa_chld;
|
||||||
#ifndef DISABLE_SYSLOG
|
#ifndef DISABLE_SYSLOG
|
||||||
if (svr_opts.usingsyslog) {
|
if (opts.usingsyslog) {
|
||||||
startsyslog();
|
startsyslog(PROGNAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void svr_getopts(int argc, char ** argv) {
|
|||||||
svr_opts.domotd = 1;
|
svr_opts.domotd = 1;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_SYSLOG
|
#ifndef DISABLE_SYSLOG
|
||||||
svr_opts.usingsyslog = 1;
|
opts.usingsyslog = 1;
|
||||||
#endif
|
#endif
|
||||||
opts.recv_window = DEFAULT_RECV_WINDOW;
|
opts.recv_window = DEFAULT_RECV_WINDOW;
|
||||||
opts.keepalive_secs = DEFAULT_KEEPALIVE;
|
opts.keepalive_secs = DEFAULT_KEEPALIVE;
|
||||||
@ -189,7 +189,7 @@ void svr_getopts(int argc, char ** argv) {
|
|||||||
break;
|
break;
|
||||||
#ifndef DISABLE_SYSLOG
|
#ifndef DISABLE_SYSLOG
|
||||||
case 'E':
|
case 'E':
|
||||||
svr_opts.usingsyslog = 0;
|
opts.usingsyslog = 0;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SVR_LOCALTCPFWD
|
#ifdef ENABLE_SVR_LOCALTCPFWD
|
||||||
|
@ -204,7 +204,7 @@ void svr_dropbear_log(int priority, const char* format, va_list param) {
|
|||||||
vsnprintf(printbuf, sizeof(printbuf), format, param);
|
vsnprintf(printbuf, sizeof(printbuf), format, param);
|
||||||
|
|
||||||
#ifndef DISABLE_SYSLOG
|
#ifndef DISABLE_SYSLOG
|
||||||
if (svr_opts.usingsyslog) {
|
if (opts.usingsyslog) {
|
||||||
syslog(priority, "%s", printbuf);
|
syslog(priority, "%s", printbuf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -215,7 +215,7 @@ void svr_dropbear_log(int priority, const char* format, va_list param) {
|
|||||||
havetrace = debug_trace;
|
havetrace = debug_trace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!svr_opts.usingsyslog || havetrace)
|
if (!opts.usingsyslog || havetrace)
|
||||||
{
|
{
|
||||||
struct tm * local_tm = NULL;
|
struct tm * local_tm = NULL;
|
||||||
timesec = time(NULL);
|
timesec = time(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user