comparison cli-main.c @ 1212:bf626d259eb1

Support syslog logging in dbclient.
author Konstantin Tokarev <ktokarev@smartlabs.tv>
date Tue, 01 Dec 2015 21:55:34 +0300
parents fb58cf341951
children d058e15ea213
comparison
equal deleted inserted replaced
1211:6ecc133fb2ee 1212:bf626d259eb1
58 seedrandom(); 58 seedrandom();
59 crypto_init(); 59 crypto_init();
60 60
61 cli_getopts(argc, argv); 61 cli_getopts(argc, argv);
62 62
63 #ifndef DISABLE_SYSLOG
64 if (opts.usingsyslog) {
65 startsyslog("dbclient");
66 }
67 #endif
68
63 TRACE(("user='%s' host='%s' port='%s'", cli_opts.username, 69 TRACE(("user='%s' host='%s' port='%s'", cli_opts.username,
64 cli_opts.remotehost, cli_opts.remoteport)) 70 cli_opts.remotehost, cli_opts.remoteport))
65 71
66 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { 72 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
67 dropbear_exit("signal() error"); 73 dropbear_exit("signal() error");
116 122
117 dropbear_log(LOG_INFO, "%s", exitmsg);; 123 dropbear_log(LOG_INFO, "%s", exitmsg);;
118 exit(exitcode); 124 exit(exitcode);
119 } 125 }
120 126
121 static void cli_dropbear_log(int UNUSED(priority), 127 static void cli_dropbear_log(int priority,
122 const char* format, va_list param) { 128 const char* format, va_list param) {
123 129
124 char printbuf[1024]; 130 char printbuf[1024];
125 131
126 vsnprintf(printbuf, sizeof(printbuf), format, param); 132 vsnprintf(printbuf, sizeof(printbuf), format, param);
133
134 #ifndef DISABLE_SYSLOG
135 if (opts.usingsyslog) {
136 syslog(priority, "%s", printbuf);
137 }
138 #endif
127 139
128 fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf); 140 fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf);
129 fflush(stderr); 141 fflush(stderr);
130 } 142 }
131 143