diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-02-27 10:30:12 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-02-27 10:30:12 +0000 |
commit | 82a9a16697534c54fa269335670f0cad4b3800f4 (patch) | |
tree | fa78b7c993350ef8e7d6c81a00dbf40673f67c37 /usr.sbin/snmpd | |
parent | fc7ed00bbba1e0fe9a44c8baa7e7b7c239808633 (diff) |
Have popfile() also close the main config file,
but only do the final popfile call after yyparse() is done.
This also fixes config reload on SIGHUP for some daemons.
Spotted by otto@. OK deraadt@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r-- | usr.sbin/snmpd/parse.y | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/usr.sbin/snmpd/parse.y b/usr.sbin/snmpd/parse.y index 601ebdbcb66..da0c6b4ce75 100644 --- a/usr.sbin/snmpd/parse.y +++ b/usr.sbin/snmpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.12 2008/02/26 20:06:14 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.13 2008/02/27 10:30:11 mpf Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -57,7 +57,7 @@ static struct file { char *name; int lineno; int errors; -} *file; +} *file, *topfile; struct file *pushfile(const char *, int); int popfile(void); int check_file_secrecy(int, const char *); @@ -432,7 +432,7 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -458,7 +458,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -699,16 +699,15 @@ popfile(void) { struct file *prev; - if ((prev = TAILQ_PREV(file, files, entry)) != NULL) { + if ((prev = TAILQ_PREV(file, files, entry)) != NULL) prev->errors += file->errors; - TAILQ_REMOVE(&files, file, entry); - fclose(file->stream); - free(file->name); - free(file); - file = prev; - return (0); - } - return (EOF); + + TAILQ_REMOVE(&files, file, entry); + fclose(file->stream); + free(file->name); + free(file); + file = prev; + return (file ? 0 : EOF); } struct snmpd * @@ -720,6 +719,7 @@ parse_config(const char *filename, u_int flags) log_warn("cannot allocate memory"); return (NULL); } + topfile = file; conf->sc_flags = flags; conf->sc_confpath = filename; |