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