From: Maria Matejka Date: Tue, 13 Jun 2023 09:09:41 +0000 (+0200) Subject: Conf: Allowing conf scope to be explicitly read only X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=317c89cc8abdada9cd90f844b6b1801651d92e76;p=thirdparty%2Fbird.git Conf: Allowing conf scope to be explicitly read only --- diff --git a/conf/cf-lex.l b/conf/cf-lex.l index d1cc4ed9e..04a6c9945 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -570,6 +570,9 @@ static inline void cf_swap_soft_scope(struct config *conf); static struct symbol * cf_new_symbol(struct sym_scope *scope, pool *p, struct linpool *lp, const byte *c) { + if (scope->readonly) + cf_error("Unknown symbol %s", c); + struct symbol *s; uint l = strlen(c); @@ -723,6 +726,8 @@ cf_lex_init(int is_cli, struct config *c) sym->class = SYM_KEYWORD; sym->keyword = k; } + + global_root_scope->readonly = 1; } ifs_head = ifs = push_ifs(NULL); diff --git a/conf/conf.h b/conf/conf.h index ec8c97e84..8558fcbae 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -137,9 +137,10 @@ struct sym_scope { HASH(struct symbol) hash; /* Local symbol hash */ uint slots; /* Variable slots */ - byte active; /* Currently entered */ - byte block; /* No independent stack frame */ byte soft_scopes; /* Number of soft scopes above */ + byte active:1; /* Currently entered */ + byte block:1; /* No independent stack frame */ + byte readonly:1; /* Do not add new symbols */ }; extern struct sym_scope *global_root_scope;