=================================================================== RCS file: /cvs/cvs/blind/parse.y,v retrieving revision 1.8 retrieving revision 1.10 diff -u -p -r1.8 -r1.10 --- blind/parse.y 2022/03/22 02:18:20 1.8 +++ blind/parse.y 2022/03/25 22:43:43 1.10 @@ -16,19 +16,18 @@ %{ #include -#include #include #include -#include #include #include "blind.h" +#include "config.h" #include "log.h" -TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); + //TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); static struct file { - TAILQ_ENTRY(file) entry; + // TAILQ_ENTRY(file) entry; FILE *stream; char *name; size_t ungetpos; @@ -37,7 +36,8 @@ static struct file { int eof_reached; int lineno; int errors; -} *file, *top; +} *file; +//, *top; int lookup(char *); int igetc(void); @@ -54,9 +54,7 @@ int yyerror(const char *, ...) int config_load(struct blind *); struct file *config_push(const char *); int config_pop(void); -int config_perm(int, const char *); - TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead); struct sym { TAILQ_ENTRY(sym) entry; @@ -203,7 +201,8 @@ lgetc(int quotec) if ((c = igetc()) == EOF) { yyerror("reached end of file while parsing " "quoted string"); - if (file == top || config_pop() == EOF) + // if (file == top || config_pop() == EOF) + if (config_pop() == EOF) return (EOF); return (quotec); } @@ -231,7 +230,8 @@ lgetc(int quotec) return ('\n'); } while (c == EOF) { - if (file == top || config_pop() == EOF) + //if (file == top || config_pop() == EOF) + if (config_pop() == EOF) return (EOF); c = igetc(); } @@ -445,7 +445,7 @@ config_load(struct blind *temp) // config_purge(PURGE_ALL); return (-1); } - top = file; + // top = file; yyparse(); @@ -488,7 +488,7 @@ config_push(const char *name) free(nfile); return (NULL); } - nfile->lineno = TAILQ_EMPTY(&files) ? 1 : 0; + nfile->lineno = 1; // TAILQ_EMPTY(&files) ? 1 : 0; nfile->ungetsize = 16; nfile->ungetbuf = malloc(nfile->ungetsize); if (nfile->ungetbuf == NULL) { @@ -498,44 +498,25 @@ config_push(const char *name) free(nfile); return (NULL); } - TAILQ_INSERT_TAIL(&files, nfile, entry); + //TAILQ_INSERT_TAIL(&files, nfile, entry); return (nfile); } int config_pop(void) { - struct file *prv; + // struct file *prv; - if ((prv = TAILQ_PREV(file, files, entry)) != NULL) - prv->errors += file->errors; + //if ((prv = TAILQ_PREV(file, files, entry)) != NULL) + // prv->errors += file->errors; - TAILQ_REMOVE(&files, file, entry); + // TAILQ_REMOVE(&files, file, entry); fclose(file->stream); free(file->name); free(file->ungetbuf); - free(file); - file = prv; + // free(file); + // file = prv; - return (file ? 0 : EOF); -} - -int -config_perm(int fd, const char *name) -{ - struct stat st; - - if (fstat(fd, &st)) { - log_debug("cannot stat config file"); - return (-1); - } - if (st.st_uid != 0 && st.st_uid != getuid()) { - log_debug("not root or current user owned"); - return (-1); - } - if (st.st_mode & (S_IWGRP | S_IXGRP | S_IRWXO)) { - log_debug("insecure config file"); - return (-1); - } - return (0); + // return (file ? 0 : EOF); + return (EOF); }