expand_remote_port 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. diff -ruN tcp_wrappers_7.6.orig/eval.c tcp_wrappers_7.6/eval.c
  2. --- tcp_wrappers_7.6.orig/eval.c 1995-01-30 19:51:46.000000000 +0100
  3. +++ tcp_wrappers_7.6/eval.c 2004-11-04 13:59:01.000000000 +0100
  4. @@ -98,6 +98,28 @@
  5. }
  6. }
  7. +/* eval_port - return string with the port */
  8. +char *eval_port(saddr)
  9. +#ifdef INET6
  10. +struct sockaddr *saddr;
  11. +#else
  12. +struct sockaddr_in *saddr;
  13. +#endif
  14. +{
  15. + static char port[16];
  16. + if (saddr != 0) {
  17. + sprintf(port, "%u",
  18. +#ifdef INET6
  19. + ntohs(((struct sockaddr_in *)saddr)->sin_port));
  20. +#else
  21. + ntohs(saddr->sin_port));
  22. +#endif
  23. + } else {
  24. + strcpy(port, "0");
  25. + }
  26. + return (port);
  27. +}
  28. +
  29. /* eval_client - return string with as much about the client as we know */
  30. char *eval_client(request)
  31. diff -ruN tcp_wrappers_7.6.orig/hosts_access.5 tcp_wrappers_7.6/hosts_access.5
  32. --- tcp_wrappers_7.6.orig/hosts_access.5 2004-11-04 13:17:45.000000000 +0100
  33. +++ tcp_wrappers_7.6/hosts_access.5 2004-11-04 13:55:32.000000000 +0100
  34. @@ -175,6 +175,8 @@
  35. unavailable.
  36. .IP "%n (%N)"
  37. The client (server) host name (or "unknown" or "paranoid").
  38. +.IP "%r (%R)"
  39. +The clients (servers) port number (or "0").
  40. .IP %p
  41. The daemon process id.
  42. .IP %s
  43. diff -ruN tcp_wrappers_7.6.orig/percent_x.c tcp_wrappers_7.6/percent_x.c
  44. --- tcp_wrappers_7.6.orig/percent_x.c 1994-12-28 17:42:38.000000000 +0100
  45. +++ tcp_wrappers_7.6/percent_x.c 2004-11-04 13:19:29.000000000 +0100
  46. @@ -63,6 +63,8 @@
  47. ch == 'n' ? eval_hostname(request->client) :
  48. ch == 'N' ? eval_hostname(request->server) :
  49. ch == 'p' ? eval_pid(request) :
  50. + ch == 'r' ? eval_port(request->client->sin) :
  51. + ch == 'R' ? eval_port(request->server->sin) :
  52. ch == 's' ? eval_server(request) :
  53. ch == 'u' ? eval_user(request) :
  54. ch == '%' ? "%" : (tcpd_warn("unrecognized %%%c", ch), "");
  55. diff -ruN tcp_wrappers_7.6.orig/tcpd.h tcp_wrappers_7.6/tcpd.h
  56. --- tcp_wrappers_7.6.orig/tcpd.h 2004-11-04 13:17:45.000000000 +0100
  57. +++ tcp_wrappers_7.6/tcpd.h 2004-11-04 13:19:13.000000000 +0100
  58. @@ -145,6 +145,11 @@
  59. extern char *eval_hostinfo(struct host_info *); /* host name or address */
  60. extern char *eval_client(struct request_info *);/* whatever is available */
  61. extern char *eval_server(struct request_info *);/* whatever is available */
  62. +#ifdef INET6
  63. +extern char *eval_port(struct sockaddr *);
  64. +#else
  65. +extern char *eval_port(struct sockaddr_in *);
  66. +#endif
  67. #define eval_daemon(r) ((r)->daemon) /* daemon process name */
  68. #define eval_pid(r) ((r)->pid) /* process id */