Skip to content

Commit

Permalink
bugfix: nginx patch: do not build resolver parsing feature under Wind…
Browse files Browse the repository at this point in the history
…ows.

bugfix: nginx patch: moved the include of resolv.h to after ngx_config.h to avoid compilation failures on FreeBSD.

bugfix: patch: updated safe_resolver_ipv6_option.patch with new offsets to avoid confusing patch while applying.
Signed-off-by: Yichun Zhang (agentzh) <[email protected]>
  • Loading branch information
dndx authored and agentzh committed Apr 21, 2018
1 parent d6c0785 commit f0e621b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ path to be used for parsing, for example: `local=/tmp/test.conf`.

When `local=off`, parsing will be disabled (this is the default).

This feature is not available on Windows platforms.

[Back to TOC](#table-of-contents)

Mailing List
Expand Down
28 changes: 18 additions & 10 deletions patches/nginx-1.13.6-resolver_conf_parsing.patch
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c
index cd55520c..df55a484 100644
index cd55520c..dade1846 100644
--- a/src/core/ngx_resolver.c
+++ b/src/core/ngx_resolver.c
@@ -5,6 +5,7 @@
*/


+#include <resolv.h>
#include <ngx_config.h>
@@ -9,12 +9,26 @@
#include <ngx_core.h>
#include <ngx_event.h>
@@ -15,6 +16,14 @@

+#if !(NGX_WIN32)
+#include <resolv.h>
+#endif
+

#define NGX_RESOLVER_UDP_SIZE 4096

#define NGX_RESOLVER_TCP_RSIZE (2 + 65535)
#define NGX_RESOLVER_TCP_WSIZE 8192

+#if !(NGX_WIN32)
+/*
+ * note that 2KB should be more than enough for majority of the
+ * resolv.conf files out there. it also acts as a safety guard to prevent
+ * abuse.
+ */
+#define NGX_RESOLVER_FILE_BUF_SIZE 2048
+#define NGX_RESOLVER_FILE_NAME "/etc/resolv.conf"
+#endif
+

typedef struct {
u_char ident_hi;
@@ -131,6 +140,189 @@ static ngx_resolver_node_t *ngx_resolver_lookup_addr6(ngx_resolver_t *r,
@@ -131,6 +145,191 @@ static ngx_resolver_node_t *ngx_resolver_lookup_addr6(ngx_resolver_t *r,
#endif


+#if !(NGX_WIN32)
+static ngx_int_t
+ngx_resolver_read_resolv_conf(ngx_conf_t *cf, ngx_resolver_t *r, u_char *path,
+ size_t path_len)
Expand Down Expand Up @@ -210,15 +215,17 @@ index cd55520c..df55a484 100644
+
+ return NGX_OK;
+}
+#endif
+
+
ngx_resolver_t *
ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
{
@@ -246,6 +438,37 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
@@ -246,6 +445,39 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
}
#endif

+#if !(NGX_WIN32)
+ if (ngx_strncmp(names[i].data, "local=", 6) == 0) {
+
+ if (ngx_strcmp(&names[i].data[6], "on") == 0) {
Expand Down Expand Up @@ -249,6 +256,7 @@ index cd55520c..df55a484 100644
+
+ continue;
+ }
+#endif
+
ngx_memzero(&u, sizeof(ngx_url_t));

Expand Down
15 changes: 8 additions & 7 deletions patches/nginx-1.13.6-safe_resolver_ipv6_option.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ With this option disappearing in Nginx 1.11.5, this patch would allow such tools
to assume "ipv6=off" to be safe regardless of ipv6 support in the current
build.

diff -r a3dc657f4e95 -r 8bf038fe006f src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Thu Dec 15 21:44:34 2016 +0300
+++ b/src/core/ngx_resolver.c Thu Dec 15 16:17:01 2016 -0800
@@ -224,14 +224,22 @@
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c
index dade1846..5a3f0aa4 100644
--- a/src/core/ngx_resolver.c
+++ b/src/core/ngx_resolver.c
@@ -426,14 +426,22 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
continue;
}

Expand All @@ -45,11 +46,11 @@ diff -r a3dc657f4e95 -r 8bf038fe006f src/core/ngx_resolver.c

} else {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
@@ -241,7 +249,6 @@
@@ -443,7 +451,6 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)

continue;
}
-#endif

ngx_memzero(&u, sizeof(ngx_url_t));

#if !(NGX_WIN32)
if (ngx_strncmp(names[i].data, "local=", 6) == 0) {

0 comments on commit f0e621b

Please sign in to comment.