Check tftp-root exists and is accessible at startup.

This commit is contained in:
Simon Kelley
2012-06-13 13:43:49 +01:00
parent ed55cb66e6
commit 8b3ae2fd43
4 changed files with 39 additions and 1 deletions

View File

@@ -498,6 +498,34 @@ int main (int argc, char **argv)
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 @@ static void fatal_event(struct event_desc *ev, char *msg)
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);
}
}