=================================================================== RCS file: /cvs/cvs/blind/parse.y,v retrieving revision 1.6 retrieving revision 1.10 diff -u -p -r1.6 -r1.10 --- blind/parse.y 2022/03/20 23:03:01 1.6 +++ blind/parse.y 2022/03/25 22:43:43 1.10 @@ -16,19 +16,18 @@ %{ #include -#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); @@ -48,15 +48,13 @@ int kw_cmp(const void *, const void *); int yyparse(void); int yylex(void); int yyerror(const char *, ...) - __attribute__((__format__ (printf, 1, 2))) - __attribute__((__nonnull__ (1))); + __attribute__((__format__ (printf, 1, 2))) + __attribute__((__nonnull__ (1))); 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; @@ -154,7 +152,6 @@ lookup(char *s) return (STRING); } - #define START_EXPAND 1 #define DONE_EXPAND 2 @@ -204,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); } @@ -232,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(); } @@ -446,7 +445,7 @@ config_load(struct blind *temp) // config_purge(PURGE_ALL); return (-1); } - top = file; + // top = file; yyparse(); @@ -489,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) { @@ -499,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); }