diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-02-26 10:09:59 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-02-26 10:09:59 +0000 |
commit | b46f88af58a8d288797f9ac76d7aef32576d1360 (patch) | |
tree | 5b31427ce019869d392e57042555456ed9749fda /usr.sbin | |
parent | c5ad3516ac1e4caaf6eafee610f3a026efecc199 (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')
-rw-r--r-- | usr.sbin/bgpd/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/hostapd/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/ifstated/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/ntpd/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/ospf6d/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/ospfd/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/relayd/parse.y | 26 | ||||
-rw-r--r-- | usr.sbin/ripd/parse.y | 29 |
9 files changed, 133 insertions, 125 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index a7f912e07f4..2c8c60e1604 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.214 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.215 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -47,7 +47,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 *); @@ -1884,8 +1884,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -1903,7 +1904,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -2145,16 +2146,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); } int @@ -2177,6 +2177,7 @@ parse_config(char *filename, struct bgpd_config *xconf, free(conf); return (-1); } + topfile = file; if ((mrtconf = calloc(1, sizeof(struct mrt_head))) == NULL) fatal(NULL); diff --git a/usr.sbin/dvmrpd/parse.y b/usr.sbin/dvmrpd/parse.y index 9e8941ddf35..226e96f7170 100644 --- a/usr.sbin/dvmrpd/parse.y +++ b/usr.sbin/dvmrpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.13 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.14 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -51,7 +51,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 *); @@ -430,8 +430,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -449,7 +450,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -690,16 +691,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 dvmrpd_conf * @@ -713,6 +713,7 @@ parse_config(char *filename, int opts) errx(1, "parse_config calloc"); return (NULL); } + topfile = file; defs = &globaldefs; defs->probe_interval = DEFAULT_PROBE_INTERVAL; diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y index 4f4103cd656..820917e4b3b 100644 --- a/usr.sbin/hostapd/parse.y +++ b/usr.sbin/hostapd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.36 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.37 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -64,7 +64,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 *); @@ -1351,8 +1351,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -1370,7 +1371,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -1689,16 +1690,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); } int @@ -1739,6 +1739,7 @@ hostapd_parse_file(struct hostapd_config *cfg) free(sym); } } + topfile = file; return (errors ? EINVAL : ret); } diff --git a/usr.sbin/ifstated/parse.y b/usr.sbin/ifstated/parse.y index e13e642d9c1..d3a882882e9 100644 --- a/usr.sbin/ifstated/parse.y +++ b/usr.sbin/ifstated/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.25 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.26 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org> @@ -49,7 +49,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 *); @@ -431,8 +431,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -450,7 +451,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -691,16 +692,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 ifsd_config * @@ -719,6 +719,7 @@ parse_config(char *filename, int opts) free(conf); return (NULL); } + topfile = file; TAILQ_INIT(&conf->states); diff --git a/usr.sbin/ntpd/parse.y b/usr.sbin/ntpd/parse.y index 082e0c3f7e4..ea9357a8b19 100644 --- a/usr.sbin/ntpd/parse.y +++ b/usr.sbin/ntpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.41 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.42 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -43,7 +43,7 @@ static struct file { char *name; int lineno; int errors; -} *file; +} *file, *topfile; struct file *pushfile(const char *); int popfile(void); int yyparse(void); @@ -353,8 +353,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -372,7 +373,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -560,16 +561,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); } int @@ -585,6 +585,7 @@ parse_config(const char *filename, struct ntpd_conf *xconf) if ((file = pushfile(filename)) == NULL) { return (-1); } + topfile = file; yyparse(); errors = file->errors; diff --git a/usr.sbin/ospf6d/parse.y b/usr.sbin/ospf6d/parse.y index 0bc09123b30..69163d8750a 100644 --- a/usr.sbin/ospf6d/parse.y +++ b/usr.sbin/ospf6d/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.12 2007/12/13 08:54:05 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.13 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -51,7 +51,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 *); @@ -589,8 +589,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -608,7 +609,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -849,16 +850,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 ospfd_conf * @@ -889,6 +889,7 @@ parse_config(char *filename, int opts) free(conf); return (NULL); } + topfile = file; LIST_INIT(&conf->area_list); LIST_INIT(&conf->cand_list); diff --git a/usr.sbin/ospfd/parse.y b/usr.sbin/ospfd/parse.y index bc2a9b463b9..d4e8f0fe247 100644 --- a/usr.sbin/ospfd/parse.y +++ b/usr.sbin/ospfd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.60 2008/02/22 10:56:50 simon Exp $ */ +/* $OpenBSD: parse.y,v 1.61 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -49,7 +49,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 *); @@ -717,8 +717,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -736,7 +737,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -977,16 +978,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 ospfd_conf * @@ -1018,6 +1018,7 @@ parse_config(char *filename, int opts) free(conf); return (NULL); } + topfile = file; LIST_INIT(&conf->area_list); LIST_INIT(&conf->cand_list); diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index 63954efeb51..6e7f2020ec4 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.107 2008/02/13 11:32:59 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.108 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -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 *); @@ -1400,7 +1400,7 @@ lgetc(int 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); } @@ -1418,7 +1418,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -1659,16 +1659,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 relayd * @@ -2069,6 +2068,7 @@ table_inherit(struct table *tb) h->tablename = tb->conf.name; TAILQ_INSERT_HEAD(&tb->hosts, h, entry); } + topfile = file; conf->sc_tablecount++; TAILQ_INSERT_HEAD(conf->sc_tables, tb, entry); diff --git a/usr.sbin/ripd/parse.y b/usr.sbin/ripd/parse.y index 58416c55810..18ee46b1770 100644 --- a/usr.sbin/ripd/parse.y +++ b/usr.sbin/ripd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.17 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.18 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -50,7 +50,7 @@ static struct file { char *name; int lineno; int errors; -} *file; +} *file, *topfile; struct file *pushfile(const char *, int); int popfile(void); int yyparse(void); @@ -436,8 +436,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -455,7 +456,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -696,16 +697,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 ripd_conf * @@ -754,6 +754,7 @@ parse_config(char *filename, int opts) clear_config(conf); return (NULL); } + topfile = file; return (conf); } |