# HG changeset patch # User Konstantin Tokarev # Date 1448996134 -10800 # Node ID bf626d259eb1e1f6009cd4e997091b4255e01abe # Parent 6ecc133fb2eefa82efc1fcc69fb076d8d12b0fd6 Support syslog logging in dbclient. diff -r 6ecc133fb2ee -r bf626d259eb1 cli-main.c --- a/cli-main.c Tue Dec 01 21:54:03 2015 +0300 +++ b/cli-main.c Tue Dec 01 21:55:34 2015 +0300 @@ -60,6 +60,12 @@ cli_getopts(argc, argv); +#ifndef DISABLE_SYSLOG + if (opts.usingsyslog) { + startsyslog("dbclient"); + } +#endif + TRACE(("user='%s' host='%s' port='%s'", cli_opts.username, cli_opts.remotehost, cli_opts.remoteport)) @@ -118,13 +124,19 @@ exit(exitcode); } -static void cli_dropbear_log(int UNUSED(priority), +static void cli_dropbear_log(int priority, const char* format, va_list param) { char printbuf[1024]; 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); fflush(stderr); } diff -r 6ecc133fb2ee -r bf626d259eb1 cli-runopts.c --- a/cli-runopts.c Tue Dec 01 21:54:03 2015 +0300 +++ b/cli-runopts.c Tue Dec 01 21:55:34 2015 +0300 @@ -864,6 +864,9 @@ #ifdef ENABLE_CLI_ANYTCPFWD "\tExitOnForwardFailure\n" #endif +#ifndef DISABLE_SYSLOG + "\tUseSyslog\n" +#endif ); exit(EXIT_SUCCESS); } @@ -875,5 +878,12 @@ } #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); } diff -r 6ecc133fb2ee -r bf626d259eb1 cli-session.c --- a/cli-session.c Tue Dec 01 21:54:03 2015 +0300 +++ b/cli-session.c Tue Dec 01 21:55:34 2015 +0300 @@ -269,6 +269,11 @@ return; case USERAUTH_SUCCESS_RCVD: +#ifndef DISABLE_SYSLOG + if (opts.usingsyslog) { + dropbear_log(LOG_INFO, "Authentication succeeded."); + } +#endif #ifdef DROPBEAR_NONE_CIPHER if (cli_ses.cipher_none_after_auth) diff -r 6ecc133fb2ee -r bf626d259eb1 dbclient.1 --- a/dbclient.1 Tue Dec 01 21:54:03 2015 +0300 +++ b/dbclient.1 Tue Dec 01 21:55:34 2015 +0300 @@ -133,12 +133,14 @@ For full details of the options listed below, and their possible values, see ssh_config(5). -For now only following options have been implemented: -.RS +For now following options have been implemented: .RS .TP -ExitOnForwardFailure -.RE +.B ExitOnForwardFailure +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 .TP .B \-s