diff options
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/control.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/log.c | 17 | ||||
-rw-r--r-- | usr.sbin/relayd/proc.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/relay_udp.c | 7 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 5 | ||||
-rw-r--r-- | usr.sbin/relayd/ssl.c | 5 |
8 files changed, 28 insertions, 24 deletions
diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index 04bb2c853d4..85a6f65ab25 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.55 2017/01/09 14:04:31 krw Exp $ */ +/* $OpenBSD: control.c,v 1.56 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -387,7 +387,7 @@ control_dispatch_imsg(int fd, short event, void *arg) memcpy(imsg.data, &verbose, sizeof(verbose)); control_imsg_forward(ps, &imsg); - log_verbose(verbose); + log_setverbose(verbose); break; default: log_debug("%s: error handling imsg %d", diff --git a/usr.sbin/relayd/log.c b/usr.sbin/relayd/log.c index 5d7c9bbccba..03b23bec130 100644 --- a/usr.sbin/relayd/log.c +++ b/usr.sbin/relayd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.33 2017/01/08 20:31:03 reyk Exp $ */ +/* $OpenBSD: log.c,v 1.34 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -24,13 +24,14 @@ #include <errno.h> #include <time.h> -int debug; -int verbose; +static int debug; +static int verbose; const char *log_procname; void log_init(int, int); void log_procinit(const char *); -void log_verbose(int); +void log_setverbose(int); +int log_getverbose(void); void log_warn(const char *, ...) __attribute__((__format__ (printf, 1, 2))); void log_warnx(const char *, ...) @@ -71,11 +72,17 @@ log_procinit(const char *procname) } void -log_verbose(int v) +log_setverbose(int v) { verbose = v; } +int +log_getverbose(void) +{ + return (verbose); +} + void logit(int pri, const char *fmt, ...) { diff --git a/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c index 67550afbd03..3f135d3e360 100644 --- a/usr.sbin/relayd/proc.c +++ b/usr.sbin/relayd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.37 2016/11/24 21:01:18 reyk Exp $ */ +/* $OpenBSD: proc.c,v 1.38 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -662,7 +662,7 @@ proc_dispatch(int fd, short event, void *arg) case IMSG_CTL_VERBOSE: IMSG_SIZE_CHECK(&imsg, &verbose); memcpy(&verbose, imsg.data, sizeof(verbose)); - log_verbose(verbose); + log_setverbose(verbose); break; case IMSG_CTL_PROCFD: IMSG_SIZE_CHECK(&imsg, &pf); diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index e0a0a87483c..116a01d61cb 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.217 2016/11/10 13:21:58 jca Exp $ */ +/* $OpenBSD: relay.c,v 1.218 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -287,11 +287,9 @@ relay_protodebug(struct relay *rlay) int relay_privinit(struct relay *rlay) { - extern int debug; - log_debug("%s: adding relay %s", __func__, rlay->rl_conf.name); - if (debug) + if (log_getverbose() > 1) relay_protodebug(rlay); switch (rlay->rl_proto->type) { diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c index 754bdf9f564..2589e51de79 100644 --- a/usr.sbin/relayd/relay_udp.c +++ b/usr.sbin/relayd/relay_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_udp.c,v 1.44 2016/11/10 13:21:58 jca Exp $ */ +/* $OpenBSD: relay_udp.c,v 1.45 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org> @@ -39,7 +39,6 @@ extern volatile sig_atomic_t relay_sessions; extern objid_t relay_conid; -extern int debug; static struct relayd *env = NULL; struct shuffle relay_shuffle; @@ -467,7 +466,7 @@ relay_dns_request(struct rsession *con) if (buf == NULL || priv == NULL || len < 1) return (-1); - if (debug) + if (log_getverbose() > 1) relay_dns_log(con, buf, len); getmonotime(&con->se_tv_start); @@ -522,7 +521,7 @@ relay_dns_result(struct rsession *con, u_int8_t *buf, size_t len) if (priv == NULL) fatalx("relay_dns_result: response to invalid session"); - if (debug) + if (log_getverbose() > 1) relay_dns_log(con, buf, len); /* diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index 39d4b35d28e..3a66500e60c 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.163 2016/11/24 21:01:18 reyk Exp $ */ +/* $OpenBSD: relayd.c,v 1.164 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2007 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -203,7 +203,7 @@ main(int argc, char *argv[]) ps->ps_csock.cs_name = RELAYD_SOCKET; log_init(debug, LOG_DAEMON); - log_verbose(verbose); + log_setverbose(verbose); if (env->sc_conf.opts & RELAYD_OPT_NOACTION) ps->ps_noaction = 1; diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 2c0246df99c..1a438bbc0c8 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.236 2016/11/24 21:01:18 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.237 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -1352,7 +1352,8 @@ u_int16_t shuffle_generate16(struct shuffle *); /* log.c */ void log_init(int, int); void log_procinit(const char *); -void log_verbose(int); +void log_setverbose(int); +int log_getverbose(void); void log_warn(const char *, ...) __attribute__((__format__ (printf, 1, 2))); void log_warnx(const char *, ...) diff --git a/usr.sbin/relayd/ssl.c b/usr.sbin/relayd/ssl.c index dbc5f4469c5..f5dad7e36f0 100644 --- a/usr.sbin/relayd/ssl.c +++ b/usr.sbin/relayd/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.30 2015/12/30 12:08:34 benno Exp $ */ +/* $OpenBSD: ssl.c,v 1.31 2017/01/09 14:49:21 reyk Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -225,9 +225,8 @@ ssl_error(const char *where, const char *what) { char errbuf[128]; unsigned long code; - extern int debug; - if (!debug) + if (log_getverbose() < 2) return; for (; (code = ERR_get_error()) != 0 ;) { ERR_error_string_n(code, errbuf, sizeof(errbuf)); |