80 lines
2.8 KiB
80 lines
2.8 KiB
# --- SDE-COPYRIGHT-NOTE-BEGIN --- |
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
# |
|
# Filename: package/.../tcp_wrappers/0020-tcp_wrappers-7.6-match-port.patch |
|
# Copyright (C) 2011 The OpenSDE Project |
|
# |
|
# More information can be found in the files COPYING and README. |
|
# |
|
# This patch file is dual-licensed. It is available under the license the |
|
# patched project is licensed under, as long as it is an OpenSource license |
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms |
|
# of the GNU General Public License as published by the Free Software |
|
# Foundation; either version 2 of the License, or (at your option) any later |
|
# version. |
|
# --- SDE-COPYRIGHT-NOTE-END --- |
|
|
|
diff -ruNp tcp_wrappers_7.6.orig/hosts_access.c tcp_wrappers_7.6/hosts_access.c |
|
--- tcp_wrappers_7.6.orig/hosts_access.c 2007-01-08 01:31:32.000000000 +0100 |
|
+++ tcp_wrappers_7.6/hosts_access.c 2007-01-08 01:31:08.000000000 +0100 |
|
@@ -232,6 +232,36 @@ int (*match_fn) (); |
|
return (NO); |
|
} |
|
|
|
+/* |
|
+ * daemon_or_port_match - match server information: if the server endpoint |
|
+ * pattern is a port number, match against port number of connection; |
|
+ * otherwise match against daemon executable name |
|
+ */ |
|
+ |
|
+static int daemon_or_port_match(char *tok, struct request_info *request) { |
|
+ unsigned int port, sin_port; |
|
+ char junk; |
|
+ |
|
+ /* daemon name */ |
|
+ if (sscanf(tok, "%u%c", &port, &junk) != 1 || port > 65535) |
|
+ return (string_match(tok, eval_daemon(request))); |
|
+ |
|
+ /* port number */ |
|
+ if (!request->server->sin) |
|
+ return (NO); |
|
+ |
|
+#ifdef INET6 |
|
+ sin_port = ntohs(((struct sockaddr_in *)request->server->sin)->sin_port); |
|
+#else |
|
+ sin_port = ntohs(request->server->sin->sin_port); |
|
+#endif |
|
+ |
|
+ if (port == sin_port) |
|
+ return (YES); |
|
+ else |
|
+ return (NO); |
|
+} |
|
+ |
|
/* server_match - match server information */ |
|
|
|
static int server_match(tok, request) |
|
@@ -241,9 +271,9 @@ struct request_info *request; |
|
char *host; |
|
|
|
if ((host = split_at(tok + 1, '@')) == 0) { /* plain daemon */ |
|
- return (string_match(tok, eval_daemon(request))); |
|
+ return (daemon_or_port_match(tok, request)); |
|
} else { /* daemon@host */ |
|
- return (string_match(tok, eval_daemon(request)) |
|
+ return (daemon_or_port_match(tok, request) |
|
&& host_match(host, request->server)); |
|
} |
|
} |
|
diff -ruNp tcp_wrappers_7.6.orig/hosts_access.5 tcp_wrappers_7.6/hosts_access.5 |
|
--- tcp_wrappers_7.6.orig/hosts_access.5 2007-01-08 01:31:32.000000000 +0100 |
|
+++ tcp_wrappers_7.6/hosts_access.5 2007-01-08 01:30:18.000000000 +0100 |
|
@@ -51,7 +51,7 @@ being optional: |
|
daemon_list : client_list [ : shell_command ] |
|
.PP |
|
\fIdaemon_list\fR is a list of one or more daemon process names |
|
-(argv[0] values) or wildcards (see below). |
|
+(argv[0] values) or server port numbers or wildcards (see below). |
|
.PP |
|
\fIclient_list\fR is a list |
|
of one or more host names, host addresses, patterns or wildcards (see
|
|
|