summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/tcp-wrappers/tcp-wrappers-7.6/expand_remote_port.patch
blob: 0c54ba6d35ba1539a8c6c07d00251540e21e20d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Upstream-Status: Inactive-Upstream [current release is from 1997; no vcs anywhere]

diff -ruN tcp_wrappers_7.6.orig/eval.c tcp_wrappers_7.6/eval.c
--- tcp_wrappers_7.6.orig/eval.c	1995-01-30 19:51:46.000000000 +0100
+++ tcp_wrappers_7.6/eval.c	2004-11-04 13:59:01.000000000 +0100
@@ -98,6 +98,28 @@
     }
 }
 
+/* eval_port - return string with the port */
+char   *eval_port(saddr)
+#ifdef INET6
+struct sockaddr *saddr;
+#else
+struct sockaddr_in *saddr;
+#endif
+{
+    static char port[16];
+    if (saddr != 0) {
+        sprintf(port, "%u",
+#ifdef INET6
+            ntohs(((struct sockaddr_in *)saddr)->sin_port));
+#else
+            ntohs(saddr->sin_port));
+#endif
+    } else {
+	strcpy(port, "0");
+    }
+    return (port);
+}
+
 /* eval_client - return string with as much about the client as we know */
 
 char   *eval_client(request)
diff -ruN tcp_wrappers_7.6.orig/hosts_access.5 tcp_wrappers_7.6/hosts_access.5
--- tcp_wrappers_7.6.orig/hosts_access.5	2004-11-04 13:17:45.000000000 +0100
+++ tcp_wrappers_7.6/hosts_access.5	2004-11-04 13:55:32.000000000 +0100
@@ -175,6 +175,8 @@
 unavailable.
 .IP "%n (%N)"
 The client (server) host name (or "unknown" or "paranoid").
+.IP "%r (%R)"
+The clients (servers) port number (or "0").
 .IP %p
 The daemon process id.
 .IP %s
diff -ruN tcp_wrappers_7.6.orig/percent_x.c tcp_wrappers_7.6/percent_x.c
--- tcp_wrappers_7.6.orig/percent_x.c	1994-12-28 17:42:38.000000000 +0100
+++ tcp_wrappers_7.6/percent_x.c	2004-11-04 13:19:29.000000000 +0100
@@ -63,6 +63,8 @@
 		ch == 'n' ? eval_hostname(request->client) :
 		ch == 'N' ? eval_hostname(request->server) :
 		ch == 'p' ? eval_pid(request) :
+		ch == 'r' ? eval_port(request->client->sin) :
+		ch == 'R' ? eval_port(request->server->sin) :
 		ch == 's' ? eval_server(request) :
 		ch == 'u' ? eval_user(request) :
 		ch == '%' ? "%" : (tcpd_warn("unrecognized %%%c", ch), "");
diff -ruN tcp_wrappers_7.6.orig/tcpd.h tcp_wrappers_7.6/tcpd.h
--- tcp_wrappers_7.6.orig/tcpd.h	2004-11-04 13:17:45.000000000 +0100
+++ tcp_wrappers_7.6/tcpd.h	2004-11-04 13:19:13.000000000 +0100
@@ -145,6 +145,11 @@
 extern char *eval_hostinfo(struct host_info *);	/* host name or address */
 extern char *eval_client(struct request_info *);/* whatever is available */
 extern char *eval_server(struct request_info *);/* whatever is available */
+#ifdef INET6
+extern char *eval_port(struct sockaddr *);
+#else
+extern char *eval_port(struct sockaddr_in *);
+#endif
 #define eval_daemon(r)	((r)->daemon)	/* daemon process name */
 #define eval_pid(r)	((r)->pid)	/* process id */