summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ifstated
diff options
context:
space:
mode:
authormpf <mpf@openbsd.org>2008-02-26 10:09:58 +0000
committermpf <mpf@openbsd.org>2008-02-26 10:09:58 +0000
commitc6004ab9a7d2cc39aacb95862f2f0078521b6b49 (patch)
treefe1fffc0e04efaf1eb891d4c1e9197237bb4d30c /usr.sbin/ifstated
parentAllow a range of baud rates in a manner similiar to tip/cu, (diff)
downloadwireguard-openbsd-c6004ab9a7d2cc39aacb95862f2f0078521b6b49.tar.xz
wireguard-openbsd-c6004ab9a7d2cc39aacb95862f2f0078521b6b49.zip
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/ifstated')
-rw-r--r--usr.sbin/ifstated/parse.y29
1 files changed, 15 insertions, 14 deletions
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);