lighttpd 1.4.x https://www.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2334 lines
76 KiB

#include "first.h"
#include "base.h"
#include "burl.h"
#include "fdevent.h"
#include "http_etag.h"
#include "keyvalue.h"
#include "log.h"
#include "stream.h"
#include "configparser.h"
#include "configfile.h"
#include "plugin.h"
#include "stat_cache.h"
#include "sys-crypto.h"
#include <sys/stat.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <glob.h>
#ifdef HAVE_SYSLOG_H
# include <syslog.h>
#endif
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
typedef struct {
PLUGIN_DATA;
request_config defaults;
} config_data_base;
static void config_free_config(void * const p_d) {
plugin_data_base * const p = p_d;
if (NULL == p) return;
if (NULL == p->cvlist) { free(p); return; }
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0];
for (; -1 != cpv->k_id; ++cpv) {
switch (cpv->k_id) {
case 18:/* server.kbytes-per-second */
if (cpv->vtype == T_CONFIG_LOCAL) free(cpv->v.v);
break;
default:
break;
}
}
}
free(p->cvlist);
free(p);
}
void config_reset_config_bytes_sec(void * const p_d) {
plugin_data_base * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0];
for (; -1 != cpv->k_id; ++cpv) {
switch (cpv->k_id) {
case 18:/* server.kbytes-per-second */
if (cpv->vtype == T_CONFIG_LOCAL) ((off_t *)cpv->v.v)[0] = 0;
break;
default:
break;
}
}
}
}
static void config_merge_config_cpv(request_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* server.document-root */
pconf->document_root = cpv->v.b;
break;
case 1: /* server.name */
pconf->server_name = cpv->v.b;
break;
case 2: /* server.tag */
pconf->server_tag = cpv->v.b;
break;
case 3: /* server.max-request-size */
pconf->max_request_size = cpv->v.u;
break;
case 4: /* server.max-keep-alive-requests */
pconf->max_keep_alive_requests = cpv->v.shrt;
break;
case 5: /* server.max-keep-alive-idle */
pconf->max_keep_alive_idle = cpv->v.shrt;
break;
case 6: /* server.max-read-idle */
pconf->max_read_idle = cpv->v.shrt;
break;
case 7: /* server.max-write-idle */
pconf->max_write_idle = cpv->v.shrt;
break;
case 8: /* server.errorfile-prefix */
pconf->errorfile_prefix = cpv->v.b;
break;
case 9: /* server.error-handler */
pconf->error_handler = cpv->v.b;
break;
case 10:/* server.error-handler-404 */
pconf->error_handler_404 = cpv->v.b;
break;
case 11:/* server.error-intercept */
pconf->error_intercept = (0 != cpv->v.u);
break;
case 12:/* server.force-lowercase-filenames */
pconf->force_lowercase_filenames = (0 != cpv->v.u);
break;
case 13:/* server.follow-symlink */
pconf->follow_symlink = (0 != cpv->v.u);
break;
case 14:/* server.protocol-http11 */
pconf->allow_http11 = (0 != cpv->v.u);
break;
case 15:/* server.range-requests */
pconf->range_requests = (0 != cpv->v.u);
break;
case 16:/* server.stream-request-body */
pconf->stream_request_body = cpv->v.shrt;
break;
case 17:/* server.stream-response-body */
pconf->stream_response_body = cpv->v.shrt;
break;
case 18:/* server.kbytes-per-second */
pconf->global_bytes_per_second = (unsigned int)((off_t *)cpv->v.v)[1];
pconf->global_bytes_per_second_cnt_ptr = cpv->v.v;
break;
case 19:/* connection.kbytes-per-second */
pconf->bytes_per_second = (unsigned int)cpv->v.shrt << 10;/* (*=1024) */
break;
case 20:/* mimetype.assign */
pconf->mimetypes = cpv->v.a;
break;
case 21:/* mimetype.use-xattr */
pconf->use_xattr = (0 != cpv->v.u);
break;
case 22:/* etag.use-inode */
cpv->v.u
? (pconf->etag_flags |= ETAG_USE_INODE)
: (pconf->etag_flags &= ~ETAG_USE_INODE);
break;
case 23:/* etag.use-mtime */
cpv->v.u
? (pconf->etag_flags |= ETAG_USE_MTIME)
: (pconf->etag_flags &= ~ETAG_USE_MTIME);
break;
case 24:/* etag.use-size */
cpv->v.u
? (pconf->etag_flags |= ETAG_USE_SIZE)
: (pconf->etag_flags &= ~ETAG_USE_SIZE);
break;
case 25:/* debug.log-condition-handling */
pconf->log_condition_handling = (0 != cpv->v.u);
break;
case 26:/* debug.log-file-not-found */
pconf->log_file_not_found = (0 != cpv->v.u);
break;
case 27:/* debug.log-request-handling */
pconf->log_request_handling = (0 != cpv->v.u);
break;
case 28:/* debug.log-request-header */
pconf->log_request_header = (0 != cpv->v.u);
break;
case 29:/* debug.log-response-header */
pconf->log_response_header = (0 != cpv->v.u);
break;
case 30:/* debug.log-timeouts */
pconf->log_timeouts = (0 != cpv->v.u);
break;
case 31: /* server.errorlog */
if (cpv->vtype == T_CONFIG_LOCAL) pconf->errh = cpv->v.v;
break;
case 32:/* server.breakagelog */
if (cpv->vtype == T_CONFIG_LOCAL) pconf->serrh = cpv->v.v;
break;
default:/* should not happen */
return;
}
}
static void config_merge_config(request_config * const pconf, const config_plugin_value_t *cpv) {
do {
config_merge_config_cpv(pconf, cpv);
} while ((++cpv)->k_id != -1);
}
void config_patch_config(request_st * const r) {
config_data_base * const p = r->con->config_data_base;
/* performed by config_reset_config() */
/*memcpy(&r->conf, &p->defaults, sizeof(request_config));*/
for (int i = 1, used = p->nconfig; i < used; ++i) {
if (config_check_cond(r, (uint32_t)p->cvlist[i].k_id))
config_merge_config(&r->conf, p->cvlist + p->cvlist[i].v.u2[0]);
}
}
void config_reset_config(request_st * const r) {
/* initialize request_config (r->conf) from top-level request_config */
config_data_base * const p = r->con->config_data_base;
r->server_name = p->defaults.server_name;
memcpy(&r->conf, &p->defaults, sizeof(request_config));
}
static int config_burl_normalize_cond (server *srv) {
buffer * const tb = srv->tmp_buf;
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
data_config * const config =(data_config *)srv->config_context->data[i];
if (COMP_HTTP_QUERY_STRING != config->comp) continue;
switch(config->cond) {
case CONFIG_COND_NE:
case CONFIG_COND_EQ:
/* (can use this routine as long as it does not perform
* any regex-specific normalization of first arg) */
pcre_keyvalue_burl_normalize_key(&config->string, tb);
break;
case CONFIG_COND_NOMATCH:
case CONFIG_COND_MATCH:
pcre_keyvalue_burl_normalize_key(&config->string, tb);
if (!data_config_pcre_compile(config)) return 0;
break;
default:
break;
}
}
return 1;
}
#ifdef USE_OPENSSL_CRYPTO
static void config_warn_openssl_module (server *srv) {
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
const data_config *config = (data_config const*)srv->config_context->data[i];
for (uint32_t j = 0; j < config->value->used; ++j) {
data_unset *du = config->value->data[j];
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__,
"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 "
"*will not* use SSL/TLS where your lighttpd.conf contains "
"ssl.* directives");
return;
}
}
}
}
#endif
static void config_check_module_duplicates (server *srv) {
int dup = 0;
data_string ** const data = (data_string **)srv->srvconf.modules->data;
const uint32_t used = srv->srvconf.modules->used;
for (uint32_t i = 0; i < used; ++i) {
const buffer * const m = &data[i]->value;
for (uint32_t j = i+1; j < used; ++j) {
if (buffer_is_equal(m, &data[j]->value)) {
++dup;
break;
}
}
}
if (!dup) return;
array * const modules = array_init(used - dup);
for (uint32_t i = 0; i < used; ++i) {
const buffer * const m = &data[i]->value;
uint32_t j;
for (j = 0; j < modules->used; ++j) {
buffer *n = &((data_string *)modules->data[j])->value;
if (buffer_is_equal(m, n)) break; /* duplicate */
}
if (j == modules->used)
array_insert_value(modules, CONST_BUF_LEN(m));
}
array_free(srv->srvconf.modules);
srv->srvconf.modules = modules;
}
static const char * config_has_opt_and_value (server * const srv, const char * const opt, const uint32_t olen, const char * const v, const uint32_t vlen) {
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
const data_config * const config =
(data_config const *)srv->config_context->data[i];
const data_string * const ds =
(data_string *)array_get_element_klen(config->value, opt, olen);
if (NULL != ds && ds->type == TYPE_STRING
&& buffer_eq_slen(&ds->value, v, vlen))
return v;
}
return NULL;
}
static void config_warn_authn_module (server *srv, const char *module, uint32_t len, const char *v) {
buffer * const tb = srv->tmp_buf;
buffer_copy_string_len(tb, CONST_STR_LEN("mod_authn_"));
buffer_append_string_len(tb, module, len);
array_insert_value(srv->srvconf.modules, CONST_BUF_LEN(tb));
log_error(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 "
"to start up since your lighttpd.conf uses auth.backend = \"%s\".",
module, module, v);
}
static void config_compat_module_load (server *srv) {
int prepend_mod_indexfile = 1;
int append_mod_dirlisting = 1;
int append_mod_staticfile = 1;
int append_mod_authn_file = 1;
int append_mod_authn_ldap = 1;
int append_mod_authn_mysql = 1;
int append_mod_openssl = 1;
int contains_mod_auth = 0;
for (uint32_t i = 0; i < srv->srvconf.modules->used; ++i) {
buffer *m = &((data_string *)srv->srvconf.modules->data[i])->value;
if (buffer_eq_slen(m, CONST_STR_LEN("mod_indexfile")))
prepend_mod_indexfile = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_staticfile")))
append_mod_staticfile = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_dirlisting")))
append_mod_dirlisting = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_gnutls")))
append_mod_openssl = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_mbedtls")))
append_mod_openssl = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_nss")))
append_mod_openssl = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_openssl")))
append_mod_openssl = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_wolfssl")))
append_mod_openssl = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_authn_file")))
append_mod_authn_file = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_authn_ldap")))
append_mod_authn_ldap = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_authn_mysql")))
append_mod_authn_mysql = 0;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_auth")))
contains_mod_auth = 1;
if (0 == prepend_mod_indexfile &&
0 == append_mod_dirlisting &&
0 == append_mod_staticfile &&
0 == append_mod_openssl &&
0 == append_mod_authn_file &&
0 == append_mod_authn_ldap &&
0 == append_mod_authn_mysql &&
1 == contains_mod_auth) {
break;
}
}
/* prepend default modules */
if (prepend_mod_indexfile) {
/* mod_indexfile has to be loaded before mod_fastcgi and friends */
array *modules = array_init(srv->srvconf.modules->used+4);
array_insert_value(modules, CONST_STR_LEN("mod_indexfile"));
for (uint32_t i = 0; i < srv->srvconf.modules->used; ++i) {
data_string *ds = (data_string *)srv->srvconf.modules->data[i];
array_insert_value(modules, CONST_BUF_LEN(&ds->value));
}
array_free(srv->srvconf.modules);
srv->srvconf.modules = modules;
}
/* append default modules */
if (append_mod_dirlisting) {
array_insert_value(srv->srvconf.modules, CONST_STR_LEN("mod_dirlisting"));
}
if (append_mod_staticfile) {
array_insert_value(srv->srvconf.modules, CONST_STR_LEN("mod_staticfile"));
}
if (append_mod_openssl) {
#ifdef USE_OPENSSL_CRYPTO
config_warn_openssl_module(srv);
#endif
}
/* mod_auth.c,http_auth.c auth backends were split into separate modules
* Automatically load auth backend modules for compatibility with
* existing lighttpd 1.4.x configs */
if (contains_mod_auth) {
if (append_mod_authn_file) {
const char *v;
if ( (v=config_has_opt_and_value(srv,CONST_STR_LEN("auth.backend"),
CONST_STR_LEN("htdigest")))
||(v=config_has_opt_and_value(srv,CONST_STR_LEN("auth.backend"),
CONST_STR_LEN("htpasswd")))
||(v=config_has_opt_and_value(srv,CONST_STR_LEN("auth.backend"),
CONST_STR_LEN("plain"))))
config_warn_authn_module(srv, CONST_STR_LEN("file"), v);
}
if (append_mod_authn_ldap) {
#if defined(HAVE_LDAP_H) && defined(HAVE_LBER_H) && defined(HAVE_LIBLDAP) && defined(HAVE_LIBLBER)
if (config_has_opt_and_value(srv, CONST_STR_LEN("auth.backend"),
CONST_STR_LEN("ldap")))
config_warn_authn_module(srv, CONST_STR_LEN("ldap"), "ldap");
#endif
}
if (append_mod_authn_mysql) {
#if defined(HAVE_MYSQL)
if (config_has_opt_and_value(srv, CONST_STR_LEN("auth.backend"),
CONST_STR_LEN("mysql")))
config_warn_authn_module(srv, CONST_STR_LEN("mysql"), "mysql");
#endif
}
}
}
static void config_deprecate_module_compress (server *srv) {
int mod_compress_idx = -1;
int mod_deflate_idx = -1;
for (uint32_t i = 0; i < srv->srvconf.modules->used; ++i) {
buffer *m = &((data_string *)srv->srvconf.modules->data[i])->value;
if (buffer_eq_slen(m, CONST_STR_LEN("mod_compress")))
mod_compress_idx = (int)i;
else if (buffer_eq_slen(m, CONST_STR_LEN("mod_deflate")))
mod_deflate_idx = (int)i;
}
if (mod_compress_idx < 0) return;
int has_compress_directive = 0;
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
const data_config *config =
(data_config const *)srv->config_context->data[i];
for (uint32_t j = 0; j < config->value->used; ++j) {
buffer *k = &config->value->data[j]->key;
if (0 == strncmp(k->ptr, "compress.", sizeof("compress.")-1)) {
has_compress_directive = 1;
break;
}
}
if (has_compress_directive) {
log_error(srv->errh, __FILE__, __LINE__,
"Warning: \"mod_compress\" is DEPRECATED and has been replaced "
"with \"mod_deflate\". A future release of lighttpd 1.4.x will "
"not contain mod_compress and lighttpd may fail to start up");
break;
}
}
if (mod_deflate_idx >= 0 || !has_compress_directive) {
/* create new modules value list without mod_compress */
array *a = array_init(srv->srvconf.modules->used-1);
for (uint32_t i = 0; i < srv->srvconf.modules->used; ++i) {
buffer *m = &((data_string *)srv->srvconf.modules->data[i])->value;
if (buffer_eq_slen(m, CONST_STR_LEN("mod_compress")))
continue;
array_insert_value(a, CONST_BUF_LEN(m));
}
array_free(srv->srvconf.modules);
srv->srvconf.modules = a;
}
else {
/* replace "mod_compress" value with "mod_deflate" value */
buffer *m = &((data_string *)srv->srvconf.modules->data[mod_compress_idx])->value;
buffer_copy_string_len(m, CONST_STR_LEN("mod_deflate"));
}
}
static int config_http_parseopts (server *srv, const array *a) {
unsigned short int opts = srv->srvconf.http_url_normalize;
unsigned short int decode_2f = 1;
int rc = 1;
for (size_t i = 0; i < a->used; ++i) {
const data_string * const ds = (const data_string *)a->data[i];
const buffer *k = &ds->key;
unsigned short int opt;
int val = config_plugin_value_tobool((data_unset *)ds, 2);
if (2 == val) {
log_error(srv->errh, __FILE__, __LINE__,
"unrecognized value for server.http-parseopts: "
"%s => %s (expect \"[enable|disable]\")", k->ptr, ds->value.ptr);
rc = 0;
}
if (buffer_eq_slen(k, CONST_STR_LEN("url-normalize")))
opt = HTTP_PARSEOPT_URL_NORMALIZE;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-normalize-unreserved")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_UNRESERVED;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-normalize-required")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-ctrls-reject")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-path-backslash-trans")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_BACKSLASH_TRANS;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-path-2f-decode")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-path-2f-reject")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-path-dotseg-remove")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-path-dotseg-reject")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT;
else if (buffer_eq_slen(k, CONST_STR_LEN("url-query-20-plus")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS;
else if (buffer_eq_slen(k, CONST_STR_LEN("header-strict"))) {
srv->srvconf.http_header_strict = val;
continue;
}
else if (buffer_eq_slen(k, CONST_STR_LEN("host-strict"))) {
srv->srvconf.http_host_strict = val;
continue;
}
else if (buffer_eq_slen(k, CONST_STR_LEN("host-normalize"))) {
srv->srvconf.http_host_normalize = val;
continue;
}
else if (buffer_eq_slen(k, CONST_STR_LEN("method-get-body"))) {
srv->srvconf.http_method_get_body = val;
continue;
}
else {
log_error(srv->errh, __FILE__, __LINE__,
"unrecognized key for server.http-parseopts: %s", k->ptr);
rc = 0;
continue;
}
if (val)
opts |= opt;
else {
opts &= ~opt;
if (opt == HTTP_PARSEOPT_URL_NORMALIZE) {
opts = 0;
break;
}
if (opt == HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE) {
decode_2f = 0;
}
}
}
if (opts != 0) {
opts |= HTTP_PARSEOPT_URL_NORMALIZE;
if ((opts & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
|HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT))
== (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
|HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
log_error(srv->errh, __FILE__, __LINE__,
"conflicting options in server.http-parseopts:"
"url-path-2f-decode, url-path-2f-reject");
rc = 0;
}
if ((opts & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
|HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT))
== (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
|HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
log_error(srv->errh, __FILE__, __LINE__,
"conflicting options in server.http-parseopts:"
"url-path-dotseg-remove, url-path-dotseg-reject");
rc = 0;
}
if (!(opts & (HTTP_PARSEOPT_URL_NORMALIZE_UNRESERVED
|HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED))) {
opts |= HTTP_PARSEOPT_URL_NORMALIZE_UNRESERVED;
if (decode_2f
&& !(opts & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT))
opts |= HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE;
}
}
srv->srvconf.http_url_normalize = opts;
return rc;
}
static int config_insert_srvconf(server *srv) {
static const config_plugin_keys_t cpk[] = {
{ CONST_STR_LEN("server.modules"),
T_CONFIG_ARRAY_VLIST,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.compat-module-load"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.systemd-socket-activation"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.port"),
T_CONFIG_SHORT,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.bind"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.network-backend"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.chroot"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.username"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.groupname"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.errorlog-placeholder-moved-to-config-insert"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.breakagelog-placeholder-moved-to-config-insert"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.errorlog-use-syslog"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.syslog-facility"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.core-files"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.event-handler"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.pid-file"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.max-worker"),
T_CONFIG_SHORT,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.max-fds"),
T_CONFIG_SHORT,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.max-connections"),
T_CONFIG_SHORT,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.max-request-field-size"),
T_CONFIG_INT,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.chunkqueue-chunk-sz"),
T_CONFIG_INT,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.upload-temp-file-size"),
T_CONFIG_INT,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.upload-dirs"),
T_CONFIG_ARRAY_VLIST,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.http-parseopts"),
T_CONFIG_ARRAY_KVSTRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.http-parseopt-header-strict"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.http-parseopt-host-strict"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.http-parseopt-host-normalize"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.reject-expect-100-with-417"), /*(ignored)*/
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.stat-cache-engine"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("mimetype.xattr-name"),
T_CONFIG_STRING,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("ssl.engine"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_CONNECTION }
,{ CONST_STR_LEN("debug.log-request-header-on-error"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("debug.log-state-handling"),
T_CONFIG_BOOL,
T_CONFIG_SCOPE_SERVER }
,{ CONST_STR_LEN("server.feature-flags"),
T_CONFIG_ARRAY_KVANY,
T_CONFIG_SCOPE_SERVER }
,{ NULL, 0,
T_CONFIG_UNSET,
T_CONFIG_SCOPE_UNSET }
};
int rc = 0;
plugin_data_base srvplug;
memset(&srvplug, 0, sizeof(srvplug));
plugin_data_base * const p = &srvplug;
if (!config_plugin_values_init(srv, p, cpk, "global"))
return HANDLER_ERROR;
int ssl_enabled = 0; /*(directive checked here only to set default port)*/
/* process and validate T_CONFIG_SCOPE_SERVER config directives */
if (p->cvlist[0].v.u2[1]) {
config_plugin_value_t *cpv = p->cvlist + p->cvlist[0].v.u2[0];
for (; -1 != cpv->k_id; ++cpv) {
switch (cpv->k_id) {
case 0: /* server.modules */
array_copy_array(srv->srvconf.modules, cpv->v.a);
break;
case 1: /* server.compat-module-load */
srv->srvconf.compat_module_load = (unsigned short)cpv->v.u;
break;
case 2: /* server.systemd-socket-activation */
srv->srvconf.systemd_socket_activation=(unsigned short)cpv->v.u;
break;
case 3: /* server.port */
srv->srvconf.port = cpv->v.shrt;
break;
case 4: /* server.bind */
srv->srvconf.bindhost = cpv->v.b;
break;
case 5: /* server.network-backend */
srv->srvconf.network_backend = cpv->v.b;
break;
case 6: /* server.chroot */
srv->srvconf.changeroot = cpv->v.b;
break;
case 7: /* server.username */
srv->srvconf.username = cpv->v.b;
break;
case 8: /* server.groupname */
srv->srvconf.groupname = cpv->v.b;
break;
case 9: /* server.errorlog */ /* moved to config_insert() */
/*srv->srvconf.errorlog_file = cpv->v.b;*/
break;
case 10:/* server.breakagelog */ /* moved to config_insert() */
/*srv->srvconf.breakagelog_file = cpv->v.b;*/
break;
case 11:/* server.errorlog-use-syslog */
srv->srvconf.errorlog_use_syslog = (unsigned short)cpv->v.u;
break;
case 12:/* server.syslog-facility */
srv->srvconf.syslog_facility = cpv->v.b;
break;
case 13:/* server.core-files */
srv->srvconf.enable_cores = (unsigned short)cpv->v.u;
break;
case 14:/* server.event-handler */
srv->srvconf.event_handler = cpv->v.b->ptr;
break;
case 15:/* server.pid-file */
*(const buffer **)&srv->srvconf.pid_file = cpv->v.b;
break;
case 16:/* server.max-worker */
srv->srvconf.max_worker = (unsigned short)cpv->v.u;
break;
case 17:/* server.max-fds */
srv->srvconf.max_fds = (unsigned short)cpv->v.u;
break;
case 18:/* server.max-connections */
srv->srvconf.max_conns = (unsigned short)cpv->v.u;
break;
case 19:/* server.max-request-field-size */
srv->srvconf.max_request_field_size = cpv->v.u;
break;
case 20:/* server.chunkqueue-chunk-sz */
chunkqueue_set_chunk_size(cpv->v.u);
break;
case 21:/* server.upload-temp-file-size */
srv->srvconf.upload_temp_file_size = cpv->v.u;
break;
case 22:/* server.upload-dirs */
array_copy_array(srv->srvconf.upload_tempdirs, cpv->v.a);
break;
case 23:/* server.http-parseopts */
if (!config_http_parseopts(srv, cpv->v.a))
rc = HANDLER_ERROR;
break;
case 24:/* server.http-parseopt-header-strict */
srv->srvconf.http_header_strict = (0 != cpv->v.u);
break;
case 25:/* server.http-parseopt-host-strict */
srv->srvconf.http_host_strict = (0 != cpv->v.u);
break;
case 26:/* server.http-parseopt-host-normalize */
srv->srvconf.http_host_normalize = (0 != cpv->v.u);
break;
case 27:/* server.reject-expect-100-with-417 *//*(ignored)*/
break;
case 28:/* server.stat-cache-engine */
if (0 != stat_cache_choose_engine(cpv->v.b, srv->errh))
rc = HANDLER_ERROR;
break;
case 29:/* mimetype.xattr-name */
stat_cache_xattrname(cpv->v.b->ptr);
break;
case 30:/* ssl.engine */
ssl_enabled = (0 != cpv->v.u);
#if !defined(USE_OPENSSL_CRYPTO) \
&& !defined(USE_MBEDTLS_CRYPTO) \
&& !defined(USE_NSS_CRYPTO) \
&& !defined(USE_GNUTLS_CRYPTO) \
&& !defined(USE_WOLFSSL_CRYPTO)
if (ssl_enabled) {
log_error(srv->errh, __FILE__, __LINE__,
"ssl support is missing; "
"recompile with e.g. --with-openssl");
rc = HANDLER_ERROR;
break;
}
#endif
break;
case 31:/* debug.log-request-header-on-error */