mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Better log message when dhcp hosts|opts file cannot be read.
This commit is contained in:
17
src/option.c
17
src/option.c
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
static volatile int mem_recover = 0;
|
static volatile int mem_recover = 0;
|
||||||
static jmp_buf mem_jmp;
|
static jmp_buf mem_jmp;
|
||||||
static void one_file(char *file, int hard_opt);
|
static int one_file(char *file, int hard_opt);
|
||||||
|
|
||||||
/* Solaris headers don't have facility names. */
|
/* Solaris headers don't have facility names. */
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
#ifdef HAVE_SOLARIS_NETWORK
|
||||||
@@ -3289,7 +3289,7 @@ static void read_file(char *file, FILE *f, int hard_opt)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void one_file(char *file, int hard_opt)
|
static int one_file(char *file, int hard_opt)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int nofile_ok = 0;
|
int nofile_ok = 0;
|
||||||
@@ -3310,7 +3310,7 @@ static void one_file(char *file, int hard_opt)
|
|||||||
if (hard_opt == 0 && strcmp(file, "-") == 0)
|
if (hard_opt == 0 && strcmp(file, "-") == 0)
|
||||||
{
|
{
|
||||||
if (read_stdin == 1)
|
if (read_stdin == 1)
|
||||||
return;
|
return 1;
|
||||||
read_stdin = 1;
|
read_stdin = 1;
|
||||||
file = "stdin";
|
file = "stdin";
|
||||||
f = stdin;
|
f = stdin;
|
||||||
@@ -3326,7 +3326,7 @@ static void one_file(char *file, int hard_opt)
|
|||||||
|
|
||||||
for (r = filesread; r; r = r->next)
|
for (r = filesread; r; r = r->next)
|
||||||
if (r->dev == statbuf.st_dev && r->ino == statbuf.st_ino)
|
if (r->dev == statbuf.st_dev && r->ino == statbuf.st_ino)
|
||||||
return;
|
return 1;
|
||||||
|
|
||||||
r = safe_malloc(sizeof(struct fileread));
|
r = safe_malloc(sizeof(struct fileread));
|
||||||
r->next = filesread;
|
r->next = filesread;
|
||||||
@@ -3338,14 +3338,14 @@ static void one_file(char *file, int hard_opt)
|
|||||||
if (!(f = fopen(file, "r")))
|
if (!(f = fopen(file, "r")))
|
||||||
{
|
{
|
||||||
if (errno == ENOENT && nofile_ok)
|
if (errno == ENOENT && nofile_ok)
|
||||||
return; /* No conffile, all done. */
|
return 1; /* No conffile, all done. */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *str = _("cannot read %s: %s");
|
char *str = _("cannot read %s: %s");
|
||||||
if (hard_opt != 0)
|
if (hard_opt != 0)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_ERR, str, file, strerror(errno));
|
my_syslog(LOG_ERR, str, file, strerror(errno));
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
die(str, file, EC_FILE);
|
die(str, file, EC_FILE);
|
||||||
@@ -3354,6 +3354,7 @@ static void one_file(char *file, int hard_opt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
read_file(file, f, hard_opt);
|
read_file(file, f, hard_opt);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* expand any name which is a directory */
|
/* expand any name which is a directory */
|
||||||
@@ -3506,7 +3507,7 @@ void reread_dhcp(void)
|
|||||||
for (hf = daemon->dhcp_hosts_file; hf; hf = hf->next)
|
for (hf = daemon->dhcp_hosts_file; hf; hf = hf->next)
|
||||||
if (!(hf->flags & AH_INACTIVE))
|
if (!(hf->flags & AH_INACTIVE))
|
||||||
{
|
{
|
||||||
one_file(hf->fname, LOPT_BANK);
|
if (one_file(hf->fname, LOPT_BANK))
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3542,7 +3543,7 @@ void reread_dhcp(void)
|
|||||||
for (hf = daemon->dhcp_opts_file; hf; hf = hf->next)
|
for (hf = daemon->dhcp_opts_file; hf; hf = hf->next)
|
||||||
if (!(hf->flags & AH_INACTIVE))
|
if (!(hf->flags & AH_INACTIVE))
|
||||||
{
|
{
|
||||||
one_file(hf->fname, LOPT_OPTS);
|
if (one_file(hf->fname, LOPT_OPTS))
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user