oidentd-2.0.8-masquerading.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --- oidentd.orig/src/kernel/linux.c 2006-05-22 06:58:53.000000000 +0300
  2. +++ oidentd-2.0.8/src/kernel/linux.c 2007-07-11 21:28:56.000000000 +0300
  3. @@ -48,6 +48,7 @@
  4. #define CFILE6 "/proc/net/tcp6"
  5. #define MASQFILE "/proc/net/ip_masquerade"
  6. #define CONNTRACK "/proc/net/ip_conntrack"
  7. +#define NFCONNTRACK "/proc/net/nf_conntrack"
  8. static int netlink_sock;
  9. extern struct sockaddr_storage proxy;
  10. @@ -82,7 +83,15 @@
  11. debug("fopen: %s: %s", CONNTRACK, strerror(errno));
  12. return false;
  13. }
  14. - masq_fp = fopen("/dev/null", "r");
  15. +
  16. + masq_fp = fopen(NFCONNTRACK, "r");
  17. + if (masq_fp == NULL) {
  18. + if (errno != ENOENT) {
  19. + debug("fopen: %s: %s", NFCONNTRACK, strerror(errno));
  20. + return false;
  21. + }
  22. + masq_fp = fopen("/dev/null", "r");
  23. + }
  24. }
  25. netfilter = true;
  26. @@ -367,6 +376,15 @@
  27. &nport_temp, &mport_temp);
  28. }
  29. + if (ret != 21) {
  30. + ret = sscanf(buf,
  31. + "%*15s %*d %15s %*d %*d ESTABLISHED src=%d.%d.%d.%d dst=%d.%d.%d.%d sport=%d dport=%d packets=%*d bytes=%*d src=%d.%d.%d.%d dst=%d.%d.%d.%d sport=%d dport=%d",
  32. + proto, &l1, &l2, &l3, &l4, &r1, &r2, &r3, &r4,
  33. + &masq_lport_temp, &masq_fport_temp,
  34. + &nl1, &nl2, &nl3, &nl4, &nr1, &nr2, &nr3, &nr4,
  35. + &nport_temp, &mport_temp);
  36. + }
  37. +
  38. if (ret != 21)
  39. continue;