| 1 |
diff -ruNp tcp_wrappers_7.6.orig/hosts_access.c tcp_wrappers_7.6/hosts_access.c |
| 2 |
--- tcp_wrappers_7.6.orig/hosts_access.c 2007-01-08 01:31:32.000000000 +0100 |
| 3 |
+++ tcp_wrappers_7.6/hosts_access.c 2007-01-08 01:31:08.000000000 +0100 |
| 4 |
@@ -232,6 +232,36 @@ int (*match_fn) (); |
| 5 |
return (NO); |
| 6 |
} |
| 7 |
|
| 8 |
+/* |
| 9 |
+ * daemon_or_port_match - match server information: if the server endpoint |
| 10 |
+ * pattern is a port number, match against port number of connection; |
| 11 |
+ * otherwise match against daemon executable name |
| 12 |
+ */ |
| 13 |
+ |
| 14 |
+static int daemon_or_port_match(char *tok, struct request_info *request) { |
| 15 |
+ unsigned int port, sin_port; |
| 16 |
+ char junk; |
| 17 |
+ |
| 18 |
+ /* daemon name */ |
| 19 |
+ if (sscanf(tok, "%u%c", &port, &junk) != 1 || port > 65535) |
| 20 |
+ return (string_match(tok, eval_daemon(request))); |
| 21 |
+ |
| 22 |
+ /* port number */ |
| 23 |
+ if (!request->server->sin) |
| 24 |
+ return (NO); |
| 25 |
+ |
| 26 |
+#ifdef INET6 |
| 27 |
+ sin_port = ntohs(((struct sockaddr_in *)request->server->sin)->sin_port); |
| 28 |
+#else |
| 29 |
+ sin_port = ntohs(request->server->sin->sin_port); |
| 30 |
+#endif |
| 31 |
+ |
| 32 |
+ if (port == sin_port) |
| 33 |
+ return (YES); |
| 34 |
+ else |
| 35 |
+ return (NO); |
| 36 |
+} |
| 37 |
+ |
| 38 |
/* server_match - match server information */ |
| 39 |
|
| 40 |
static int server_match(tok, request) |
| 41 |
@@ -241,9 +271,9 @@ struct request_info *request; |
| 42 |
char *host; |
| 43 |
|
| 44 |
if ((host = split_at(tok + 1, '@')) == 0) { /* plain daemon */ |
| 45 |
- return (string_match(tok, eval_daemon(request))); |
| 46 |
+ return (daemon_or_port_match(tok, request)); |
| 47 |
} else { /* daemon@host */ |
| 48 |
- return (string_match(tok, eval_daemon(request)) |
| 49 |
+ return (daemon_or_port_match(tok, request) |
| 50 |
&& host_match(host, request->server)); |
| 51 |
} |
| 52 |
} |
| 53 |
diff -ruNp tcp_wrappers_7.6.orig/hosts_access.5 tcp_wrappers_7.6/hosts_access.5 |
| 54 |
--- tcp_wrappers_7.6.orig/hosts_access.5 2007-01-08 01:31:32.000000000 +0100 |
| 55 |
+++ tcp_wrappers_7.6/hosts_access.5 2007-01-08 01:30:18.000000000 +0100 |
| 56 |
@@ -51,7 +51,7 @@ being optional: |
| 57 |
daemon_list : client_list [ : shell_command ] |
| 58 |
.PP |
| 59 |
\fIdaemon_list\fR is a list of one or more daemon process names |
| 60 |
-(argv[0] values) or wildcards (see below). |
| 61 |
+(argv[0] values) or server port numbers or wildcards (see below). |
| 62 |
.PP |
| 63 |
\fIclient_list\fR is a list |
| 64 |
of one or more host names, host addresses, patterns or wildcards (see |