├── .gitignore ├── CHANGES ├── LICENSE ├── README ├── config ├── src ├── ngx_coolkit_handlers.c ├── ngx_coolkit_handlers.h ├── ngx_coolkit_module.c ├── ngx_coolkit_module.h ├── ngx_coolkit_variables.c └── ngx_coolkit_variables.h ├── t ├── location.t ├── override_method.t └── remote_passwd.t └── valgrind.suppress /.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | t/servroot/ 3 | *~ 4 | *.swp 5 | work/ 6 | buildroot/ 7 | util/ 8 | reindex 9 | go 10 | build1* 11 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | 2010-07-01 VERSION 1.0 2 | * Initial release. 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, FRiCKLE Piotr Sikora 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 14 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 16 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 17 | HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ABOUT: 2 | ------ 3 | ngx_coolkit is collection of small and useful nginx add-ons. 4 | 5 | 6 | CONFIGURATION DIRECTIVES: 7 | ------------------------- 8 | 9 | override_method off | [methods] source (context: http, server, location) 10 | ------------------------------------------------------------------------ 11 | Override HTTP method. 12 | 13 | default: none 14 | 15 | 16 | CONFIGURATION VARIABLES: 17 | ------------------------ 18 | 19 | $remote_passwd 20 | ----------------- 21 | Decoded password from "Authorization" header (Basic HTTP Authentication). 22 | 23 | 24 | $location 25 | --------- 26 | Name of the matched location block. 27 | 28 | 29 | EXAMPLE CONFIGURATION #1: 30 | ------------------------- 31 | http { 32 | server { 33 | location / { 34 | override_method $arg_method; 35 | proxy_pass http://127.0.0.1:8100; 36 | } 37 | } 38 | } 39 | 40 | Pass request with changed HTTP method (based on "?method=XXX") to the backend. 41 | 42 | 43 | EXAMPLE CONFIGURATION #2: 44 | ------------------------- 45 | http { 46 | upstream database { 47 | postgres_server 127.0.0.1 dbname=test 48 | user=monty password=some_pass; 49 | } 50 | 51 | server { 52 | location = /auth { 53 | internal; 54 | 55 | set_quote_sql_str $user $remote_user; 56 | set_quote_sql_str $pass $remote_passwd; 57 | 58 | postgres_pass database; 59 | postgres_query "SELECT login FROM users WHERE login=$user AND pass=$pass"; 60 | postgres_rewrite no_rows 403; 61 | postgres_output none; 62 | } 63 | 64 | location / { 65 | auth_request /auth; 66 | root /files; 67 | } 68 | } 69 | } 70 | 71 | Restrict access to local files by authenticating against SQL database. 72 | 73 | Required modules (other than ngx_coolkit): 74 | - ngx_http_auth_request_module, 75 | - ngx_postgres (PostgreSQL) or ngx_drizzle (MySQL, Drizzle, SQLite), 76 | - ngx_set_misc. 77 | -------------------------------------------------------------------------------- /config: -------------------------------------------------------------------------------- 1 | ngx_addon_name=ngx_coolkit_module 2 | 3 | HTTP_MODULES="$HTTP_MODULES ngx_coolkit_module" 4 | NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_coolkit_handlers.c $ngx_addon_dir/src/ngx_coolkit_module.c $ngx_addon_dir/src/ngx_coolkit_variables.c" 5 | NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ngx_coolkit_handlers.h $ngx_addon_dir/src/ngx_coolkit_module.h $ngx_addon_dir/src/ngx_coolkit_variables.h" 6 | 7 | have=NGX_COOLKIT_MODULE . auto/have 8 | -------------------------------------------------------------------------------- /src/ngx_coolkit_handlers.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, FRiCKLE Piotr Sikora 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "ngx_coolkit_handlers.h" 28 | #include "ngx_coolkit_module.h" 29 | 30 | 31 | ngx_int_t 32 | ngx_coolkit_override_method_handler(ngx_http_request_t *r) 33 | { 34 | ngx_coolkit_loc_conf_t *cklcf; 35 | ngx_coolkit_ctx_t *ckctx; 36 | ngx_str_t method; 37 | ngx_conf_bitmask_t *b; 38 | ngx_uint_t original, j; 39 | 40 | cklcf = ngx_http_get_module_loc_conf(r, ngx_coolkit_module); 41 | ckctx = ngx_http_get_module_ctx(r, ngx_coolkit_module); 42 | 43 | /* always test against original request method */ 44 | if ((ckctx != NULL) && (ckctx->overridden_method != 0)) { 45 | original = ckctx->overridden_method; 46 | } else { 47 | original = r->method; 48 | } 49 | 50 | if ((cklcf->override_source) && (cklcf->override_methods & original)) { 51 | if (ngx_http_complex_value(r, cklcf->override_source, &method) 52 | != NGX_OK) 53 | { 54 | return NGX_HTTP_INTERNAL_SERVER_ERROR; 55 | } 56 | 57 | if (method.len == 0) { 58 | return NGX_DECLINED; 59 | } 60 | 61 | b = ngx_coolkit_http_methods; 62 | for (j = 0; b[j].name.len; j++) { 63 | if ((b[j].name.len - 1 == method.len) 64 | && (ngx_strncasecmp(b[j].name.data, method.data, method.len) 65 | == 0)) 66 | { 67 | if (ckctx == NULL) { 68 | ckctx = ngx_pcalloc(r->pool, sizeof(ngx_coolkit_ctx_t)); 69 | if (ckctx == NULL) { 70 | return NGX_HTTP_INTERNAL_SERVER_ERROR; 71 | } 72 | 73 | /* 74 | * set by ngx_pcalloc(): 75 | * 76 | * ckctx->overridden_method = 0 77 | * ckctx->overridden_method_name = { 0, NULL } 78 | */ 79 | 80 | ngx_http_set_ctx(r, ckctx, ngx_coolkit_module); 81 | } 82 | 83 | if (ckctx->overridden_method == 0) { 84 | ckctx->overridden_method = r->method; 85 | ckctx->overridden_method_name = r->method_name; 86 | } 87 | 88 | r->method = b[j].mask; 89 | r->method_name = b[j].name; 90 | r->method_name.len--; /* "hidden" space */ 91 | 92 | ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 93 | "coolkit override method: %V", &method); 94 | 95 | return NGX_DECLINED; 96 | } 97 | } 98 | 99 | return NGX_DECLINED; 100 | } 101 | 102 | if ((ckctx != NULL) && (ckctx->overridden_method != 0) 103 | && (cklcf->override_source == NULL)) 104 | { 105 | /* 106 | * Bring back original method in location with 107 | * "override_method off". 108 | * This mess happens because this handlers runs twice: 109 | * in server rewrite and (location) rewrite phases. 110 | */ 111 | 112 | r->method = ckctx->overridden_method; 113 | r->method_name = ckctx->overridden_method_name; 114 | } 115 | 116 | return NGX_DECLINED; 117 | } 118 | -------------------------------------------------------------------------------- /src/ngx_coolkit_handlers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, FRiCKLE Piotr Sikora 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _NGX_COOLKIT_HANDLERS_H_ 28 | #define _NGX_COOLKIT_HANDLERS_H_ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | ngx_int_t ngx_coolkit_override_method_handler(ngx_http_request_t *); 36 | 37 | #endif /* _NGX_COOLKIT_HANDLERS_H_ */ 38 | -------------------------------------------------------------------------------- /src/ngx_coolkit_module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, FRiCKLE Piotr Sikora 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "ngx_coolkit_handlers.h" 28 | #include "ngx_coolkit_module.h" 29 | #include "ngx_coolkit_variables.h" 30 | 31 | 32 | static ngx_command_t ngx_coolkit_module_commands[] = { 33 | 34 | { ngx_string("override_method"), 35 | NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, 36 | ngx_coolkit_conf_override_method, 37 | NGX_HTTP_LOC_CONF_OFFSET, 38 | 0, 39 | NULL }, 40 | 41 | ngx_null_command 42 | }; 43 | 44 | static ngx_http_variable_t ngx_coolkit_module_variables[] = { 45 | 46 | { ngx_string("remote_passwd"), NULL, 47 | ngx_coolkit_variable_remote_passwd, 0, 48 | NGX_HTTP_VAR_NOCACHEABLE, 0 }, 49 | 50 | { ngx_string("location"), NULL, 51 | ngx_coolkit_variable_location, 0, 52 | NGX_HTTP_VAR_NOCACHEABLE, 0 }, 53 | 54 | { ngx_null_string, NULL, NULL, 0, 0, 0 } 55 | }; 56 | 57 | static ngx_http_module_t ngx_coolkit_module_ctx = { 58 | ngx_coolkit_add_variables, /* preconfiguration */ 59 | ngx_coolkit_init, /* postconfiguration */ 60 | 61 | NULL, /* create main configuration */ 62 | NULL, /* init main configuration */ 63 | 64 | NULL, /* create server configuration */ 65 | NULL, /* merge server configuration */ 66 | 67 | ngx_coolkit_create_loc_conf, /* create location configuration */ 68 | ngx_coolkit_merge_loc_conf /* merge location configuration */ 69 | }; 70 | 71 | ngx_module_t ngx_coolkit_module = { 72 | NGX_MODULE_V1, 73 | &ngx_coolkit_module_ctx, /* module context */ 74 | ngx_coolkit_module_commands, /* module directives */ 75 | NGX_HTTP_MODULE, /* module type */ 76 | NULL, /* init master */ 77 | NULL, /* init module */ 78 | NULL, /* init process */ 79 | NULL, /* init thread */ 80 | NULL, /* exit thread */ 81 | NULL, /* exit process */ 82 | NULL, /* exit master */ 83 | NGX_MODULE_V1_PADDING 84 | }; 85 | 86 | /* 87 | * nginx assumes that HTTP method name is followed by space, so add it here 88 | * instead of allocating memory for copy with added space for each request. 89 | */ 90 | ngx_conf_bitmask_t ngx_coolkit_http_methods[] = { 91 | { ngx_string("GET "), NGX_HTTP_GET }, 92 | { ngx_string("HEAD "), NGX_HTTP_HEAD }, 93 | { ngx_string("POST "), NGX_HTTP_POST }, 94 | { ngx_string("PUT "), NGX_HTTP_PUT }, 95 | { ngx_string("DELETE "), NGX_HTTP_DELETE }, 96 | { ngx_string("MKCOL "), NGX_HTTP_MKCOL }, 97 | { ngx_string("COPY "), NGX_HTTP_COPY }, 98 | { ngx_string("MOVE "), NGX_HTTP_MOVE }, 99 | { ngx_string("OPTIONS "), NGX_HTTP_OPTIONS }, 100 | { ngx_string("PROPFIND "), NGX_HTTP_PROPFIND }, 101 | { ngx_string("PROPPATCH "), NGX_HTTP_PROPPATCH }, 102 | { ngx_string("LOCK "), NGX_HTTP_LOCK }, 103 | { ngx_string("UNLOCK "), NGX_HTTP_UNLOCK }, 104 | #if defined(nginx_version) && (nginx_version >= 8041) 105 | { ngx_string("PATCH "), NGX_HTTP_PATCH }, 106 | #endif 107 | { ngx_null_string, 0 } 108 | }; 109 | 110 | 111 | ngx_int_t 112 | ngx_coolkit_add_variables(ngx_conf_t *cf) 113 | { 114 | ngx_http_variable_t *var, *v; 115 | 116 | for (v = ngx_coolkit_module_variables; v->name.len; v++) { 117 | var = ngx_http_add_variable(cf, &v->name, v->flags); 118 | if (var == NULL) { 119 | return NGX_ERROR; 120 | } 121 | 122 | var->get_handler = v->get_handler; 123 | var->data = v->data; 124 | } 125 | 126 | return NGX_OK; 127 | } 128 | 129 | ngx_int_t 130 | ngx_coolkit_init(ngx_conf_t *cf) 131 | { 132 | ngx_http_handler_pt *h; 133 | ngx_http_core_main_conf_t *cmcf; 134 | 135 | cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); 136 | 137 | h = ngx_array_push(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers); 138 | if (h == NULL) { 139 | return NGX_ERROR; 140 | } 141 | 142 | *h = ngx_coolkit_override_method_handler; 143 | 144 | h = ngx_array_push(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers); 145 | if (h == NULL) { 146 | return NGX_ERROR; 147 | } 148 | 149 | *h = ngx_coolkit_override_method_handler; 150 | 151 | return NGX_OK; 152 | } 153 | 154 | void * 155 | ngx_coolkit_create_loc_conf(ngx_conf_t *cf) 156 | { 157 | ngx_coolkit_loc_conf_t *conf; 158 | 159 | conf = ngx_palloc(cf->pool, sizeof(ngx_coolkit_loc_conf_t)); 160 | if (conf == NULL) { 161 | return NULL; 162 | } 163 | 164 | /* 165 | * set by ngx_pcalloc(): 166 | * 167 | * conf->override_methods = 0 168 | */ 169 | 170 | conf->override_source = NGX_CONF_UNSET_PTR; 171 | 172 | return conf; 173 | } 174 | 175 | char * 176 | ngx_coolkit_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) 177 | { 178 | ngx_coolkit_loc_conf_t *prev = parent; 179 | ngx_coolkit_loc_conf_t *conf = child; 180 | 181 | if (conf->override_source == NGX_CONF_UNSET_PTR) { 182 | if (prev->override_source == NGX_CONF_UNSET_PTR) { 183 | /* default */ 184 | conf->override_methods = 0; 185 | conf->override_source = NULL; 186 | } else { 187 | /* merge */ 188 | conf->override_methods = prev->override_methods; 189 | conf->override_source = prev->override_source; 190 | } 191 | } 192 | 193 | return NGX_CONF_OK; 194 | } 195 | 196 | char * 197 | ngx_coolkit_conf_override_method(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 198 | { 199 | ngx_str_t *value = cf->args->elts; 200 | ngx_str_t source = value[cf->args->nelts - 1]; 201 | ngx_coolkit_loc_conf_t *cklcf = conf; 202 | ngx_http_compile_complex_value_t ccv; 203 | ngx_conf_bitmask_t *b; 204 | ngx_uint_t i, j; 205 | 206 | if (cklcf->override_source != NGX_CONF_UNSET_PTR) { 207 | return "is duplicate"; 208 | } 209 | 210 | if (ngx_strcmp(value[1].data, "off") == 0) { 211 | cklcf->override_source = NULL; 212 | return NGX_CONF_OK; 213 | } 214 | 215 | if (source.len == 0) { 216 | ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 217 | "coolkit: empty source in \"%V\" directive", 218 | &cmd->name); 219 | 220 | return NGX_CONF_ERROR; 221 | } 222 | 223 | if (cf->args->nelts == 2) { 224 | /* override method for all methods */ 225 | cklcf->override_methods = 0xFFFF; 226 | } else { 227 | /* override method only for specified methods */ 228 | cklcf->override_methods = 0; 229 | 230 | for (i = 1; i < cf->args->nelts - 1; i++) { 231 | b = ngx_coolkit_http_methods; 232 | for (j = 0; b[j].name.len; j++) { 233 | if ((b[j].name.len - 1 == value[i].len) 234 | && (ngx_strncasecmp(b[j].name.data, 235 | value[i].data, value[i].len) == 0)) 236 | { 237 | cklcf->override_methods |= b[j].mask; 238 | break; 239 | } 240 | } 241 | 242 | if (b[j].name.len == 0) { 243 | ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 244 | "coolkit: invalid method \"%V\"" 245 | " in \"%V\" directive", 246 | &value[i], &cmd->name); 247 | 248 | return NGX_CONF_ERROR; 249 | } 250 | } 251 | } 252 | 253 | cklcf->override_source = ngx_palloc(cf->pool, 254 | sizeof(ngx_http_complex_value_t)); 255 | if (cklcf->override_source == NULL) { 256 | return NGX_CONF_ERROR; 257 | } 258 | 259 | ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); 260 | 261 | ccv.cf = cf; 262 | ccv.value = &source; 263 | ccv.complex_value = cklcf->override_source; 264 | 265 | if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { 266 | return NGX_CONF_ERROR; 267 | } 268 | 269 | return NGX_CONF_OK; 270 | } 271 | -------------------------------------------------------------------------------- /src/ngx_coolkit_module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, FRiCKLE Piotr Sikora 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _NGX_COOLKIT_MODULE_H_ 28 | #define _NGX_COOLKIT_MODULE_H_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | extern ngx_module_t ngx_coolkit_module; 37 | extern ngx_conf_bitmask_t ngx_coolkit_http_methods[]; 38 | 39 | 40 | typedef struct { 41 | /* override_method */ 42 | ngx_uint_t override_methods; 43 | ngx_http_complex_value_t *override_source; 44 | } ngx_coolkit_loc_conf_t; 45 | 46 | typedef struct { 47 | /* override_method */ 48 | ngx_uint_t overridden_method; 49 | ngx_str_t overridden_method_name; 50 | } ngx_coolkit_ctx_t; 51 | 52 | 53 | ngx_int_t ngx_coolkit_add_variables(ngx_conf_t *); 54 | ngx_int_t ngx_coolkit_init(ngx_conf_t *); 55 | void *ngx_coolkit_create_loc_conf(ngx_conf_t *); 56 | char *ngx_coolkit_merge_loc_conf(ngx_conf_t *, void *, void *); 57 | char *ngx_coolkit_conf_override_method(ngx_conf_t *, ngx_command_t *, 58 | void *); 59 | 60 | #endif /* _NGX_COOLKIT_MODULE_H_ */ 61 | -------------------------------------------------------------------------------- /src/ngx_coolkit_variables.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, FRiCKLE Piotr Sikora 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "ngx_coolkit_module.h" 28 | #include "ngx_coolkit_variables.h" 29 | 30 | 31 | /* 32 | * source: ngx_http_variables.c/ngx_http_variable_remote_user 33 | * Copyright (C) Igor Sysoev 34 | */ 35 | ngx_int_t 36 | ngx_coolkit_variable_remote_passwd(ngx_http_request_t *r, 37 | ngx_http_variable_value_t *v, uintptr_t data) 38 | { 39 | ngx_int_t rc; 40 | 41 | rc = ngx_http_auth_basic_user(r); 42 | 43 | if (rc == NGX_DECLINED) { 44 | v->not_found = 1; 45 | return NGX_OK; 46 | } 47 | 48 | if (rc == NGX_ERROR) { 49 | return NGX_ERROR; 50 | } 51 | 52 | v->len = r->headers_in.passwd.len; 53 | v->valid = 1; 54 | v->no_cacheable = 0; 55 | v->not_found = 0; 56 | v->data = r->headers_in.passwd.data; 57 | 58 | return NGX_OK; 59 | } 60 | 61 | 62 | ngx_int_t 63 | ngx_coolkit_variable_location(ngx_http_request_t *r, 64 | ngx_http_variable_value_t *v, uintptr_t data) 65 | { 66 | ngx_http_core_loc_conf_t *clcf; 67 | #if (NGX_PCRE) 68 | ngx_int_t rc; 69 | int captures[3]; 70 | #endif 71 | 72 | clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 73 | 74 | #if (NGX_PCRE) 75 | if (clcf->regex) { 76 | rc = ngx_regex_exec(clcf->regex->regex, &r->uri, captures, 3); 77 | 78 | if (rc == NGX_REGEX_NO_MATCHED) { 79 | return NGX_ERROR; 80 | } 81 | 82 | v->data = r->uri.data + captures[0]; 83 | v->len = captures[1] - captures[0]; 84 | 85 | } else 86 | #endif 87 | { 88 | v->data = clcf->name.data; 89 | v->len = clcf->name.len; 90 | } 91 | 92 | v->valid = 1; 93 | v->no_cacheable = 0; 94 | v->not_found = 0; 95 | 96 | return NGX_OK; 97 | } 98 | -------------------------------------------------------------------------------- /src/ngx_coolkit_variables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, FRiCKLE Piotr Sikora 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _NGX_COOLKIT_VARIABLES_H_ 28 | #define _NGX_COOLKIT_VARIABLES_H_ 29 | 30 | #include 31 | #include 32 | 33 | 34 | ngx_int_t ngx_coolkit_variable_remote_passwd(ngx_http_request_t *, 35 | ngx_http_variable_value_t *, uintptr_t); 36 | ngx_int_t ngx_coolkit_variable_location(ngx_http_request_t *, 37 | ngx_http_variable_value_t *, uintptr_t); 38 | 39 | #endif /* _NGX_COOLKIT_VARIABLES_H_ */ 40 | -------------------------------------------------------------------------------- /t/location.t: -------------------------------------------------------------------------------- 1 | # vi:filetype=perl 2 | 3 | use lib 'lib'; 4 | use Test::Nginx::Socket; 5 | 6 | repeat_each(2); 7 | 8 | plan tests => repeat_each() * (blocks() * 3); 9 | 10 | worker_connections(128); 11 | run_tests(); 12 | 13 | no_diff(); 14 | 15 | __DATA__ 16 | 17 | === TEST 1: sanity 18 | --- config 19 | location /echo { 20 | echo -n $location; 21 | } 22 | --- request 23 | GET /echo 24 | --- error_code: 200 25 | --- response_headers 26 | Content-Type: text/plain 27 | --- response_body chop 28 | /echo 29 | --- timeout: 10 30 | 31 | 32 | 33 | === TEST 2: regex 34 | --- config 35 | location ~/echo { 36 | echo -n $location; 37 | } 38 | --- request 39 | GET /test/echo/regex 40 | --- error_code: 200 41 | --- response_headers 42 | Content-Type: text/plain 43 | --- response_body chop 44 | /echo 45 | --- timeout: 10 46 | -------------------------------------------------------------------------------- /t/override_method.t: -------------------------------------------------------------------------------- 1 | # vi:filetype=perl 2 | 3 | use lib 'lib'; 4 | use Test::Nginx::Socket; 5 | 6 | repeat_each(2); 7 | 8 | plan tests => repeat_each() * (blocks() * 3); 9 | 10 | worker_connections(128); 11 | run_tests(); 12 | 13 | no_diff(); 14 | 15 | __DATA__ 16 | 17 | === TEST 1: not changed 18 | --- config 19 | location /test { 20 | override_method $arg_method; 21 | echo -n $request_method; 22 | } 23 | --- request 24 | GET /test 25 | --- error_code: 200 26 | --- response_headers 27 | Content-Type: text/plain 28 | --- response_body chop 29 | GET 30 | --- timeout: 10 31 | 32 | 33 | 34 | === TEST 2: changed 35 | --- config 36 | location /test { 37 | override_method $arg_method; 38 | echo -n $request_method; 39 | } 40 | --- request 41 | GET /test?method=POST 42 | --- error_code: 200 43 | --- response_headers 44 | Content-Type: text/plain 45 | --- response_body chop 46 | POST 47 | --- timeout: 10 48 | 49 | 50 | 51 | === TEST 3: inherited 52 | --- config 53 | override_method $arg_method; 54 | 55 | location /test { 56 | echo -n $request_method; 57 | } 58 | --- request 59 | GET /test?method=POST 60 | --- error_code: 200 61 | --- response_headers 62 | Content-Type: text/plain 63 | --- response_body chop 64 | POST 65 | --- timeout: 10 66 | 67 | 68 | 69 | === TEST 4: not inherited 70 | --- config 71 | override_method $arg_method; 72 | 73 | location /test { 74 | override_method PUT; 75 | echo -n $request_method; 76 | } 77 | --- request 78 | GET /test?method=POST 79 | --- error_code: 200 80 | --- response_headers 81 | Content-Type: text/plain 82 | --- response_body chop 83 | PUT 84 | --- timeout: 10 85 | 86 | 87 | 88 | === TEST 5: restored 89 | --- config 90 | override_method $arg_method; 91 | 92 | location /test { 93 | override_method off; 94 | echo -n $request_method; 95 | } 96 | --- request 97 | GET /test?method=POST 98 | --- error_code: 200 99 | --- response_headers 100 | Content-Type: text/plain 101 | --- response_body chop 102 | GET 103 | --- timeout: 10 104 | 105 | 106 | 107 | === TEST 6: method-specific (changed) 108 | --- config 109 | location /test { 110 | override_method GET $arg_method; 111 | echo -n $request_method; 112 | } 113 | --- request 114 | GET /test?method=POST 115 | --- error_code: 200 116 | --- response_headers 117 | Content-Type: text/plain 118 | --- response_body chop 119 | POST 120 | --- timeout: 10 121 | 122 | 123 | 124 | === TEST 7: method-specific (not changed) 125 | --- config 126 | location /test { 127 | override_method PUT $arg_method; 128 | echo -n $request_method; 129 | } 130 | --- request 131 | GET /test?method=POST 132 | --- error_code: 200 133 | --- response_headers 134 | Content-Type: text/plain 135 | --- response_body chop 136 | GET 137 | --- timeout: 10 138 | 139 | 140 | 141 | === TEST 8: method-specific (multiple methods) 142 | --- config 143 | location /test { 144 | override_method GET HEAD PUT $arg_method; 145 | echo -n $request_method; 146 | } 147 | --- request 148 | HEAD /test?method=POST 149 | --- error_code: 200 150 | --- response_headers 151 | Content-Type: text/plain 152 | --- response_body chop 153 | POST 154 | --- timeout: 10 155 | 156 | 157 | 158 | === TEST 9: double dance (blocked) 159 | --- config 160 | override_method GET $arg_method; 161 | if ($request_method = GET) { 162 | return 400; 163 | } 164 | 165 | location /test { 166 | override_method GET PUT; 167 | if ($request_method = GET) { 168 | return 400; 169 | } 170 | 171 | echo -n $request_method; 172 | } 173 | --- request 174 | GET /test 175 | --- error_code: 400 176 | --- response_headers 177 | Content-Type: text/html 178 | --- response_body_like: 400 Bad Request 179 | --- timeout: 10 180 | 181 | 182 | 183 | === TEST 10: double dance (passed) 184 | --- config 185 | override_method GET $arg_method; 186 | if ($request_method = GET) { 187 | return 400; 188 | } 189 | 190 | location /test { 191 | override_method GET PUT; 192 | if ($request_method = GET) { 193 | return 400; 194 | } 195 | 196 | echo -n $request_method; 197 | } 198 | --- request 199 | GET /test?method=POST 200 | --- error_code: 200 201 | --- response_headers 202 | Content-Type: text/plain 203 | --- response_body chop 204 | PUT 205 | --- timeout: 10 206 | --- skip_nginx: 3: < 0.8.34 207 | 208 | 209 | 210 | === TEST 11: double dance with "off" 211 | --- config 212 | override_method GET $arg_method; 213 | if ($request_method = GET) { 214 | return 400; 215 | } 216 | 217 | location /test { 218 | override_method off; 219 | echo -n $request_method; 220 | } 221 | --- request 222 | GET /test?method=POST 223 | --- error_code: 200 224 | --- response_headers 225 | Content-Type: text/plain 226 | --- response_body chop 227 | GET 228 | --- timeout: 10 229 | --- skip_nginx: 3: < 0.8.34 230 | 231 | 232 | 233 | === TEST 12: changed method passed to upstream 234 | --- http_config 235 | server { 236 | listen 8100; 237 | location / { 238 | echo -n $request_method; 239 | } 240 | } 241 | --- config 242 | location /test { 243 | override_method $arg_method; 244 | proxy_pass http://127.0.0.1:8100; 245 | } 246 | --- request 247 | GET /test?method=POST 248 | --- error_code: 200 249 | --- response_headers 250 | Content-Type: text/plain 251 | --- response_body chop 252 | POST 253 | --- timeout: 10 254 | 255 | 256 | 257 | === TEST 13: restored method passed to upstream 258 | --- http_config 259 | server { 260 | listen 8100; 261 | location / { 262 | echo -n $request_method; 263 | } 264 | } 265 | --- config 266 | override_method $arg_method; 267 | 268 | location /test { 269 | override_method off; 270 | proxy_pass http://127.0.0.1:8100; 271 | } 272 | --- request 273 | GET /test?method=POST 274 | --- error_code: 200 275 | --- response_headers 276 | Content-Type: text/plain 277 | --- response_body chop 278 | GET 279 | --- timeout: 10 280 | -------------------------------------------------------------------------------- /t/remote_passwd.t: -------------------------------------------------------------------------------- 1 | # vi:filetype=perl 2 | 3 | use lib 'lib'; 4 | use Test::Nginx::Socket; 5 | 6 | repeat_each(2); 7 | 8 | plan tests => repeat_each() * (blocks() * 3); 9 | 10 | worker_connections(128); 11 | run_tests(); 12 | 13 | no_diff(); 14 | 15 | __DATA__ 16 | 17 | === TEST 1: sanity 18 | --- config 19 | location /echo { 20 | echo -n $remote_passwd; 21 | } 22 | --- more_headers 23 | Authorization: Basic bW9udHk6c29tZV9wYXNz 24 | --- request 25 | GET /echo 26 | --- error_code: 200 27 | --- response_headers 28 | Content-Type: text/plain 29 | --- response_body chop 30 | some_pass 31 | --- timeout: 10 32 | 33 | 34 | 35 | === TEST 2: sanity (without Authorization header) 36 | --- config 37 | location /echo { 38 | echo -n $remote_passwd; 39 | } 40 | --- request 41 | GET /echo 42 | --- error_code: 200 43 | --- response_headers 44 | Content-Type: text/plain 45 | --- response_body: 46 | --- timeout: 10 47 | 48 | 49 | 50 | === TEST 3: accessible from within lua 51 | --- config 52 | location /echo { 53 | content_by_lua ' 54 | ngx.say(ngx.var.remote_passwd) 55 | '; 56 | } 57 | --- more_headers 58 | Authorization: Basic bW9udHk6c29tZV9wYXNz 59 | --- request 60 | GET /echo 61 | --- error_code: 200 62 | --- response_headers 63 | Content-Type: text/plain 64 | --- response_body 65 | some_pass 66 | --- timeout: 10 67 | 68 | -------------------------------------------------------------------------------- /valgrind.suppress: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | fun:malloc 5 | fun:ngx_alloc 6 | } 7 | { 8 | 9 | Memcheck:Addr1 10 | fun:ngx_init_cycle 11 | fun:ngx_master_process_cycle 12 | fun:main 13 | } 14 | { 15 | 16 | Memcheck:Param 17 | socketcall.sendmsg(msg.msg_iov[i]) 18 | fun:sendmsg 19 | fun:ngx_write_channel 20 | fun:ngx_signal_worker_processes 21 | fun:ngx_master_process_cycle 22 | fun:main 23 | } 24 | { 25 | 26 | Memcheck:Addr4 27 | fun:ngx_init_cycle 28 | fun:ngx_master_process_cycle 29 | fun:main 30 | } 31 | { 32 | 33 | Memcheck:Param 34 | socketcall.sendmsg(msg.msg_iov[i]) 35 | fun:__sendmsg_nocancel 36 | fun:ngx_write_channel 37 | fun:ngx_signal_worker_processes 38 | fun:ngx_master_process_cycle 39 | fun:main 40 | } 41 | { 42 | 43 | Memcheck:Param 44 | socketcall.sendmsg(msg.msg_iov[i]) 45 | fun:__sendmsg_nocancel 46 | fun:ngx_write_channel 47 | fun:ngx_master_process_cycle 48 | fun:main 49 | } 50 | { 51 | 52 | Memcheck:Param 53 | socketcall.sendmsg(msg.msg_iov[i]) 54 | fun:__sendmsg_nocancel 55 | fun:ngx_write_channel 56 | fun:ngx_pass_open_channel 57 | fun:ngx_start_worker_processes 58 | fun:ngx_master_process_cycle 59 | fun:main 60 | } 61 | { 62 | 63 | Memcheck:Param 64 | write(buf) 65 | fun:__write_nocancel 66 | fun:ngx_log_error_core 67 | fun:ngx_resolver_read_response 68 | } 69 | { 70 | 71 | Memcheck:Cond 72 | fun:ngx_sprintf_num 73 | fun:ngx_vslprintf 74 | fun:ngx_log_error_core 75 | fun:ngx_resolver_read_response 76 | fun:ngx_epoll_process_events 77 | fun:ngx_process_events_and_timers 78 | fun:ngx_single_process_cycle 79 | fun:main 80 | } 81 | { 82 | 83 | Memcheck:Addr1 84 | fun:ngx_vslprintf 85 | fun:ngx_snprintf 86 | fun:ngx_sock_ntop 87 | fun:ngx_event_accept 88 | } 89 | { 90 | 91 | Memcheck:Param 92 | write(buf) 93 | fun:__write_nocancel 94 | fun:ngx_log_error_core 95 | fun:ngx_resolver_read_response 96 | fun:ngx_event_process_posted 97 | fun:ngx_process_events_and_timers 98 | fun:ngx_single_process_cycle 99 | fun:main 100 | } 101 | { 102 | 103 | Memcheck:Cond 104 | fun:ngx_sprintf_num 105 | fun:ngx_vslprintf 106 | fun:ngx_log_error_core 107 | fun:ngx_resolver_read_response 108 | fun:ngx_event_process_posted 109 | fun:ngx_process_events_and_timers 110 | fun:ngx_single_process_cycle 111 | fun:main 112 | } 113 | { 114 | 115 | exp-sgcheck:SorG 116 | fun:lj_str_new 117 | fun:lua_pushlstring 118 | } 119 | { 120 | 121 | Memcheck:Leak 122 | fun:malloc 123 | fun:ngx_alloc 124 | obj:* 125 | } 126 | { 127 | 128 | exp-sgcheck:SorG 129 | fun:lj_str_new 130 | fun:lua_pushlstring 131 | } 132 | { 133 | 134 | exp-sgcheck:SorG 135 | fun:ngx_http_lua_ndk_set_var_get 136 | } 137 | { 138 | 139 | exp-sgcheck:SorG 140 | fun:lj_str_new 141 | fun:lua_getfield 142 | } 143 | { 144 | 145 | exp-sgcheck:SorG 146 | fun:lj_str_new 147 | fun:lua_setfield 148 | } 149 | { 150 | 151 | exp-sgcheck:SorG 152 | fun:ngx_http_variables_init_vars 153 | fun:ngx_http_block 154 | } 155 | { 156 | 157 | exp-sgcheck:SorG 158 | fun:ngx_conf_parse 159 | } 160 | { 161 | 162 | exp-sgcheck:SorG 163 | fun:ngx_vslprintf 164 | fun:ngx_log_error_core 165 | } 166 | { 167 | 168 | Memcheck:Leak 169 | fun:malloc 170 | fun:ngx_alloc 171 | fun:ngx_calloc 172 | fun:ngx_event_process_init 173 | } 174 | { 175 | 176 | Memcheck:Leak 177 | fun:malloc 178 | fun:ngx_alloc 179 | fun:ngx_malloc 180 | fun:ngx_pcalloc 181 | } 182 | { 183 | 184 | Memcheck:Addr4 185 | fun:lj_str_new 186 | fun:lua_setfield 187 | } 188 | { 189 | 190 | Memcheck:Addr4 191 | fun:lj_str_new 192 | fun:lua_getfield 193 | } 194 | { 195 | 196 | Memcheck:Leak 197 | fun:malloc 198 | fun:ngx_alloc 199 | fun:(below main) 200 | } 201 | { 202 | 203 | Memcheck:Param 204 | epoll_ctl(event) 205 | fun:epoll_ctl 206 | } 207 | { 208 | 209 | Memcheck:Leak 210 | fun:malloc 211 | fun:ngx_alloc 212 | fun:ngx_event_process_init 213 | } 214 | { 215 | 216 | Memcheck:Cond 217 | fun:ngx_conf_flush_files 218 | fun:ngx_single_process_cycle 219 | } 220 | { 221 | 222 | Memcheck:Cond 223 | fun:memcpy 224 | fun:ngx_vslprintf 225 | fun:ngx_log_error_core 226 | fun:ngx_http_charset_header_filter 227 | } 228 | { 229 | 230 | Memcheck:Leak 231 | fun:memalign 232 | fun:posix_memalign 233 | fun:ngx_memalign 234 | fun:ngx_pcalloc 235 | } 236 | { 237 | 238 | Memcheck:Addr4 239 | fun:lj_str_new 240 | fun:lua_pushlstring 241 | } 242 | { 243 | 244 | Memcheck:Cond 245 | fun:lj_str_new 246 | fun:lj_str_fromnum 247 | } 248 | { 249 | 250 | Memcheck:Cond 251 | fun:lj_str_new 252 | fun:lua_pushlstring 253 | } 254 | { 255 | 256 | Memcheck:Addr4 257 | fun:lj_str_new 258 | fun:lua_setfield 259 | fun:ngx_http_lua_cache_store_code 260 | } 261 | { 262 | 263 | Memcheck:Cond 264 | fun:lj_str_new 265 | fun:lua_getfield 266 | fun:ngx_http_lua_cache_load_code 267 | } 268 | { 269 | 270 | Memcheck:Cond 271 | fun:lj_str_new 272 | fun:lua_setfield 273 | fun:ngx_http_lua_cache_store_code 274 | } 275 | { 276 | 277 | Memcheck:Addr4 278 | fun:lj_str_new 279 | fun:lua_getfield 280 | fun:ngx_http_lua_cache_load_code 281 | } 282 | { 283 | 284 | Memcheck:Param 285 | socketcall.setsockopt(optval) 286 | fun:setsockopt 287 | fun:drizzle_state_connect 288 | } 289 | { 290 | 291 | Memcheck:Leak 292 | fun:malloc 293 | fun:ngx_alloc 294 | fun:ngx_palloc_large 295 | } 296 | { 297 | 298 | Memcheck:Leak 299 | fun:malloc 300 | fun:ngx_alloc 301 | fun:ngx_pool_cleanup_add 302 | } 303 | { 304 | 305 | Memcheck:Leak 306 | fun:malloc 307 | fun:ngx_alloc 308 | fun:ngx_pnalloc 309 | } 310 | { 311 | 312 | Memcheck:Cond 313 | fun:ngx_conf_flush_files 314 | fun:ngx_single_process_cycle 315 | fun:main 316 | } 317 | 318 | { 319 | 320 | Memcheck:Leak 321 | fun:malloc 322 | fun:ngx_alloc 323 | fun:ngx_palloc 324 | } 325 | { 326 | 327 | Memcheck:Leak 328 | fun:malloc 329 | fun:ngx_alloc 330 | fun:ngx_pcalloc 331 | } 332 | { 333 | 334 | Memcheck:Leak 335 | fun:malloc 336 | fun:ngx_alloc 337 | fun:ngx_malloc 338 | fun:ngx_palloc_large 339 | } 340 | { 341 | 342 | Memcheck:Leak 343 | fun:malloc 344 | fun:ngx_alloc 345 | fun:ngx_create_pool 346 | } 347 | { 348 | 349 | Memcheck:Leak 350 | fun:malloc 351 | fun:ngx_alloc 352 | fun:ngx_malloc 353 | fun:ngx_palloc 354 | } 355 | { 356 | 357 | Memcheck:Leak 358 | fun:malloc 359 | fun:ngx_alloc 360 | fun:ngx_malloc 361 | fun:ngx_pnalloc 362 | } 363 | 364 | { 365 | 366 | Memcheck:Leak 367 | fun:malloc 368 | fun:ngx_alloc 369 | fun:ngx_palloc_large 370 | fun:ngx_palloc 371 | fun:ngx_array_push 372 | fun:ngx_http_get_variable_index 373 | fun:ngx_http_memc_add_variable 374 | fun:ngx_http_memc_init 375 | fun:ngx_http_block 376 | fun:ngx_conf_parse 377 | fun:ngx_init_cycle 378 | fun:main 379 | } 380 | 381 | { 382 | 383 | Memcheck:Leak 384 | fun:malloc 385 | fun:ngx_alloc 386 | fun:ngx_event_process_init 387 | fun:ngx_single_process_cycle 388 | fun:main 389 | } 390 | { 391 | 392 | Memcheck:Leak 393 | fun:malloc 394 | fun:ngx_alloc 395 | fun:ngx_crc32_table_init 396 | fun:main 397 | } 398 | { 399 | 400 | Memcheck:Leak 401 | fun:malloc 402 | fun:ngx_alloc 403 | fun:ngx_event_process_init 404 | fun:ngx_worker_process_init 405 | fun:ngx_worker_process_cycle 406 | fun:ngx_spawn_process 407 | fun:ngx_start_worker_processes 408 | fun:ngx_master_process_cycle 409 | fun:main 410 | } 411 | { 412 | 413 | Memcheck:Param 414 | socketcall.sendmsg(msg.msg_iov[i]) 415 | fun:__sendmsg_nocancel 416 | fun:ngx_write_channel 417 | fun:ngx_signal_worker_processes 418 | fun:ngx_master_process_cycle 419 | fun:main 420 | } 421 | { 422 | 423 | Memcheck:Leak 424 | fun:malloc 425 | fun:ngx_alloc 426 | fun:ngx_palloc_large 427 | fun:ngx_palloc 428 | fun:ngx_pcalloc 429 | fun:ngx_hash_init 430 | fun:ngx_http_variables_init_vars 431 | fun:ngx_http_block 432 | fun:ngx_conf_parse 433 | fun:ngx_init_cycle 434 | fun:main 435 | } 436 | { 437 | 438 | Memcheck:Leak 439 | fun:malloc 440 | fun:ngx_alloc 441 | fun:ngx_palloc_large 442 | fun:ngx_palloc 443 | fun:ngx_pcalloc 444 | fun:ngx_http_upstream_drizzle_create_srv_conf 445 | fun:ngx_http_upstream 446 | fun:ngx_conf_parse 447 | fun:ngx_http_block 448 | fun:ngx_conf_parse 449 | fun:ngx_init_cycle 450 | fun:main 451 | } 452 | { 453 | 454 | Memcheck:Leak 455 | fun:malloc 456 | fun:ngx_alloc 457 | fun:ngx_palloc_large 458 | fun:ngx_palloc 459 | fun:ngx_pcalloc 460 | fun:ngx_hash_keys_array_init 461 | fun:ngx_http_variables_add_core_vars 462 | fun:ngx_http_core_preconfiguration 463 | fun:ngx_http_block 464 | fun:ngx_conf_parse 465 | fun:ngx_init_cycle 466 | fun:main 467 | } 468 | { 469 | 470 | Memcheck:Leak 471 | fun:malloc 472 | fun:ngx_alloc 473 | fun:ngx_palloc_large 474 | fun:ngx_palloc 475 | fun:ngx_array_push 476 | fun:ngx_hash_add_key 477 | fun:ngx_http_add_variable 478 | fun:ngx_http_echo_add_variables 479 | fun:ngx_http_echo_handler_init 480 | fun:ngx_http_block 481 | fun:ngx_conf_parse 482 | fun:ngx_init_cycle 483 | } 484 | { 485 | 486 | Memcheck:Leak 487 | fun:malloc 488 | fun:ngx_alloc 489 | fun:ngx_palloc_large 490 | fun:ngx_palloc 491 | fun:ngx_pcalloc 492 | fun:ngx_http_upstream_drizzle_create_srv_conf 493 | fun:ngx_http_core_server 494 | fun:ngx_conf_parse 495 | fun:ngx_http_block 496 | fun:ngx_conf_parse 497 | fun:ngx_init_cycle 498 | fun:main 499 | } 500 | { 501 | 502 | Memcheck:Leak 503 | fun:malloc 504 | fun:ngx_alloc 505 | fun:ngx_palloc_large 506 | fun:ngx_palloc 507 | fun:ngx_pcalloc 508 | fun:ngx_http_upstream_drizzle_create_srv_conf 509 | fun:ngx_http_block 510 | fun:ngx_conf_parse 511 | fun:ngx_init_cycle 512 | fun:main 513 | } 514 | { 515 | 516 | Memcheck:Leak 517 | fun:malloc 518 | fun:ngx_alloc 519 | fun:ngx_palloc_large 520 | fun:ngx_palloc 521 | fun:ngx_array_push 522 | fun:ngx_hash_add_key 523 | fun:ngx_http_variables_add_core_vars 524 | fun:ngx_http_core_preconfiguration 525 | fun:ngx_http_block 526 | fun:ngx_conf_parse 527 | fun:ngx_init_cycle 528 | fun:main 529 | } 530 | { 531 | 532 | Memcheck:Leak 533 | fun:malloc 534 | fun:ngx_alloc 535 | fun:ngx_palloc_large 536 | fun:ngx_palloc 537 | fun:ngx_pcalloc 538 | fun:ngx_init_cycle 539 | fun:main 540 | } 541 | { 542 | 543 | Memcheck:Leak 544 | fun:malloc 545 | fun:ngx_alloc 546 | fun:ngx_palloc_large 547 | fun:ngx_palloc 548 | fun:ngx_hash_init 549 | fun:ngx_http_upstream_init_main_conf 550 | fun:ngx_http_block 551 | fun:ngx_conf_parse 552 | fun:ngx_init_cycle 553 | fun:main 554 | } 555 | { 556 | 557 | Memcheck:Leak 558 | fun:malloc 559 | fun:ngx_alloc 560 | fun:ngx_palloc_large 561 | fun:ngx_palloc 562 | fun:ngx_pcalloc 563 | fun:ngx_http_drizzle_keepalive_init 564 | fun:ngx_http_upstream_drizzle_init 565 | fun:ngx_http_upstream_init_main_conf 566 | fun:ngx_http_block 567 | fun:ngx_conf_parse 568 | fun:ngx_init_cycle 569 | fun:main 570 | } 571 | { 572 | 573 | Memcheck:Leak 574 | fun:malloc 575 | fun:ngx_alloc 576 | fun:ngx_palloc_large 577 | fun:ngx_palloc 578 | fun:ngx_hash_init 579 | fun:ngx_http_variables_init_vars 580 | fun:ngx_http_block 581 | fun:ngx_conf_parse 582 | fun:ngx_init_cycle 583 | fun:main 584 | } 585 | { 586 | 587 | Memcheck:Leak 588 | fun:memalign 589 | fun:posix_memalign 590 | fun:ngx_memalign 591 | fun:ngx_create_pool 592 | } 593 | { 594 | 595 | Memcheck:Leak 596 | fun:memalign 597 | fun:posix_memalign 598 | fun:ngx_memalign 599 | fun:ngx_palloc_block 600 | fun:ngx_palloc 601 | } 602 | { 603 | 604 | Memcheck:Cond 605 | fun:index 606 | fun:expand_dynamic_string_token 607 | fun:_dl_map_object 608 | fun:map_doit 609 | fun:_dl_catch_error 610 | fun:do_preload 611 | fun:dl_main 612 | } 613 | --------------------------------------------------------------------------------