|
| 1 | +diff --git src/ngx_http_lua_pipe.c src/ngx_http_lua_pipe.c |
| 2 | +index c555d7bc..9b50d0ae 100644 |
| 3 | +--- src/ngx_http_lua_pipe.c |
| 4 | ++++ src/ngx_http_lua_pipe.c |
| 5 | +@@ -545,6 +545,21 @@ ngx_http_lua_pipe_fd_write(ngx_connection_t *c, u_char *buf, size_t size) |
| 6 | + } |
| 7 | + |
| 8 | + |
| 9 | ++#if !(NGX_HTTP_LUA_HAVE_EXECVPE) |
| 10 | ++static int |
| 11 | ++ngx_http_lua_execvpe(const char *program, char **argv, char **envp) |
| 12 | ++{ |
| 13 | ++ char **saved = environ; |
| 14 | ++ int rc; |
| 15 | ++ |
| 16 | ++ environ = envp; |
| 17 | ++ rc = execvp(program, argv); |
| 18 | ++ environ = saved; |
| 19 | ++ return rc; |
| 20 | ++} |
| 21 | ++#endif |
| 22 | ++ |
| 23 | ++ |
| 24 | + int |
| 25 | + ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, |
| 26 | + const char *file, const char **argv, int merge_stderr, size_t buffer_size, |
| 27 | +@@ -568,15 +583,6 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, |
| 28 | + ngx_http_lua_pipe_signal_t *sig; |
| 29 | + sigset_t set; |
| 30 | + |
| 31 | +-#if !(NGX_HTTP_LUA_HAVE_EXECVPE) |
| 32 | +- if (environ != NULL) { |
| 33 | +- *errbuf_size = ngx_snprintf(errbuf, *errbuf_size, |
| 34 | +- "environ option not supported") |
| 35 | +- - errbuf; |
| 36 | +- return NGX_ERROR; |
| 37 | +- } |
| 38 | +-#endif |
| 39 | +- |
| 40 | + pool_size = ngx_align(NGX_MIN_POOL_SIZE + buffer_size * 2, |
| 41 | + NGX_POOL_ALIGNMENT); |
| 42 | + |
| 43 | +@@ -766,9 +772,13 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | +-#if (NGX_HTTP_LUA_HAVE_EXECVPE) |
| 48 | + if (environ != NULL) { |
| 49 | ++#if (NGX_HTTP_LUA_HAVE_EXECVPE) |
| 50 | + if (execvpe(file, (char * const *) argv, (char * const *) environ) |
| 51 | ++#else |
| 52 | ++ if (ngx_http_lua_execvpe(file, (char * const *) argv, |
| 53 | ++ (char * const *) environ) |
| 54 | ++#endif |
| 55 | + == -1) |
| 56 | + { |
| 57 | + ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, |
| 58 | +@@ -784,14 +794,6 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | +-#else |
| 63 | +- if (execvp(file, (char * const *) argv) == -1) { |
| 64 | +- ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, |
| 65 | +- "lua pipe child execvp() failed while executing %s", |
| 66 | +- file); |
| 67 | +- } |
| 68 | +-#endif |
| 69 | +- |
| 70 | + exit(EXIT_FAILURE); |
| 71 | + } |
| 72 | + |
0 commit comments