1
0

patch-tcpdchk_c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --- tcp_wrappers_7.6.orig/tcpdchk.c 1997-02-12 02:13:25.000000000 +0100
  2. +++ tcp_wrappers_7.6/tcpdchk.c 2009-06-05 18:45:03.000000000 +0200
  3. @@ -350,6 +350,8 @@ char *pat;
  4. {
  5. if (pat[0] == '@') {
  6. tcpd_warn("%s: daemon name begins with \"@\"", pat);
  7. + } else if (pat[0] == '/') {
  8. + tcpd_warn("%s: daemon name begins with \"/\"", pat);
  9. } else if (pat[0] == '.') {
  10. tcpd_warn("%s: daemon name begins with dot", pat);
  11. } else if (pat[strlen(pat) - 1] == '.') {
  12. @@ -382,6 +384,8 @@ char *pat;
  13. {
  14. if (pat[0] == '@') { /* @netgroup */
  15. tcpd_warn("%s: user name begins with \"@\"", pat);
  16. + } else if (pat[0] == '/') {
  17. + tcpd_warn("%s: user name begins with \"/\"", pat);
  18. } else if (pat[0] == '.') {
  19. tcpd_warn("%s: user name begins with dot", pat);
  20. } else if (pat[strlen(pat) - 1] == '.') {
  21. @@ -402,8 +406,13 @@ char *pat;
  22. static int check_host(pat)
  23. char *pat;
  24. {
  25. + char buf[BUFSIZ];
  26. char *mask;
  27. int addr_count = 1;
  28. + FILE *fp;
  29. + struct tcpd_context saved_context;
  30. + char *cp;
  31. + char *wsp = " \t\r\n";
  32. if (pat[0] == '@') { /* @netgroup */
  33. #ifdef NO_NETGRENT
  34. @@ -422,6 +431,21 @@ char *pat;
  35. tcpd_warn("netgroup support disabled");
  36. #endif
  37. #endif
  38. + } else if (pat[0] == '/') { /* /path/name */
  39. + if ((fp = fopen(pat, "r")) != 0) {
  40. + saved_context = tcpd_context;
  41. + tcpd_context.file = pat;
  42. + tcpd_context.line = 0;
  43. + while (fgets(buf, sizeof(buf), fp)) {
  44. + tcpd_context.line++;
  45. + for (cp = strtok(buf, wsp); cp; cp = strtok((char *) 0, wsp))
  46. + check_host(cp);
  47. + }
  48. + tcpd_context = saved_context;
  49. + fclose(fp);
  50. + } else if (errno != ENOENT) {
  51. + tcpd_warn("open %s: %m", pat);
  52. + }
  53. } else if (mask = split_at(pat, '/')) { /* network/netmask */
  54. if (dot_quad_addr(pat) == INADDR_NONE
  55. || dot_quad_addr(mask) == INADDR_NONE)