Merge lp:~sjinks/ngx-tcpwrappers/lp625299 into lp:ngx-tcpwrappers
- lp625299
- Merge into trunk
Proposed by
Volodymyr Kolesnykov
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Volodymyr Kolesnykov | ||||
Approved revision: | 5 | ||||
Merged at revision: | 5 | ||||
Proposed branch: | lp:~sjinks/ngx-tcpwrappers/lp625299 | ||||
Merge into: | lp:ngx-tcpwrappers | ||||
Diff against target: |
389 lines (+241/-65) 1 file modified
ngx_tcpwrappers.c (+241/-65) |
||||
To merge this branch: | bzr merge lp:~sjinks/ngx-tcpwrappers/lp625299 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Volodymyr Kolesnykov | Approve | ||
Review via email: mp+33924@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Volodymyr Kolesnykov (sjinks) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ngx_tcpwrappers.c' | |||
2 | --- ngx_tcpwrappers.c 2010-08-25 04:29:23 +0000 | |||
3 | +++ ngx_tcpwrappers.c 2010-08-27 15:56:41 +0000 | |||
4 | @@ -8,6 +8,7 @@ | |||
5 | 8 | #include <ngx_http.h> | 8 | #include <ngx_http.h> |
6 | 9 | #include <ngx_inet.h> | 9 | #include <ngx_inet.h> |
7 | 10 | #include <tcpd.h> | 10 | #include <tcpd.h> |
8 | 11 | #include <syslog.h> | ||
9 | 11 | 12 | ||
10 | 12 | /** | 13 | /** |
11 | 13 | * @brief Default daemon name for libwrap | 14 | * @brief Default daemon name for libwrap |
12 | @@ -18,78 +19,48 @@ | |||
13 | 18 | static ngx_mutex_t* libwrap_mutex; | 19 | static ngx_mutex_t* libwrap_mutex; |
14 | 19 | #endif | 20 | #endif |
15 | 20 | 21 | ||
74 | 21 | /** | 22 | static int orig_allow_severity; |
75 | 22 | * @param daemon Daemon name | 23 | static int orig_deny_severity; |
76 | 23 | * @param client_addr Client IP address | 24 | static int orig_hosts_access_verbose; |
77 | 24 | * @return Whether access should be granted | 25 | static char* orig_allow_table; |
78 | 25 | * @retval 0 No | 26 | static char* orig_deny_table; |
21 | 26 | * @retval 1 Yes | ||
22 | 27 | */ | ||
23 | 28 | static int my_hosts_ctl(char* daemon, char* client_addr) | ||
24 | 29 | { | ||
25 | 30 | int res; | ||
26 | 31 | |||
27 | 32 | #if (NGX_THREADS) | ||
28 | 33 | ngx_mutex_lock(libwrap_mutex); | ||
29 | 34 | #endif | ||
30 | 35 | |||
31 | 36 | res = hosts_ctl(daemon, "", client_addr, ""); | ||
32 | 37 | |||
33 | 38 | #if (NGX_THREADS) | ||
34 | 39 | ngx_mutex_unlock(libwrap_mutex); | ||
35 | 40 | #endif | ||
36 | 41 | return res; | ||
37 | 42 | } | ||
38 | 43 | |||
39 | 44 | /** | ||
40 | 45 | * @param daemon Daemon name | ||
41 | 46 | * @param conn nginx connection structure | ||
42 | 47 | * @return Whether access should be granted | ||
43 | 48 | * @retval 0 No | ||
44 | 49 | * @retval 1 Yes | ||
45 | 50 | */ | ||
46 | 51 | static int my_hosts_access(char* daemon, ngx_connection_t* conn) | ||
47 | 52 | { | ||
48 | 53 | int res; | ||
49 | 54 | struct request_info request_info; | ||
50 | 55 | |||
51 | 56 | #if (NGX_THREADS) | ||
52 | 57 | ngx_mutex_lock(libwrap_mutex); | ||
53 | 58 | #endif | ||
54 | 59 | |||
55 | 60 | request_init( | ||
56 | 61 | &request_info, | ||
57 | 62 | RQ_DAEMON, daemon, | ||
58 | 63 | RQ_USER, STRING_UNKNOWN, | ||
59 | 64 | RQ_CLIENT_SIN, conn->local_sockaddr, | ||
60 | 65 | RQ_SERVER_SIN, conn->sockaddr, | ||
61 | 66 | RQ_FILE, conn->fd, | ||
62 | 67 | NULL | ||
63 | 68 | ); | ||
64 | 69 | |||
65 | 70 | fromhost(&request_info); | ||
66 | 71 | |||
67 | 72 | res = hosts_access(&request_info); | ||
68 | 73 | |||
69 | 74 | #if (NGX_THREADS) | ||
70 | 75 | ngx_mutex_unlock(libwrap_mutex); | ||
71 | 76 | #endif | ||
72 | 77 | return res; | ||
73 | 78 | } | ||
79 | 79 | 27 | ||
80 | 80 | /** | 28 | /** |
81 | 81 | * @brief Module configuration structure | 29 | * @brief Module configuration structure |
82 | 82 | */ | 30 | */ |
83 | 83 | typedef struct { | 31 | typedef struct { |
87 | 84 | ngx_flag_t enabled; /**< tcpwrappers on */ | 32 | ngx_flag_t enabled; /**< tcpwrappers */ |
88 | 85 | ngx_flag_t thorough; /**< tcpwrappers_thorough on */ | 33 | ngx_flag_t thorough; /**< tcpwrappers_thorough */ |
89 | 86 | ngx_str_t daemon; /**< tcpwrappers_daemon */ | 34 | ngx_str_t daemon; /**< tcpwrappers_daemon */ |
90 | 35 | ngx_uint_t allow_severity; /**< tcpwrappers_allow_severity */ | ||
91 | 36 | ngx_uint_t deny_severity; /**< tcpwrappers_deny_severity */ | ||
92 | 37 | ngx_flag_t verbose_access; /**< tcpwrappers_verbose */ | ||
93 | 38 | ngx_str_t allow_file; /**< tcpwrappers_allow_file */ | ||
94 | 39 | ngx_str_t deny_file; /**< tcpwrappers_deny_file */ | ||
95 | 87 | } ngx_http_tcpwrappers_conf_t; | 40 | } ngx_http_tcpwrappers_conf_t; |
96 | 88 | 41 | ||
97 | 42 | /* Forward declarations */ | ||
98 | 89 | static ngx_int_t ngx_http_tcpwrappers_handler(ngx_http_request_t* r); | 43 | static ngx_int_t ngx_http_tcpwrappers_handler(ngx_http_request_t* r); |
99 | 90 | static ngx_int_t ngx_http_tcpwrappers_init(ngx_conf_t* cf); | 44 | static ngx_int_t ngx_http_tcpwrappers_init(ngx_conf_t* cf); |
100 | 91 | static void* ngx_http_tcpwrappers_create_loc_conf(ngx_conf_t* cf); | 45 | static void* ngx_http_tcpwrappers_create_loc_conf(ngx_conf_t* cf); |
101 | 92 | static char* ngx_http_tcpwrappers_merge_loc_conf(ngx_conf_t* cf, void* parent, void* child); | 46 | static char* ngx_http_tcpwrappers_merge_loc_conf(ngx_conf_t* cf, void* parent, void* child); |
102 | 47 | static int my_hosts_ctl(char* daemon, ngx_connection_t* conn, char* client_addr, ngx_http_tcpwrappers_conf_t* config); | ||
103 | 48 | static int my_hosts_access(char* daemon, ngx_connection_t* conn, ngx_http_tcpwrappers_conf_t* config); | ||
104 | 49 | |||
105 | 50 | /** | ||
106 | 51 | * @brief Severities for @c tcpwrappers_allow_severity and tcpwrappers_deny_severity | ||
107 | 52 | */ | ||
108 | 53 | static ngx_conf_enum_t severities[] = { | ||
109 | 54 | { ngx_string("emerg"), LOG_EMERG }, | ||
110 | 55 | { ngx_string("alert"), LOG_ALERT }, | ||
111 | 56 | { ngx_string("crit"), LOG_CRIT }, | ||
112 | 57 | { ngx_string("err"), LOG_ERR }, | ||
113 | 58 | { ngx_string("warning"), LOG_WARNING }, | ||
114 | 59 | { ngx_string("notice"), LOG_NOTICE }, | ||
115 | 60 | { ngx_string("info"), LOG_INFO }, | ||
116 | 61 | { ngx_string("debug"), LOG_DEBUG }, | ||
117 | 62 | { ngx_null_string, 0 } | ||
118 | 63 | }; | ||
119 | 93 | 64 | ||
120 | 94 | /** | 65 | /** |
121 | 95 | * @brief Configuration directives | 66 | * @brief Configuration directives |
122 | @@ -122,6 +93,51 @@ | |||
123 | 122 | NULL | 93 | NULL |
124 | 123 | }, | 94 | }, |
125 | 124 | 95 | ||
126 | 96 | { | ||
127 | 97 | ngx_string("tcpwrappers_allow_severity"), | ||
128 | 98 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LMT_CONF | NGX_CONF_TAKE1, | ||
129 | 99 | ngx_conf_set_enum_slot, | ||
130 | 100 | NGX_HTTP_LOC_CONF_OFFSET, | ||
131 | 101 | offsetof(ngx_http_tcpwrappers_conf_t, allow_severity), | ||
132 | 102 | &severities | ||
133 | 103 | }, | ||
134 | 104 | |||
135 | 105 | { | ||
136 | 106 | ngx_string("tcpwrappers_deny_severity"), | ||
137 | 107 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LMT_CONF | NGX_CONF_TAKE1, | ||
138 | 108 | ngx_conf_set_enum_slot, | ||
139 | 109 | NGX_HTTP_LOC_CONF_OFFSET, | ||
140 | 110 | offsetof(ngx_http_tcpwrappers_conf_t, deny_severity), | ||
141 | 111 | &severities | ||
142 | 112 | }, | ||
143 | 113 | |||
144 | 114 | { | ||
145 | 115 | ngx_string("tcpwrappers_verbose"), | ||
146 | 116 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LMT_CONF | NGX_CONF_TAKE1, | ||
147 | 117 | ngx_conf_set_flag_slot, | ||
148 | 118 | NGX_HTTP_LOC_CONF_OFFSET, | ||
149 | 119 | offsetof(ngx_http_tcpwrappers_conf_t, verbose_access), | ||
150 | 120 | NULL | ||
151 | 121 | }, | ||
152 | 122 | |||
153 | 123 | { | ||
154 | 124 | ngx_string("tcpwrappers_allow_file"), | ||
155 | 125 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LMT_CONF | NGX_CONF_TAKE1, | ||
156 | 126 | ngx_conf_set_str_slot, | ||
157 | 127 | NGX_HTTP_LOC_CONF_OFFSET, | ||
158 | 128 | offsetof(ngx_http_tcpwrappers_conf_t, allow_file), | ||
159 | 129 | NULL | ||
160 | 130 | }, | ||
161 | 131 | |||
162 | 132 | { | ||
163 | 133 | ngx_string("tcpwrappers_deny_file"), | ||
164 | 134 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LMT_CONF | NGX_CONF_TAKE1, | ||
165 | 135 | ngx_conf_set_str_slot, | ||
166 | 136 | NGX_HTTP_LOC_CONF_OFFSET, | ||
167 | 137 | offsetof(ngx_http_tcpwrappers_conf_t, deny_file), | ||
168 | 138 | NULL | ||
169 | 139 | }, | ||
170 | 140 | |||
171 | 125 | ngx_null_command | 141 | ngx_null_command |
172 | 126 | }; | 142 | }; |
173 | 127 | 143 | ||
174 | @@ -173,6 +189,7 @@ | |||
175 | 173 | ngx_http_tcpwrappers_conf_t* config = ngx_http_get_module_loc_conf(r, ngx_tcpwrappers_module); | 189 | ngx_http_tcpwrappers_conf_t* config = ngx_http_get_module_loc_conf(r, ngx_tcpwrappers_module); |
176 | 174 | int res; | 190 | int res; |
177 | 175 | char* daemon_name; | 191 | char* daemon_name; |
178 | 192 | char* p; | ||
179 | 176 | 193 | ||
180 | 177 | if (1 != config->enabled || !config->daemon.len) { | 194 | if (1 != config->enabled || !config->daemon.len) { |
181 | 178 | return NGX_DECLINED; | 195 | return NGX_DECLINED; |
182 | @@ -189,11 +206,11 @@ | |||
183 | 189 | } | 206 | } |
184 | 190 | 207 | ||
185 | 191 | daemon_name = (char*)alloca(config->daemon.len + 1); | 208 | daemon_name = (char*)alloca(config->daemon.len + 1); |
188 | 192 | memcpy(daemon_name, config->daemon.data, config->daemon.len); | 209 | p = ngx_cpymem(daemon_name, config->daemon.data, config->daemon.len); |
189 | 193 | daemon_name[config->daemon.len] = '\0'; | 210 | *p = '\0'; |
190 | 194 | 211 | ||
191 | 195 | if (1 == config->thorough) { | 212 | if (1 == config->thorough) { |
193 | 196 | res = my_hosts_access(daemon_name, r->connection); | 213 | res = my_hosts_access(daemon_name, r->connection, config); |
194 | 197 | } | 214 | } |
195 | 198 | else { | 215 | else { |
196 | 199 | char* client_addr = STRING_UNKNOWN; | 216 | char* client_addr = STRING_UNKNOWN; |
197 | @@ -205,7 +222,7 @@ | |||
198 | 205 | client_addr = addr; | 222 | client_addr = addr; |
199 | 206 | } | 223 | } |
200 | 207 | 224 | ||
202 | 208 | res = my_hosts_ctl(daemon_name, client_addr); | 225 | res = my_hosts_ctl(daemon_name, r->connection, client_addr, config); |
203 | 209 | } | 226 | } |
204 | 210 | 227 | ||
205 | 211 | if (!res) { | 228 | if (!res) { |
206 | @@ -226,6 +243,8 @@ | |||
207 | 226 | * @return Whether initialization succeeded | 243 | * @return Whether initialization succeeded |
208 | 227 | * @retval NGX_OK Yes | 244 | * @retval NGX_OK Yes |
209 | 228 | * @retval NGX_ERROR No | 245 | * @retval NGX_ERROR No |
210 | 246 | * @sa orig_allow_severity | ||
211 | 247 | * @sa orig_deny_severity | ||
212 | 229 | */ | 248 | */ |
213 | 230 | static ngx_int_t ngx_http_tcpwrappers_init(ngx_conf_t* cf) | 249 | static ngx_int_t ngx_http_tcpwrappers_init(ngx_conf_t* cf) |
214 | 231 | { | 250 | { |
215 | @@ -261,10 +280,23 @@ | |||
216 | 261 | static void* ngx_http_tcpwrappers_create_loc_conf(ngx_conf_t* cf) | 280 | static void* ngx_http_tcpwrappers_create_loc_conf(ngx_conf_t* cf) |
217 | 262 | { | 281 | { |
218 | 263 | ngx_http_tcpwrappers_conf_t* conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_tcpwrappers_conf_t)); | 282 | ngx_http_tcpwrappers_conf_t* conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_tcpwrappers_conf_t)); |
219 | 283 | |||
220 | 284 | orig_allow_severity = allow_severity; | ||
221 | 285 | orig_deny_severity = deny_severity; | ||
222 | 286 | resident = 1; | ||
223 | 287 | orig_hosts_access_verbose = hosts_access_verbose; | ||
224 | 288 | orig_allow_table = hosts_allow_table; | ||
225 | 289 | orig_deny_table = hosts_deny_table; | ||
226 | 290 | |||
227 | 264 | if (NULL != conf) { | 291 | if (NULL != conf) { |
228 | 265 | conf->enabled = NGX_CONF_UNSET; | 292 | conf->enabled = NGX_CONF_UNSET; |
229 | 266 | conf->thorough = NGX_CONF_UNSET; | 293 | conf->thorough = NGX_CONF_UNSET; |
230 | 267 | ngx_str_null(&conf->daemon); | 294 | ngx_str_null(&conf->daemon); |
231 | 295 | conf->allow_severity = NGX_CONF_UNSET; | ||
232 | 296 | conf->deny_severity = NGX_CONF_UNSET; | ||
233 | 297 | conf->verbose_access = NGX_CONF_UNSET; | ||
234 | 298 | ngx_str_null(&conf->allow_file); | ||
235 | 299 | ngx_str_null(&conf->deny_file); | ||
236 | 268 | } | 300 | } |
237 | 269 | 301 | ||
238 | 270 | return conf; | 302 | return conf; |
239 | @@ -287,6 +319,150 @@ | |||
240 | 287 | ngx_conf_merge_value(conf->enabled, prev->enabled, 0); | 319 | ngx_conf_merge_value(conf->enabled, prev->enabled, 0); |
241 | 288 | ngx_conf_merge_value(conf->thorough, prev->thorough, 0); | 320 | ngx_conf_merge_value(conf->thorough, prev->thorough, 0); |
242 | 289 | ngx_conf_merge_str_value(conf->daemon, prev->daemon, NGX_TCPWRAPPERS_DAEMON); | 321 | ngx_conf_merge_str_value(conf->daemon, prev->daemon, NGX_TCPWRAPPERS_DAEMON); |
243 | 322 | ngx_conf_merge_value(conf->allow_severity, prev->allow_severity, orig_allow_severity); | ||
244 | 323 | ngx_conf_merge_value(conf->deny_severity, prev->deny_severity, orig_deny_severity); | ||
245 | 324 | ngx_conf_merge_value(conf->verbose_access, prev->verbose_access, orig_hosts_access_verbose); | ||
246 | 325 | |||
247 | 326 | if (!conf->allow_file.data) { | ||
248 | 327 | if (prev->allow_file.data) { | ||
249 | 328 | conf->allow_file.len = prev->allow_file.len; | ||
250 | 329 | conf->allow_file.data = prev->allow_file.data; | ||
251 | 330 | } | ||
252 | 331 | else { | ||
253 | 332 | conf->allow_file.len = strlen(orig_allow_table); | ||
254 | 333 | conf->allow_file.data = (u_char*)orig_allow_table; | ||
255 | 334 | } | ||
256 | 335 | } | ||
257 | 336 | |||
258 | 337 | if (!conf->deny_file.data) { | ||
259 | 338 | if (prev->deny_file.data) { | ||
260 | 339 | conf->deny_file.len = prev->deny_file.len; | ||
261 | 340 | conf->deny_file.data = prev->deny_file.data; | ||
262 | 341 | } | ||
263 | 342 | else { | ||
264 | 343 | conf->deny_file.len = strlen(orig_deny_table); | ||
265 | 344 | conf->deny_file.data = (u_char*)orig_deny_table; | ||
266 | 345 | } | ||
267 | 346 | } | ||
268 | 290 | 347 | ||
269 | 291 | return NGX_CONF_OK; | 348 | return NGX_CONF_OK; |
270 | 292 | } | 349 | } |
271 | 350 | |||
272 | 351 | /** | ||
273 | 352 | * @param daemon Daemon name | ||
274 | 353 | * @param client_addr Client IP address | ||
275 | 354 | * @return Whether access should be granted | ||
276 | 355 | * @retval 0 No | ||
277 | 356 | * @retval 1 Yes | ||
278 | 357 | */ | ||
279 | 358 | static int my_hosts_ctl(char* daemon, ngx_connection_t* conn, char* client_addr, ngx_http_tcpwrappers_conf_t* config) | ||
280 | 359 | { | ||
281 | 360 | int res; | ||
282 | 361 | char* p; | ||
283 | 362 | char* allow_file; | ||
284 | 363 | char* deny_file; | ||
285 | 364 | |||
286 | 365 | p = alloca(config->allow_file.len + config->deny_file.len + 2); | ||
287 | 366 | allow_file = p; | ||
288 | 367 | |||
289 | 368 | p = ngx_cpymem(p, config->allow_file.data, config->allow_file.len); | ||
290 | 369 | *p = '\0'; | ||
291 | 370 | ++p; | ||
292 | 371 | deny_file = p; | ||
293 | 372 | p = ngx_cpymem(p, config->deny_file.data, config->deny_file.len); | ||
294 | 373 | *p = '\0'; | ||
295 | 374 | |||
296 | 375 | ngx_log_debug4( | ||
297 | 376 | NGX_LOG_DEBUG_HTTP, | ||
298 | 377 | conn->log, | ||
299 | 378 | 0, | ||
300 | 379 | "ngx_tcpwrappers: daemon: %s, allow file: %s, deny file: %s, verbosity: %d", | ||
301 | 380 | daemon, | ||
302 | 381 | allow_file, | ||
303 | 382 | deny_file, | ||
304 | 383 | config->verbose_access | ||
305 | 384 | ); | ||
306 | 385 | |||
307 | 386 | #if (NGX_THREADS) | ||
308 | 387 | ngx_mutex_lock(libwrap_mutex); | ||
309 | 388 | #endif | ||
310 | 389 | |||
311 | 390 | allow_severity = config->allow_severity; | ||
312 | 391 | deny_severity = config->deny_severity; | ||
313 | 392 | hosts_access_verbose = config->verbose_access; | ||
314 | 393 | hosts_allow_table = allow_file; | ||
315 | 394 | hosts_deny_table = deny_file; | ||
316 | 395 | |||
317 | 396 | res = hosts_ctl(daemon, "", client_addr, ""); | ||
318 | 397 | |||
319 | 398 | #if (NGX_THREADS) | ||
320 | 399 | ngx_mutex_unlock(libwrap_mutex); | ||
321 | 400 | #endif | ||
322 | 401 | return res; | ||
323 | 402 | } | ||
324 | 403 | |||
325 | 404 | /** | ||
326 | 405 | * @param daemon Daemon name | ||
327 | 406 | * @param conn nginx connection structure | ||
328 | 407 | * @return Whether access should be granted | ||
329 | 408 | * @retval 0 No | ||
330 | 409 | * @retval 1 Yes | ||
331 | 410 | */ | ||
332 | 411 | static int my_hosts_access(char* daemon, ngx_connection_t* conn, ngx_http_tcpwrappers_conf_t* config) | ||
333 | 412 | { | ||
334 | 413 | int res; | ||
335 | 414 | char* p; | ||
336 | 415 | char* allow_file; | ||
337 | 416 | char* deny_file; | ||
338 | 417 | struct request_info request_info; | ||
339 | 418 | |||
340 | 419 | p = alloca(config->allow_file.len + config->deny_file.len + 2); | ||
341 | 420 | allow_file = p; | ||
342 | 421 | |||
343 | 422 | p = ngx_cpymem(p, config->allow_file.data, config->allow_file.len); | ||
344 | 423 | *p = '\0'; | ||
345 | 424 | ++p; | ||
346 | 425 | deny_file = p; | ||
347 | 426 | p = ngx_cpymem(p, config->deny_file.data, config->deny_file.len); | ||
348 | 427 | *p = '\0'; | ||
349 | 428 | |||
350 | 429 | ngx_log_debug4( | ||
351 | 430 | NGX_LOG_DEBUG_HTTP, | ||
352 | 431 | conn->log, | ||
353 | 432 | 0, | ||
354 | 433 | "ngx_tcpwrappers: daemon: %s, allow file: %s, deny file: %s, verbosity: %d", | ||
355 | 434 | daemon, | ||
356 | 435 | allow_file, | ||
357 | 436 | deny_file, | ||
358 | 437 | config->verbose_access | ||
359 | 438 | ); | ||
360 | 439 | |||
361 | 440 | #if (NGX_THREADS) | ||
362 | 441 | ngx_mutex_lock(libwrap_mutex); | ||
363 | 442 | #endif | ||
364 | 443 | |||
365 | 444 | allow_severity = config->allow_severity; | ||
366 | 445 | deny_severity = config->deny_severity; | ||
367 | 446 | hosts_access_verbose = config->verbose_access; | ||
368 | 447 | hosts_allow_table = allow_file; | ||
369 | 448 | hosts_deny_table = deny_file; | ||
370 | 449 | |||
371 | 450 | request_init( | ||
372 | 451 | &request_info, | ||
373 | 452 | RQ_DAEMON, daemon, | ||
374 | 453 | RQ_USER, STRING_UNKNOWN, | ||
375 | 454 | RQ_CLIENT_SIN, conn->local_sockaddr, | ||
376 | 455 | RQ_SERVER_SIN, conn->sockaddr, | ||
377 | 456 | RQ_FILE, conn->fd, | ||
378 | 457 | NULL | ||
379 | 458 | ); | ||
380 | 459 | |||
381 | 460 | fromhost(&request_info); | ||
382 | 461 | |||
383 | 462 | res = hosts_access(&request_info); | ||
384 | 463 | |||
385 | 464 | #if (NGX_THREADS) | ||
386 | 465 | ngx_mutex_unlock(libwrap_mutex); | ||
387 | 466 | #endif | ||
388 | 467 | return res; | ||
389 | 468 | } |