patch-hosts_access_c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --- tcp_wrappers_7.6.orig/hosts_access.c 1997-02-12 02:13:23.000000000 +0100
  2. +++ tcp_wrappers_7.6/hosts_access.c 2009-06-05 18:45:03.000000000 +0200
  3. @@ -240,6 +240,26 @@ struct request_info *request;
  4. }
  5. }
  6. +/* hostfile_match - look up host patterns from file */
  7. +
  8. +static int hostfile_match(path, host)
  9. +char *path;
  10. +struct hosts_info *host;
  11. +{
  12. + char tok[BUFSIZ];
  13. + int match = NO;
  14. + FILE *fp;
  15. +
  16. + if ((fp = fopen(path, "r")) != 0) {
  17. + while (fscanf(fp, "%s", tok) == 1 && !(match = host_match(tok, host)))
  18. + /* void */ ;
  19. + fclose(fp);
  20. + } else if (errno != ENOENT) {
  21. + tcpd_warn("open %s: %m", path);
  22. + }
  23. + return (match);
  24. +}
  25. +
  26. /* host_match - match host name and/or address against pattern */
  27. static int host_match(tok, host)
  28. @@ -267,6 +287,8 @@ struct host_info *host;
  29. tcpd_warn("netgroup support is disabled"); /* not tcpd_jump() */
  30. return (NO);
  31. #endif
  32. + } else if (tok[0] == '/') { /* /file hack */
  33. + return (hostfile_match(tok, host));
  34. } else if (STR_EQ(tok, "KNOWN")) { /* check address and name */
  35. char *name = eval_hostname(host);
  36. return (STR_NE(eval_hostaddr(host), unknown) && HOSTNAME_KNOWN(name));