Skip to content

Commit

Permalink
[multiple] use log_warn() for config warnings (#3239)
Browse files Browse the repository at this point in the history
use log_warn() for config warnings instead of log_error()

(behavior change)

This is a behavior change *only* if using syslog() for error logging.
Previously all error log syslogging was sent to syslog() as LOG_ERR.

x-ref:
  "syslog level set to error for messages that are not errors"
  https://redmine.lighttpd.net/issues/3239
  • Loading branch information
gstrauss committed Jan 11, 2024
1 parent 464b191 commit ac7dfe7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/configfile-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ int config_plugin_values_init(server * const srv, void *p_d, const config_plugin

if (cpk[i].scope == T_CONFIG_SCOPE_SERVER)
/* server scope options should be set only in server scope */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"DEPRECATED: do not set server options in conditionals, "
"variable: %s", cpk[i].k);
if (cpk[i].scope == T_CONFIG_SCOPE_SOCKET
&& (dc->comp!=COMP_SERVER_SOCKET || dc->cond!=CONFIG_COND_EQ))
/* socket options should be set in socket or global scope */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"WARNING: %s must be in global scope or $SERVER[\"socket\"] "
"with '==', or else is ignored", cpk[i].k);
}
Expand Down
14 changes: 7 additions & 7 deletions src/configfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static void config_warn_openssl_module (server *srv) {
if (0 == strncmp(du->key.ptr, "ssl.", sizeof("ssl.")-1)) {
/* mod_openssl should be loaded after mod_extforward */
array_insert_value(srv->srvconf.modules, CONST_STR_LEN("mod_openssl"));
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"Warning: please add \"mod_openssl\" to server.modules list "
"in lighttpd.conf. A future release of lighttpd 1.4.x "
"*will not* automatically load mod_openssl and lighttpd "
Expand Down Expand Up @@ -384,7 +384,7 @@ static void config_warn_authn_module (server *srv, const char *module, uint32_t
buffer_copy_string_len(tb, CONST_STR_LEN("mod_authn_"));
buffer_append_string_len(tb, module, len);
array_insert_value(srv->srvconf.modules, BUF_PTR_LEN(tb));
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"Warning: please add \"mod_authn_%s\" to server.modules list "
"in lighttpd.conf. A future release of lighttpd 1.4.x will "
"not automatically load mod_authn_%s and lighttpd will fail "
Expand Down Expand Up @@ -428,7 +428,7 @@ static void config_compat_module_load (server *srv) {
if (!contains_mod_auth) {
contains_mod_auth = 1;
if (dyn_name)
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"Warning: mod_auth should be listed in server.modules"
" before dynamic backends such as %s", dyn_name);
}
Expand Down Expand Up @@ -464,7 +464,7 @@ static void config_compat_module_load (server *srv) {
if (NULL == dyn_name)
dyn_name = m->ptr;
if (!append_mod_staticfile)
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"Warning: %s should be listed in server.modules"
" before mod_staticfile", m->ptr);
}
Expand Down Expand Up @@ -1255,7 +1255,7 @@ static int config_insert(server *srv) {
#ifndef HAVE_LSTAT
#ifndef _WIN32
if (0 == cpv->v.u)
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"Your system lacks lstat(). "
"We can not differentiate symlinks from files. "
"Please remove server.follow-symlink from your config.");
Expand Down Expand Up @@ -1398,7 +1398,7 @@ int config_finalize(server *srv, const buffer *default_server_tag) {

if (!array_get_element_klen(srv->srvconf.config_touched,
BUF_PTR_LEN(k)))
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"WARNING: unknown config-key: %s (ignored)", k->ptr);
}
}
Expand Down Expand Up @@ -1784,7 +1784,7 @@ static void config_log_error_open_syslog(server *srv, log_error_st *errh, const
}
}
if (-1 == facility) {
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"unrecognized server.syslog-facility: \"%s\"; "
"defaulting to \"daemon\" facility",
syslog_facility->ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/gw_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_p
else if (buffer_eq_slen(b, CONST_STR_LEN("authorizer")))
host_mode = GW_AUTHORIZER;
else
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"WARNING: unknown gw mode: %s "
"(ignored, mode set to responder)", b->ptr);
}
Expand Down
10 changes: 5 additions & 5 deletions src/mod_deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) {
for (; -1 != cpv->k_id; ++cpv) {
switch (cpv->k_id) {
case 9: /* compress.filetype */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"DEPRECATED: %s replaced with deflate.mimetypes",
cpk[cpv->k_id].k);
cpv->k_id = 0; /* deflate.mimetypes */
Expand All @@ -755,7 +755,7 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) {
if (0 == cpv->v.a->used) cpv->v.a = NULL;
break;
case 10:/* compress.allowed-encodings */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"DEPRECATED: %s replaced with deflate.allowed-encodings",
cpk[cpv->k_id].k);
cpv->k_id = 1; /* deflate.allowed-encodings */
Expand All @@ -765,7 +765,7 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) {
cpv->vtype = T_CONFIG_LOCAL;
break;
case 12:/* compress.max-filesize */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"DEPRECATED: %s replaced with deflate.max-compress-size",
cpk[cpv->k_id].k);
cpv->k_id = 2; /* deflate.max-compress-size */
Expand All @@ -786,7 +786,7 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) {
case 6: /* deflate.work-block-size */
break;
case 13:/* compress.max-loadavg */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"DEPRECATED: %s replaced with deflate.max-loadavg",
cpk[cpv->k_id].k);
cpv->k_id = 7; /* deflate.max-loadavg */
Expand All @@ -797,7 +797,7 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) {
: 0.0;
break;
case 11:/* compress.cache-dir */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"DEPRECATED: %s replaced with deflate.cache-dir",
cpk[cpv->k_id].k);
cpv->k_id = 8; /* deflate.cache-dir */
Expand Down
4 changes: 2 additions & 2 deletions src/mod_setenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ static void mod_setenv_prep_ext (const array * const ac) {
* invalid in HTTP/2 and in updated HTTP/1.1 specs)*/
s = ds->value.ptr;
if (NULL != strchr(s, '\r') || NULL != strchr(s, '\n')) {
log_error(NULL, __FILE__, __LINE__,
log_warn(NULL, __FILE__, __LINE__,
"WARNING: setenv.*-header contains CR and/or NL (invalid): "
"%s: %s", ds->key.ptr, s);
log_error(NULL, __FILE__, __LINE__,
log_warn(NULL, __FILE__, __LINE__,
"Use mod_magnet for finer control of request, response headers.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mod_wolfssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ network_init_ssl (server *srv, plugin_config_socket *s, plugin_data *p)
s->ssl_ctx, network_ssl_servername_callback);
wolfSSL_CTX_set_servername_arg(s->ssl_ctx, srv);
#else
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"SSL: WARNING: SNI callbacks *crippled* in wolfSSL library build");
UNUSED(network_ssl_servername_callback);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ static int network_server_init(server *srv, const network_socket_config *s, buff

host = host_token->ptr;
if ((use_ipv6 && (*host == '\0' || *host == ':')) || (host[0] == '[' && host[1] == ']')) {
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"warning: please use server.use-ipv6 only for hostnames, "
"not without server.bind / empty address; your config will "
"break if the kernel default for IPV6_V6ONLY changes");
Expand All @@ -432,7 +432,7 @@ static int network_server_init(server *srv, const network_socket_config *s, buff
if (s->set_v6only) {
set_v6only = 1;
} else {
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"warning: server.set-v6only will be removed soon, "
"update your config to have different sockets for ipv4 and ipv6");
}
Expand Down

0 comments on commit ac7dfe7

Please sign in to comment.