if libevent dies it would be nice to have some kind of record of
why it decided that was a good idea. by default those messages go
nowhere.
this has tftp register a log callback for libevent to call. if
something goes wrong it should end up in the logs.
ok?
Index: tftpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/tftpd/tftpd.c,v
retrieving revision 1.34
diff -u -p -r1.34 tftpd.c
--- tftpd.c 14 Dec 2015 16:34:55 -0000 1.34
+++ tftpd.c 16 Dec 2015 01:08:55 -0000
@@ -189,6 +189,8 @@ int parse_options(struct tftp_client *,
struct opt_client *);
int validate_access(struct tftp_client *, const char *);
+void log_libevent(int, const char *);
+
struct tftp_client *
client_alloc(void);
void client_free(struct tftp_client *client);
@@ -361,6 +363,7 @@ main(int argc, char *argv[])
if (pledge("stdio rpath wpath cpath fattr dns inet", NULL) == -1)
err(1, "pledge");
+ event_set_log_callback(log_libevent);
event_init();
if (rewrite != NULL)
@@ -1625,3 +1628,30 @@ syslog_info(const char *fmt, ...)
va_end(ap);
}
+void
+log_libevent(int severity, const char *msg)
+{
+ const char *level = "msg";
+
+ switch (severity) {
+ case _EVENT_LOG_DEBUG:
+ if (!verbose)
+ return;
+ level = "debug";
+ break;
+ case _EVENT_LOG_MSG:
+ level = "msg";
+ break;
+ case _EVENT_LOG_WARN:
+ level = "warn";
+ break;
+ case _EVENT_LOG_ERR:
+ level = "err";
+ break;
+ default:
+ lerrx(1, "%s severity %d", __func__, severity);
+ return;
+ }
+
+ lwarnx("event %s: %s", level, msg);
+}