Support syslog logging in dbclient.

This commit is contained in:
Konstantin Tokarev 2015-12-01 21:55:34 +03:00
parent c59827334c
commit 3cb278c35c
4 changed files with 34 additions and 5 deletions

View File

@ -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);
} }

View File

@ -863,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);
@ -875,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);
} }

View File

@ -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)

View File

@ -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