0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 02:01:55 +00:00

Conf: Allowing conf scope to be explicitly read only

This commit is contained in:
Maria Matejka 2023-06-13 11:09:41 +02:00 committed by Igor Putovny
parent 0323471062
commit ab785d1ec4
2 changed files with 8 additions and 2 deletions

View File

@ -570,6 +570,9 @@ static inline void cf_swap_soft_scope(struct config *conf);
static struct symbol * static struct symbol *
cf_new_symbol(struct sym_scope *scope, pool *p, struct linpool *lp, const byte *c) 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; struct symbol *s;
uint l = strlen(c); uint l = strlen(c);
@ -723,6 +726,8 @@ cf_lex_init(int is_cli, struct config *c)
sym->class = SYM_KEYWORD; sym->class = SYM_KEYWORD;
sym->keyword = k; sym->keyword = k;
} }
global_root_scope->readonly = 1;
} }
ifs_head = ifs = push_ifs(NULL); ifs_head = ifs = push_ifs(NULL);

View File

@ -137,9 +137,10 @@ struct sym_scope {
HASH(struct symbol) hash; /* Local symbol hash */ HASH(struct symbol) hash; /* Local symbol hash */
uint slots; /* Variable slots */ uint slots; /* Variable slots */
byte active; /* Currently entered */
byte block; /* No independent stack frame */
byte soft_scopes; /* Number of soft scopes above */ 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; extern struct sym_scope *global_root_scope;