OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.8 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../tcp_wrappers/0020-tcp_wrappers-7.6-match-port.patch
  5. # Copyright (C) 2011 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. diff -ruNp tcp_wrappers_7.6.orig/hosts_access.c tcp_wrappers_7.6/hosts_access.c
  17. --- tcp_wrappers_7.6.orig/hosts_access.c 2007-01-08 01:31:32.000000000 +0100
  18. +++ tcp_wrappers_7.6/hosts_access.c 2007-01-08 01:31:08.000000000 +0100
  19. @@ -232,6 +232,36 @@ int (*match_fn) ();
  20. return (NO);
  21. }
  22. +/*
  23. + * daemon_or_port_match - match server information: if the server endpoint
  24. + * pattern is a port number, match against port number of connection;
  25. + * otherwise match against daemon executable name
  26. + */
  27. +
  28. +static int daemon_or_port_match(char *tok, struct request_info *request) {
  29. + unsigned int port, sin_port;
  30. + char junk;
  31. +
  32. + /* daemon name */
  33. + if (sscanf(tok, "%u%c", &port, &junk) != 1 || port > 65535)
  34. + return (string_match(tok, eval_daemon(request)));
  35. +
  36. + /* port number */
  37. + if (!request->server->sin)
  38. + return (NO);
  39. +
  40. +#ifdef INET6
  41. + sin_port = ntohs(((struct sockaddr_in *)request->server->sin)->sin_port);
  42. +#else
  43. + sin_port = ntohs(request->server->sin->sin_port);
  44. +#endif
  45. +
  46. + if (port == sin_port)
  47. + return (YES);
  48. + else
  49. + return (NO);
  50. +}
  51. +
  52. /* server_match - match server information */
  53. static int server_match(tok, request)
  54. @@ -241,9 +271,9 @@ struct request_info *request;
  55. char *host;
  56. if ((host = split_at(tok + 1, '@')) == 0) { /* plain daemon */
  57. - return (string_match(tok, eval_daemon(request)));
  58. + return (daemon_or_port_match(tok, request));
  59. } else { /* daemon@host */
  60. - return (string_match(tok, eval_daemon(request))
  61. + return (daemon_or_port_match(tok, request)
  62. && host_match(host, request->server));
  63. }
  64. }
  65. diff -ruNp tcp_wrappers_7.6.orig/hosts_access.5 tcp_wrappers_7.6/hosts_access.5
  66. --- tcp_wrappers_7.6.orig/hosts_access.5 2007-01-08 01:31:32.000000000 +0100
  67. +++ tcp_wrappers_7.6/hosts_access.5 2007-01-08 01:30:18.000000000 +0100
  68. @@ -51,7 +51,7 @@ being optional:
  69. daemon_list : client_list [ : shell_command ]
  70. .PP
  71. \fIdaemon_list\fR is a list of one or more daemon process names
  72. -(argv[0] values) or wildcards (see below).
  73. +(argv[0] values) or server port numbers or wildcards (see below).
  74. .PP
  75. \fIclient_list\fR is a list
  76. of one or more host names, host addresses, patterns or wildcards (see