=================================================================== RCS file: /cvs/cvs/blind/parse.y,v retrieving revision 1.4 retrieving revision 1.5 diff -u -p -r1.4 -r1.5 --- blind/parse.y 2022/03/20 20:40:36 1.4 +++ blind/parse.y 2022/03/20 22:00:51 1.5 @@ -38,8 +38,12 @@ static struct file { int errors; } *file, *top; +int yyparse(void); int yylex(void); -int yyerror(const char *, ...); +int yyerror(const char *, ...) + __attribute__((__format__ (printf, 1, 2))) + __attribute__((__nonnull__ (1))); + int config_load(struct blind *); struct file *config_push(const char *); int config_pop(void); @@ -67,11 +71,14 @@ typedef struct { grammar : | grammar '\n' | grammar expire '\n' + | grammar error '\n' { file->errors++; } ; expire : EXPIRE NUMBER { - } - ; + log_debug("found EXPIRE"); + env->bl_ttl = $2; +} +; %% @@ -99,7 +106,7 @@ config_load(struct blind *temp) } top = file; - // parse file + yyparse(); errors = file->errors; config_pop(); @@ -115,16 +122,16 @@ config_push(const char *name) struct file *nfile; if ((nfile = calloc(1, sizeof(struct file))) == NULL) { - log_debug("%s: calloc()", __func__); + log_debug("cannot allocate memory"); return (NULL); } if ((nfile->name = strdup(name)) == NULL) { - log_debug("%s: strdup()", __func__); + log_debug("cannot duplicate name"); free(nfile); return (NULL); } if ((nfile->stream = fopen(nfile->name, "r")) == NULL) { - log_debug("%s: fopen()", __func__); + log_debug("cannot open config file"); free(nfile->name); free(nfile); return (NULL); @@ -139,7 +146,7 @@ config_push(const char *name) nfile->ungetsize = 16; nfile->ungetbuf = malloc(nfile->ungetsize); if (nfile->ungetbuf == NULL) { - log_debug("%s: malloc()", __func__); + log_debug("cannot allocate buffer"); fclose(nfile->stream); free(nfile->name); free(nfile); @@ -173,17 +180,15 @@ config_perm(int fd, const char *name) struct stat st; if (fstat(fd, &st)) { - log_debug("%s: fstat(%s)", __func__, name); + log_debug("cannot stat config file"); return (-1); } if (st.st_uid != 0 && st.st_uid != getuid()) { - log_debug("%s: %s: wrong file permission", \ - __func__, name); + log_debug("not root or current user owned"); return (-1); } if (st.st_mode & (S_IWGRP | S_IXGRP | S_IRWXO)) { - log_debug("%s: %s: group/world readable/writable", \ - __func__, name); + log_debug("insecure config file"); return (-1); } return (0);