Browse Source

[core] allow overriding prior config values (fixes #2799)

introduce ":=" config file syntax to replace previously set value

github: closes #78

x-ref:
  "allow overriding configuration values"
  https://redmine.lighttpd.net/issues/2799
  https://github.com/lighttpd/lighttpd1.4/pull/78
personal/stbuehler/mod-csrf
Philip Prindeville 5 years ago
committed by Glenn Strauss
parent
commit
367e62c1c2
  1. 8
      src/configfile.c
  2. 17
      src/configparser.y

8
src/configfile.c

@ -967,6 +967,14 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
}
break;
case ':':
if (t->input[t->offset+1] == '=') {
t->offset += 2;
tid = TK_FORCE_ASSIGN;
buffer_copy_string_len(token, CONST_STR_LEN(":="));
}
break;
case '{':
t->offset++;

17
src/configparser.y

@ -206,6 +206,23 @@ varline ::= key(A) ASSIGN expression(B). {
A = NULL;
}
varline ::= key(A) FORCE_ASSIGN expression(B). {
if (ctx->ok) {
if (strncmp(A->ptr, "env.", sizeof("env.") - 1) == 0) {
fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n",
ctx->current->context_ndx,
ctx->current->key->ptr, A->ptr);
ctx->ok = 0;
} else {
buffer_copy_buffer(B->key, A);
array_replace(ctx->current->value, B);
B = NULL;
}
}
buffer_free(A);
A = NULL;
}
varline ::= key(A) APPEND expression(B). {
if (ctx->ok) {
array *vars = ctx->current->value;

Loading…
Cancel
Save