| 262 | } |
| 263 | |
| 264 | int allow_access(const char *addr, const char **host_ptr, int i) |
| 265 | { |
| 266 | const char *allow_list = lp_hosts_allow(i); |
| 267 | const char *deny_list = lp_hosts_deny(i); |
| 268 | |
| 269 | if (allow_list && !*allow_list) |
| 270 | allow_list = NULL; |
| 271 | if (deny_list && !*deny_list) |
| 272 | deny_list = NULL; |
| 273 | |
| 274 | allow_forward_dns = lp_forward_lookup(i); |
| 275 | |
| 276 | /* If we match an allow-list item, we always allow access. */ |
| 277 | if (allow_list) { |
| 278 | if (access_match(allow_list, addr, host_ptr)) |
| 279 | return 1; |
| 280 | /* For an allow-list w/o a deny-list, disallow non-matches. */ |
| 281 | if (!deny_list) |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | /* If we match a deny-list item (and got past any allow-list |
| 286 | * items), we always disallow access. */ |
| 287 | if (deny_list && access_match(deny_list, addr, host_ptr)) |
| 288 | return 0; |
| 289 | |
| 290 | /* Allow all other access. */ |
| 291 | return 1; |
| 292 | } |
no test coverage detected