1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-09 22:38:01 -08:00

Stop accessing verbose and debug variables from log.c directly.

This replaces log_verbose() and "extern int verbose" with the two functions
log_setverbose() and log_getverbose().

Pointed out by benno@
OK krw@ eric@ gilles@ (OK gilles@ for the snmpd bits as well)
This commit is contained in:
reyk 2017-01-09 14:49:21 +00:00
parent 50a11db7cf
commit 871fc12c55
45 changed files with 196 additions and 145 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.23 2017/01/09 14:04:31 krw Exp $ */
/* $OpenBSD: control.c,v 1.24 2017/01/09 14:49:21 reyk Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@ -304,7 +304,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
IMSG_SIZE_CHECK(&imsg, &v);
memcpy(&v, imsg.data, sizeof(v));
log_verbose(v);
log_setverbose(v);
proc_forward_imsg(&env->sc_ps, &imsg, PROC_PARENT, -1);
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: iked.c,v 1.32 2017/01/03 17:51:38 reyk Exp $ */
/* $OpenBSD: iked.c,v 1.33 2017/01/09 14:49:21 reyk Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@ -140,7 +140,7 @@ main(int argc, char *argv[])
ps->ps_csock.cs_name = IKED_SOCKET;
log_init(debug, LOG_DAEMON);
log_verbose(verbose);
log_setverbose(verbose);
if (!debug && daemon(0, 0) == -1)
err(1, "failed to daemonize");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: iked.h,v 1.99 2017/01/03 17:51:38 reyk Exp $ */
/* $OpenBSD: iked.h,v 1.100 2017/01/09 14:49:21 reyk Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@ -963,7 +963,8 @@ void ibuf_zero(struct ibuf *);
/* 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 *, ...)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.10 2017/01/08 20:31:03 reyk Exp $ */
/* $OpenBSD: log.c,v 1.11 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, ...)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.29 2015/12/07 16:05:56 reyk Exp $ */
/* $OpenBSD: proc.c,v 1.30 2017/01/09 14:49:21 reyk Exp $ */
/*
* Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org>
@ -495,7 +495,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;
default:
log_warnx("%s: %s %d got invalid imsg %d peerid %d "

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.32 2016/09/26 16:55:21 jca Exp $ */
/* $OpenBSD: util.c,v 1.33 2017/01/09 14:49:21 reyk Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@ -35,10 +35,6 @@
#include "iked.h"
#include "ikev2.h"
/* log.c */
extern int debug;
extern int verbose;
int
socket_af(struct sockaddr *sa, in_port_t port)
{
@ -474,9 +470,8 @@ void
print_hex(uint8_t *buf, off_t offset, size_t length)
{
unsigned int i;
extern int verbose;
if (verbose < 3 || !length)
if (log_getverbose() < 3 || !length)
return;
for (i = 0; i < length; i++) {
@ -495,9 +490,8 @@ void
print_hexval(uint8_t *buf, off_t offset, size_t length)
{
unsigned int i;
extern int verbose;
if (verbose < 2 || !length)
if (log_getverbose() < 2 || !length)
return;
print_debug("0x");
@ -759,7 +753,7 @@ print_debug(const char *emsg, ...)
{
va_list ap;
if (debug && verbose > 2) {
if (log_getverbose() > 2) {
va_start(ap, emsg);
vfprintf(stderr, emsg, ap);
va_end(ap);
@ -771,7 +765,7 @@ print_verbose(const char *emsg, ...)
{
va_list ap;
if (verbose) {
if (log_getverbose()) {
va_start(ap, emsg);
vfprintf(stderr, emsg, ap);
va_end(ap);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.12 2017/01/09 14:04:31 krw Exp $ */
/* $OpenBSD: control.c,v 1.13 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -290,7 +290,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
memcpy(imsg.data, &verbose, sizeof(verbose));
control_imsg_forward(env->sc_ps, &imsg);
log_verbose(verbose);
log_setverbose(verbose);
break;
default:
log_debug("%s: error handling imsg %d",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: httpd.c,v 1.62 2016/09/28 12:01:04 reyk Exp $ */
/* $OpenBSD: httpd.c,v 1.63 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@ -191,7 +191,7 @@ main(int argc, char *argv[])
ps->ps_csock.cs_name = NULL;
log_init(debug, LOG_DAEMON);
log_verbose(verbose);
log_setverbose(verbose);
if (env->sc_opts & HTTPD_OPT_NOACTION)
ps->ps_noaction = 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: httpd.h,v 1.124 2016/11/17 14:52:48 jsing Exp $ */
/* $OpenBSD: httpd.h,v 1.125 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@ -685,7 +685,8 @@ extern struct httpd *httpd_env;
/* 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 *, ...)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.12 2017/01/08 20:31:03 reyk Exp $ */
/* $OpenBSD: log.c,v 1.13 2017/01/09 14:49:22 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, ...)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.34 2016/10/12 10:57:30 reyk Exp $ */
/* $OpenBSD: proc.c,v 1.35 2017/01/09 14:49:22 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);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: server.c,v 1.100 2016/11/17 14:58:37 jsing Exp $ */
/* $OpenBSD: server.c,v 1.101 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@ -1153,14 +1153,13 @@ server_log(struct client *clt, const char *msg)
struct server_config *srv_conf = clt->clt_srv_conf;
char *ptr = NULL, *vmsg = NULL;
int debug_cmd = -1;
extern int verbose;
switch (srv_conf->logformat) {
case LOG_FORMAT_CONNECTION:
debug_cmd = IMSG_LOG_ACCESS;
break;
default:
if (verbose > 1)
if (log_getverbose() > 1)
debug_cmd = IMSG_LOG_ERROR;
if (EVBUFFER_LENGTH(clt->clt_log)) {
while ((ptr =

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.15 2017/01/08 20:31:03 reyk Exp $ */
/* $OpenBSD: log.c,v 1.16 2017/01/09 14:49:22 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, ...)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.112 2016/12/01 16:24:48 mestre Exp $ */
/* $OpenBSD: ntpd.c,v 1.113 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -209,7 +209,7 @@ main(int argc, char *argv[])
reset_adjtime();
if (!lconf.settime) {
log_init(lconf.debug, LOG_DAEMON);
log_verbose(lconf.verbose);
log_setverbose(lconf.verbose);
if (!lconf.debug)
if (daemon(1, 0))
fatal("daemon");
@ -284,7 +284,7 @@ main(int argc, char *argv[])
lconf.settime = 0;
timeout = INFTIM;
log_init(lconf.debug, LOG_DAEMON);
log_verbose(lconf.verbose);
log_setverbose(lconf.verbose);
log_warnx("no reply received in time, skipping initial "
"time setting");
if (!lconf.debug)
@ -384,7 +384,7 @@ dispatch_imsg(struct ntpd_conf *lconf, int argc, char **argv)
if (!lconf->settime)
break;
log_init(lconf->debug, LOG_DAEMON);
log_verbose(lconf->verbose);
log_setverbose(lconf->verbose);
memcpy(&d, imsg.data, sizeof(d));
ntpd_settime(d);
/* daemonize now */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.133 2016/09/26 17:17:01 rzalamena Exp $ */
/* $OpenBSD: ntpd.h,v 1.134 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -408,7 +408,8 @@ void build_show_sensor(struct ctl_show_sensor *,
/* 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 *, ...)

View File

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

View File

@ -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, ...)
{

View File

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

View File

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

View File

@ -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);
/*

View File

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

View File

@ -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 *, ...)

View File

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

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.18 2017/01/09 09:53:23 reyk Exp $ */
/* $OpenBSD: log.c,v 1.19 2017/01/09 14:49:22 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, ...)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.h,v 1.6 2017/01/09 09:53:23 reyk Exp $ */
/* $OpenBSD: log.h,v 1.7 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2010 Gilles Chehade <gilles@poolp.org>
@ -21,7 +21,8 @@
/* 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 *, ...)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: scheduler.c,v 1.55 2016/09/08 12:06:43 eric Exp $ */
/* $OpenBSD: scheduler.c,v 1.56 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@ -306,7 +306,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg)
m_msg(&m, imsg);
m_get_int(&m, &v);
m_end(&m);
log_verbose(v);
log_setverbose(v);
return;
case IMSG_CTL_PROFILE:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.131 2017/01/09 09:53:23 reyk Exp $ */
/* $OpenBSD: util.c,v 1.132 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@ -812,5 +812,5 @@ log_trace_verbose(int v)
tracing = v;
/* Set debug logging in log.c */
log_verbose(v & TRACE_DEBUG ? 2 : foreground_log);
log_setverbose(v & TRACE_DEBUG ? 2 : foreground_log);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.40 2016/11/18 16:16:39 jca Exp $ */
/* $OpenBSD: control.c,v 1.41 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@ -331,7 +331,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
return control_close(c, "invalid size", &imsg);
memcpy(&v, imsg.data, sizeof(v));
log_verbose(v);
log_setverbose(v);
for (i = 0; i < PROC_MAX; i++) {
if (privsep_process == PROC_CONTROL)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.14 2017/01/08 20:31:03 reyk Exp $ */
/* $OpenBSD: log.c,v 1.15 2017/01/09 14:49:22 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, ...)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.21 2016/10/28 09:07:08 rzalamena Exp $ */
/* $OpenBSD: proc.c,v 1.22 2017/01/09 14:49:22 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);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: snmpd.c,v 1.34 2016/10/28 09:07:08 rzalamena Exp $ */
/* $OpenBSD: snmpd.c,v 1.35 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@ -158,6 +158,7 @@ main(int argc, char *argv[])
switch (c) {
case 'd':
debug++;
flags |= SNMPD_F_DEBUG;
break;
case 'D':
if (cmdline_symset(optarg) < 0)
@ -221,7 +222,7 @@ main(int argc, char *argv[])
errx(1, "unknown user %s", SNMPD_USER);
log_init(debug, LOG_DAEMON);
log_verbose(verbose);
log_setverbose(verbose);
gettimeofday(&env->sc_starttime, NULL);
env->sc_engine_boots = 0;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: snmpd.h,v 1.73 2016/11/18 16:16:39 jca Exp $ */
/* $OpenBSD: snmpd.h,v 1.74 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@ -560,7 +560,8 @@ struct usmuser {
struct snmpd {
u_int8_t sc_flags;
#define SNMPD_F_VERBOSE 0x01
#define SNMPD_F_NONAMES 0x02
#define SNMPD_F_DEBUG 0x02
#define SNMPD_F_NONAMES 0x04
const char *sc_confpath;
struct addresslist sc_addresses;
@ -617,7 +618,8 @@ int cmdline_symset(char *);
/* 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 *, ...)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: traphandler.c,v 1.7 2016/11/18 16:16:39 jca Exp $ */
/* $OpenBSD: traphandler.c,v 1.8 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2014 Bret Stephen Lambert <blambert@openbsd.org>
@ -294,6 +294,8 @@ traphandler_priv_recvmsg(struct privsep_proc *p, struct imsg *imsg)
int
traphandler_fork_handler(struct privsep_proc *p, struct imsg *imsg)
{
struct privsep *ps = p->p_ps;
struct snmpd *env = ps->ps_env;
char oidbuf[SNMP_MAX_OID_STRLEN];
struct sockaddr *sa;
char *buf;
@ -303,9 +305,10 @@ traphandler_fork_handler(struct privsep_proc *p, struct imsg *imsg)
struct ber_oid trapoid;
u_int uptime;
struct passwd *pw;
extern int debug;
int verbose;
pw = p->p_ps->ps_pw;
pw = ps->ps_pw;
verbose = log_getverbose();
if (setgroups(1, &pw->pw_gid) ||
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
@ -314,7 +317,8 @@ traphandler_fork_handler(struct privsep_proc *p, struct imsg *imsg)
closefrom(STDERR_FILENO + 1);
log_init(debug, LOG_DAEMON);
log_init((env->sc_flags & SNMPD_F_DEBUG) ? 1 : 0, LOG_DAEMON);
log_setverbose(verbose);
log_procinit(p->p_title);
n = IMSG_DATA_SIZE(imsg);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.6 2016/11/09 20:31:56 jca Exp $ */
/* $OpenBSD: util.c,v 1.7 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2014 Bret Stephen Lambert <blambert@openbsd.org>
*
@ -30,10 +30,6 @@
#include "snmp.h"
#include "snmpd.h"
/* log.c */
extern int debug;
extern int verbose;
/*
* Convert variable bindings from AgentX to SNMP dialect.
*/
@ -283,7 +279,7 @@ print_debug(const char *emsg, ...)
{
va_list ap;
if (debug && verbose > 2) {
if (log_getverbose() > 2) {
va_start(ap, emsg);
vfprintf(stderr, emsg, ap);
va_end(ap);
@ -295,7 +291,7 @@ print_verbose(const char *emsg, ...)
{
va_list ap;
if (verbose) {
if (log_getverbose()) {
va_start(ap, emsg);
vfprintf(stderr, emsg, ap);
va_end(ap);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.6 2017/01/09 14:04:31 krw Exp $ */
/* $OpenBSD: control.c,v 1.7 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2010-2016 Reyk Floeter <reyk@openbsd.org>
@ -361,7 +361,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
IMSG_SIZE_CHECK(&imsg, &v);
memcpy(&v, imsg.data, sizeof(v));
log_verbose(v);
log_setverbose(v);
proc_forward_imsg(&env->sc_ps, &imsg, PROC_PARENT, -1);
proc_forward_imsg(&env->sc_ps, &imsg, PROC_OFP, -1);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.3 2017/01/08 20:31:03 reyk Exp $ */
/* $OpenBSD: log.c,v 1.4 2017/01/09 14:49:22 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, ...)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.9 2016/11/16 15:32:42 rzalamena Exp $ */
/* $OpenBSD: proc.c,v 1.10 2017/01/09 14:49:22 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);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.h,v 1.5 2016/11/16 15:32:42 rzalamena Exp $ */
/* $OpenBSD: proc.h,v 1.6 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org>
@ -168,7 +168,8 @@ void control(struct privsep *, struct privsep_proc *);
/* 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 *, ...)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: switchd.c,v 1.14 2016/10/12 19:07:42 reyk Exp $ */
/* $OpenBSD: switchd.c,v 1.15 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
@ -175,7 +175,7 @@ main(int argc, char *argv[])
fatalx("unknown user " SWITCHD_USER);
log_init(debug, LOG_DAEMON);
log_verbose(verbose);
log_setverbose(verbose);
/* Configure the control socket */
ps->ps_csock.cs_name = SWITCHD_SOCKET;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.5 2016/11/15 09:05:14 reyk Exp $ */
/* $OpenBSD: util.c,v 1.6 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
@ -37,9 +37,6 @@
#include "switchd.h"
extern int debug;
extern int verbose;
void
socket_set_blockmode(int fd, enum blockmodes bm)
{
@ -313,7 +310,7 @@ print_debug(const char *emsg, ...)
{
va_list ap;
if (debug && verbose > 2) {
if (log_getverbose() > 2) {
va_start(ap, emsg);
vfprintf(stderr, emsg, ap);
va_end(ap);
@ -325,7 +322,7 @@ print_verbose(const char *emsg, ...)
{
va_list ap;
if (verbose) {
if (log_getverbose()) {
va_start(ap, emsg);
vfprintf(stderr, emsg, ap);
va_end(ap);
@ -336,9 +333,8 @@ void
print_hex(uint8_t *buf, off_t offset, size_t length)
{
unsigned int i;
extern int verbose;
if (verbose < 3 || !length)
if (log_getverbose() < 3 || !length)
return;
for (i = 0; i < length; i++) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.10 2017/01/09 14:04:31 krw Exp $ */
/* $OpenBSD: control.c,v 1.11 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org>
@ -350,7 +350,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
IMSG_SIZE_CHECK(&imsg, &v);
memcpy(&v, imsg.data, sizeof(v));
log_verbose(v);
log_setverbose(v);
proc_forward_imsg(ps, &imsg, PROC_PARENT, -1);
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.6 2016/11/24 21:39:45 reyk Exp $ */
/* $OpenBSD: log.c,v 1.7 2017/01/09 14:49:22 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, ...)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.11 2016/11/16 15:32:42 rzalamena Exp $ */
/* $OpenBSD: proc.c,v 1.12 2017/01/09 14:49:22 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);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.h,v 1.10 2016/11/16 15:32:42 rzalamena Exp $ */
/* $OpenBSD: proc.h,v 1.11 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org>
@ -198,7 +198,8 @@ void control_cleanup(struct control_sock *);
/* 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 *, ...)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: vmd.c,v 1.47 2016/12/14 21:17:25 reyk Exp $ */
/* $OpenBSD: vmd.c,v 1.48 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@ -421,7 +421,7 @@ main(int argc, char **argv)
env->vmd_conffile = conffile;
log_init(env->vmd_debug, LOG_DAEMON);
log_verbose(env->vmd_verbose);
log_setverbose(env->vmd_verbose);
if (env->vmd_noaction)
ps->ps_noaction = 1;