When users specify a file (instead of a directory) as argument of
hostsdir, dnsmasq will log:

> dnsmasq: bad dynamic directory hosts: Success

because stat() didn't fail for this file, however, the test
whether this is a directory failed.

This patch changes the behavior to log

> dnsmasq: bad dynamic directory hosts: not a directory

instead in this case.

Best,
Dominik
From 066a79e48b129e845744ad0e8d88be5181875ba0 Mon Sep 17 00:00:00 2001
From: Dominik Derigs <dl...@dl6er.de>
Date: Wed, 22 Sep 2021 15:32:59 +0200
Subject: [PATCH] Correcly warn if dynamic directory is actually no directory

Signed-off-by: DL6ER <dl...@dl6er.de>
---
 src/inotify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/inotify.c b/src/inotify.c
index 5776feb..7425b15 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -151,7 +151,7 @@ void set_dynamic_inotify(int flag, int total_size, struct crec **rhash, int revh
       if (stat(ah->fname, &buf) == -1 || !(S_ISDIR(buf.st_mode)))
 	{
 	  my_syslog(LOG_ERR, _("bad dynamic directory %s: %s"), 
-		    ah->fname, strerror(errno));
+		    ah->fname, (S_ISDIR(buf.st_mode)) ? strerror(errno) : _("not a directory"));
 	  continue;
 	}
       
-- 
2.25.1

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss

Reply via email to