summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--conf.c8
-rw-r--r--parse.y3
2 files changed, 9 insertions, 2 deletions
diff --git a/conf.c b/conf.c
index ea22d59..8b43668 100644
--- a/conf.c
+++ b/conf.c
@@ -168,6 +168,8 @@ conf_init(struct conf *c)
 void
 conf_setup(struct conf *c, const char *conf_file)
 {
+	struct stat sb;
+
 	if (conf_file == NULL) {
 		char *home = getenv("HOME");
 
@@ -177,7 +179,11 @@ conf_setup(struct conf *c, const char *conf_file)
 		snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home,
 		    CONFFILE);
 	} else
-		snprintf(c->conf_path, sizeof(c->conf_path), "%s", conf_file);
+		if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
+			errx(1, "%s: %s", conf_file, strerror(errno));
+		else
+			snprintf(c->conf_path, sizeof(c->conf_path), "%s",
+			    conf_file);
 
 	conf_init(c);
 
diff --git a/parse.y b/parse.y
index 1b054bf..3181c6d 100644
--- a/parse.y
+++ b/parse.y
@@ -441,7 +441,8 @@ pushfile(const char *name)
 	nfile->name = xstrdup(name);
 
 	if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
-		warn("%s", nfile->name);
+		if (errno != ENOENT)
+			warn("%s", nfile->name);
 		free(nfile->name);
 		free(nfile);
 		return (NULL);