Check tftp-root exists and is accessible at startup.
diff --git a/CHANGELOG b/CHANGELOG
index a98b101..702a865 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,12 @@
version 2.63
Do duplicate dhcp-host address check in --test mode.
+ Check that tftp-root directories are accessible before
+ start-up. Thanks to Daniel Veillard for the initial patch.
+
+ Allow more than one --tfp-root flag. The per-interface
+ stuff is pointless without that.
+
version 2.62
Update German translation. Thanks to Conrad Kostecki.
diff --git a/src/dnsmasq.c b/src/dnsmasq.c
index a6237ba..e48424b 100644
--- a/src/dnsmasq.c
+++ b/src/dnsmasq.c
@@ -498,6 +498,34 @@
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
#endif
+#ifdef HAVE_TFTP
+ if (daemon->tftp_unlimited || daemon->tftp_interfaces)
+ {
+ DIR *dir;
+ struct tftp_prefix *p;
+
+ if (daemon->tftp_prefix)
+ {
+ if (!((dir = opendir(daemon->tftp_prefix))))
+ {
+ send_event(err_pipe[1], EVENT_TFTP_ERR, errno, daemon->tftp_prefix);
+ _exit(0);
+ }
+ closedir(dir);
+ }
+
+ for (p = daemon->if_prefix; p; p = p->next)
+ {
+ if (!((dir = opendir(p->prefix))))
+ {
+ send_event(err_pipe[1], EVENT_TFTP_ERR, errno, p->prefix);
+ _exit(0);
+ }
+ closedir(dir);
+ }
+ }
+#endif
+
if (daemon->port == 0)
my_syslog(LOG_INFO, _("started, version %s DNS disabled"), VERSION);
else if (daemon->cachesize != 0)
@@ -995,6 +1023,9 @@
case EVENT_LUA_ERR:
die(_("failed to load Lua script: %s"), msg, EC_MISC);
+
+ case EVENT_TFTP_ERR:
+ die(_("TFTP directory %s inaccessible: %s"), msg, EC_FILE);
}
}
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
index 4b24acc..689d29b 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -159,6 +159,7 @@
#define EVENT_LOG_ERR 17
#define EVENT_FORK_ERR 18
#define EVENT_LUA_ERR 19
+#define EVENT_TFTP_ERR 20
/* Exit codes. */
#define EC_GOOD 0
diff --git a/src/option.c b/src/option.c
index 23b4114..0014269 100644
--- a/src/option.c
+++ b/src/option.c
@@ -341,7 +341,7 @@
{ LOPT_NO_NAMES, ARG_DUP, "[=tag:<tag>]...", gettext_noop("Ignore hostnames provided by DHCP clients."), NULL },
{ LOPT_OVERRIDE, OPT_NO_OVERRIDE, NULL, gettext_noop("Do NOT reuse filename and server fields for extra DHCP options."), NULL },
{ LOPT_TFTP, ARG_DUP, "[=<interface>]", gettext_noop("Enable integrated read-only TFTP server."), NULL },
- { LOPT_PREFIX, ARG_ONE, "<dir>[,<iface>]", gettext_noop("Export files by TFTP only from the specified subtree."), NULL },
+ { LOPT_PREFIX, ARG_DUP, "<dir>[,<iface>]", gettext_noop("Export files by TFTP only from the specified subtree."), NULL },
{ LOPT_APREF, OPT_TFTP_APREF, NULL, gettext_noop("Add client IP address to tftp-root."), NULL },
{ LOPT_SECURE, OPT_TFTP_SECURE, NULL, gettext_noop("Allow access only to files owned by the user running dnsmasq."), NULL },
{ LOPT_TFTP_MAX, ARG_ONE, "<integer>", gettext_noop("Maximum number of conncurrent TFTP transfers (defaults to %s)."), "#" },