Re: [OpenWrt-Devel] [Patch v2] [dnsmasq] backport --tftp-no-fail to ignore missing tftp root
Hi, please don't use [dnsmasq]. use dnsmasq: instead. otherwise git am does not pick it up. i fixed this manually now so you dont need to send a v3 John On 01/04/2015 01:11, Stefan Tomanek wrote: This patch backports the option --tftp-no-fail to dnsmasq and prevents the service from aborting if the specified TFTP root directory is not available; this might be the case if TFTP files are located on external media that might occasionally not be present at startup. Signed-off-by: Stefan Tomanek stefan.tomanek+open...@wertarbyte.de --- .../network/services/dnsmasq/files/dnsmasq.init|1 + ...-tftp-no-fail-to-ignore-missing-tftp-root.patch | 193 2 files changed, 194 insertions(+), 0 deletions(-) create mode 100644 package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 2e7fb7b..9795d1a 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -128,6 +128,7 @@ dnsmasq() { append_bool $cfg boguspriv --bogus-priv append_bool $cfg expandhosts --expand-hosts append_bool $cfg enable_tftp --enable-tftp + append_bool $cfg tftp_no_fail --tftp-no-fail append_bool $cfg nonwildcard --bind-interfaces append_bool $cfg fqdn --dhcp-fqdn append_bool $cfg proxydnssec --proxy-dnssec diff --git a/package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch b/package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch new file mode 100644 index 000..c85e4e6 --- /dev/null +++ b/package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch @@ -0,0 +1,193 @@ +From 56920681eaf2c5eb08fc75baee4939d15d03b0ea Mon Sep 17 00:00:00 2001 +From: Stefan Tomanek stefan.tomanek+dnsm...@wertarbyte.de +Date: Tue, 31 Mar 2015 22:32:11 +0100 +Subject: [PATCH] add --tftp-no-fail to ignore missing tftp root + +(cherry picked from commit 30d0879ed55cb67b1b735beab3d93f3bb3ef1dd2) + +Conflicts: + CHANGELOG + src/dnsmasq.c + src/dnsmasq.h + src/option.c +--- + dnsmasq.conf.example | 3 +++ + man/dnsmasq.8| 3 +++ + src/dnsmasq.c| 42 +++--- + src/dnsmasq.h| 4 +++- + src/option.c | 3 +++ + 5 files changed, 43 insertions(+), 12 deletions(-) + +diff --git a/dnsmasq.conf.example b/dnsmasq.conf.example +index 1bd305d..67be99a 100644 +--- a/dnsmasq.conf.example b/dnsmasq.conf.example +@@ -486,6 +486,9 @@ + # Set the root directory for files available via FTP. + #tftp-root=/var/ftpd + ++# Do not abort if the tftp-root is unavailable ++#tftp-no-fail ++ + # Make the TFTP server more secure: with this set, only files owned by + # the user dnsmasq is running as will be send over the net. + #tftp-secure +diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 +index 0b8e04f..2ff4b96 100644 +--- a/man/dnsmasq.8 b/man/dnsmasq.8 +@@ -1670,6 +1670,9 @@ Absolute paths (starting with /) are allowed, but they must be within + the tftp-root. If the optional interface argument is given, the + directory is only used for TFTP requests via that interface. + .TP ++.B --tftp-no-fail ++Do not abort startup if specified tftp root directories are inaccessible. ++.TP + .B --tftp-unique-root + Add the IP address of the TFTP client as a path component on the end + of the TFTP-root (in standard dotted-quad format). Only valid if a +diff --git a/src/dnsmasq.c b/src/dnsmasq.c +index 5c7750d..b6fa285 100644 +--- a/src/dnsmasq.c b/src/dnsmasq.c +@@ -58,6 +58,9 @@ int main (int argc, char **argv) + struct dhcp_context *context; + struct dhcp_relay *relay; + #endif ++#ifdef HAVE_TFTP ++ int tftp_prefix_missing = 0; ++#endif + + #ifdef LOCALEDIR + setlocale(LC_ALL, ); +@@ -623,7 +626,7 @@ int main (int argc, char **argv) + #endif + + #ifdef HAVE_TFTP +- if (option_bool(OPT_TFTP)) ++ if (option_bool(OPT_TFTP)) + { + DIR *dir; + struct tftp_prefix *p; +@@ -632,24 +635,33 @@ int main (int argc, char **argv) + { + if (!((dir = opendir(daemon-tftp_prefix + { +- send_event(err_pipe[1], EVENT_TFTP_ERR, errno, daemon-tftp_prefix); +- _exit(0); ++ tftp_prefix_missing = 1; ++ if (!option_bool(OPT_TFTP_NO_FAIL)) ++{ ++ 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) + { ++ p-missing = 0; + if (!((dir = opendir(p-prefix +- { +- send_event(err_pipe[1],
[OpenWrt-Devel] [Patch v2] [dnsmasq] backport --tftp-no-fail to ignore missing tftp root
This patch backports the option --tftp-no-fail to dnsmasq and prevents the service from aborting if the specified TFTP root directory is not available; this might be the case if TFTP files are located on external media that might occasionally not be present at startup. Signed-off-by: Stefan Tomanek stefan.tomanek+open...@wertarbyte.de --- .../network/services/dnsmasq/files/dnsmasq.init|1 + ...-tftp-no-fail-to-ignore-missing-tftp-root.patch | 193 2 files changed, 194 insertions(+), 0 deletions(-) create mode 100644 package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 2e7fb7b..9795d1a 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -128,6 +128,7 @@ dnsmasq() { append_bool $cfg boguspriv --bogus-priv append_bool $cfg expandhosts --expand-hosts append_bool $cfg enable_tftp --enable-tftp + append_bool $cfg tftp_no_fail --tftp-no-fail append_bool $cfg nonwildcard --bind-interfaces append_bool $cfg fqdn --dhcp-fqdn append_bool $cfg proxydnssec --proxy-dnssec diff --git a/package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch b/package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch new file mode 100644 index 000..c85e4e6 --- /dev/null +++ b/package/network/services/dnsmasq/patches/120-add-tftp-no-fail-to-ignore-missing-tftp-root.patch @@ -0,0 +1,193 @@ +From 56920681eaf2c5eb08fc75baee4939d15d03b0ea Mon Sep 17 00:00:00 2001 +From: Stefan Tomanek stefan.tomanek+dnsm...@wertarbyte.de +Date: Tue, 31 Mar 2015 22:32:11 +0100 +Subject: [PATCH] add --tftp-no-fail to ignore missing tftp root + +(cherry picked from commit 30d0879ed55cb67b1b735beab3d93f3bb3ef1dd2) + +Conflicts: + CHANGELOG + src/dnsmasq.c + src/dnsmasq.h + src/option.c +--- + dnsmasq.conf.example | 3 +++ + man/dnsmasq.8| 3 +++ + src/dnsmasq.c| 42 +++--- + src/dnsmasq.h| 4 +++- + src/option.c | 3 +++ + 5 files changed, 43 insertions(+), 12 deletions(-) + +diff --git a/dnsmasq.conf.example b/dnsmasq.conf.example +index 1bd305d..67be99a 100644 +--- a/dnsmasq.conf.example b/dnsmasq.conf.example +@@ -486,6 +486,9 @@ + # Set the root directory for files available via FTP. + #tftp-root=/var/ftpd + ++# Do not abort if the tftp-root is unavailable ++#tftp-no-fail ++ + # Make the TFTP server more secure: with this set, only files owned by + # the user dnsmasq is running as will be send over the net. + #tftp-secure +diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 +index 0b8e04f..2ff4b96 100644 +--- a/man/dnsmasq.8 b/man/dnsmasq.8 +@@ -1670,6 +1670,9 @@ Absolute paths (starting with /) are allowed, but they must be within + the tftp-root. If the optional interface argument is given, the + directory is only used for TFTP requests via that interface. + .TP ++.B --tftp-no-fail ++Do not abort startup if specified tftp root directories are inaccessible. ++.TP + .B --tftp-unique-root + Add the IP address of the TFTP client as a path component on the end + of the TFTP-root (in standard dotted-quad format). Only valid if a +diff --git a/src/dnsmasq.c b/src/dnsmasq.c +index 5c7750d..b6fa285 100644 +--- a/src/dnsmasq.c b/src/dnsmasq.c +@@ -58,6 +58,9 @@ int main (int argc, char **argv) + struct dhcp_context *context; + struct dhcp_relay *relay; + #endif ++#ifdef HAVE_TFTP ++ int tftp_prefix_missing = 0; ++#endif + + #ifdef LOCALEDIR + setlocale(LC_ALL, ); +@@ -623,7 +626,7 @@ int main (int argc, char **argv) + #endif + + #ifdef HAVE_TFTP +- if (option_bool(OPT_TFTP)) ++ if (option_bool(OPT_TFTP)) + { + DIR *dir; + struct tftp_prefix *p; +@@ -632,24 +635,33 @@ int main (int argc, char **argv) + { + if (!((dir = opendir(daemon-tftp_prefix + { +-send_event(err_pipe[1], EVENT_TFTP_ERR, errno, daemon-tftp_prefix); +-_exit(0); ++tftp_prefix_missing = 1; ++if (!option_bool(OPT_TFTP_NO_FAIL)) ++ { ++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) + { ++p-missing = 0; + if (!((dir = opendir(p-prefix +- { +- send_event(err_pipe[1], EVENT_TFTP_ERR, errno, p-prefix); +- _exit(0); +- } ++ { ++p-missing = 1; ++if (!option_bool(OPT_TFTP_NO_FAIL)) ++ { ++send_event(err_pipe[1], EVENT_TFTP_ERR, errno, p-prefix); ++