diff --git a/patch/1.19.3/ngx_lua-ngx_pipe_environ_on_mac.patch b/patch/1.19.3/ngx_lua-ngx_pipe_environ_on_mac.patch new file mode 100644 index 0000000..6869bda --- /dev/null +++ b/patch/1.19.3/ngx_lua-ngx_pipe_environ_on_mac.patch @@ -0,0 +1,72 @@ +diff --git src/ngx_http_lua_pipe.c src/ngx_http_lua_pipe.c +index c555d7bc..9b50d0ae 100644 +--- src/ngx_http_lua_pipe.c ++++ src/ngx_http_lua_pipe.c +@@ -545,6 +545,21 @@ ngx_http_lua_pipe_fd_write(ngx_connection_t *c, u_char *buf, size_t size) + } + + ++#if !(NGX_HTTP_LUA_HAVE_EXECVPE) ++static int ++ngx_http_lua_execvpe(const char *program, char **argv, char **envp) ++{ ++ char **saved = environ; ++ int rc; ++ ++ environ = envp; ++ rc = execvp(program, argv); ++ environ = saved; ++ return rc; ++} ++#endif ++ ++ + int + ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, + const char *file, const char **argv, int merge_stderr, size_t buffer_size, +@@ -568,15 +583,6 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, + ngx_http_lua_pipe_signal_t *sig; + sigset_t set; + +-#if !(NGX_HTTP_LUA_HAVE_EXECVPE) +- if (environ != NULL) { +- *errbuf_size = ngx_snprintf(errbuf, *errbuf_size, +- "environ option not supported") +- - errbuf; +- return NGX_ERROR; +- } +-#endif +- + pool_size = ngx_align(NGX_MIN_POOL_SIZE + buffer_size * 2, + NGX_POOL_ALIGNMENT); + +@@ -766,9 +772,13 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, + } + } + +-#if (NGX_HTTP_LUA_HAVE_EXECVPE) + if (environ != NULL) { ++#if (NGX_HTTP_LUA_HAVE_EXECVPE) + if (execvpe(file, (char * const *) argv, (char * const *) environ) ++#else ++ if (ngx_http_lua_execvpe(file, (char * const *) argv, ++ (char * const *) environ) ++#endif + == -1) + { + ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, +@@ -784,14 +794,6 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, + } + } + +-#else +- if (execvp(file, (char * const *) argv) == -1) { +- ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, +- "lua pipe child execvp() failed while executing %s", +- file); +- } +-#endif +- + exit(EXIT_FAILURE); + } + diff --git a/patch/README.md b/patch/README.md index 9c65d4b..6d62d73 100644 --- a/patch/README.md +++ b/patch/README.md @@ -5,3 +5,5 @@ We have modified them a lot and even changed the API. The `*-upstream_mtls` patches originally come from the Kong's kong-build-tools and lua-kong-nginx-module projects, which is also under Apache-2.0 License. + +The `*-ngx_pipe_environ_on_mac` patches support the environ argument of the ngx.pipe.spawn function on macos. \ No newline at end of file