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.

153 lines
5.1 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../tcp_wrappers/0013-tcp_wrappers-7.6-aclexec.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 2006-03-01 19:25:45.000000000 +0100
  18. +++ tcp_wrappers_7.6/hosts_access.c 2006-03-01 19:23:58.000000000 +0100
  19. @@ -82,6 +82,9 @@ int hosts_access_verbose = 0;
  20. */
  21. int resident = (-1); /* -1, 0: unknown; +1: yes */
  22. +#ifdef ACLEXEC
  23. +int aclexec_matched = 0;
  24. +#endif
  25. /* Forward declarations. */
  26. @@ -185,6 +188,12 @@ struct request_info *request;
  27. if (sh_cmd) {
  28. #ifdef PROCESS_OPTIONS
  29. process_options(sh_cmd, request);
  30. +# ifdef ACLEXEC
  31. + if (aclexec_matched) {
  32. + syslog(LOG_INFO, "aclexec returned %d", aclexec_matched);
  33. + match = NO;
  34. + }
  35. +# endif
  36. #else
  37. char cmd[BUFSIZ];
  38. shell_cmd(percent_x(cmd, sizeof(cmd), sh_cmd, request));
  39. diff -ruNp tcp_wrappers_7.6.orig/options.c tcp_wrappers_7.6/options.c
  40. --- tcp_wrappers_7.6.orig/options.c 1996-02-11 17:01:32.000000000 +0100
  41. +++ tcp_wrappers_7.6/options.c 2006-03-01 19:24:25.000000000 +0100
  42. @@ -47,6 +47,7 @@ static char sccsid[] = "@(#) options.c 1
  43. #include <ctype.h>
  44. #include <setjmp.h>
  45. #include <string.h>
  46. +#include <sys/wait.h>
  47. #ifndef MAXPATHNAMELEN
  48. #define MAXPATHNAMELEN BUFSIZ
  49. @@ -76,6 +77,7 @@ static void group_option(); /* execute
  50. static void umask_option(); /* execute "umask mask" option */
  51. static void linger_option(); /* execute "linger time" option */
  52. static void keepalive_option(); /* execute "keepalive" option */
  53. +static void aclexec_option(); /* execute "aclexec command" option */
  54. static void spawn_option(); /* execute "spawn command" option */
  55. static void twist_option(); /* execute "twist command" option */
  56. static void rfc931_option(); /* execute "rfc931" option */
  57. @@ -113,6 +115,9 @@ static struct option option_table[] = {
  58. "umask", umask_option, NEED_ARG,
  59. "linger", linger_option, NEED_ARG,
  60. "keepalive", keepalive_option, 0,
  61. +#ifdef ACLEXEC
  62. + "aclexec", aclexec_option, NEED_ARG | EXPAND_ARG,
  63. +#endif
  64. "spawn", spawn_option, NEED_ARG | EXPAND_ARG,
  65. "twist", twist_option, NEED_ARG | EXPAND_ARG | USE_LAST,
  66. "rfc931", rfc931_option, OPT_ARG,
  67. @@ -310,6 +315,54 @@ struct request_info *request;
  68. shell_cmd(value);
  69. }
  70. +#ifdef ACLEXEC
  71. +/* aclexec_option - spawn a shell command and check status */
  72. +
  73. +/* ARGSUSED */
  74. +
  75. +static void aclexec_option(value, request)
  76. +char *value;
  77. +struct request_info *request;
  78. +{
  79. + int status, child_pid, wait_pid;
  80. + extern int aclexec_matched;
  81. +
  82. + if (dry_run != 0)
  83. + return;
  84. +
  85. + child_pid = fork();
  86. +
  87. + /* Something went wrong: we MUST terminate the process. */
  88. + if (child_pid < 0) {
  89. + tcpd_warn("aclexec_option: /bin/sh: %m");
  90. + clean_exit(request);
  91. + }
  92. +
  93. + if (child_pid == 0) {
  94. + execl("/bin/sh", "sh", "-c", value, (char *) 0);
  95. +
  96. + /* Something went wrong. We MUST terminate the child process. */
  97. + tcpd_warn("execl /bin/sh: %m");
  98. + _exit(0);
  99. + }
  100. +
  101. + while ((wait_pid = wait(&status)) != -1 && wait_pid != child_pid)
  102. + /* void */ ;
  103. +
  104. + aclexec_matched = 1;
  105. +
  106. + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
  107. + aclexec_matched = 0;
  108. + }
  109. +
  110. + if (WIFSIGNALED(status))
  111. + tcpd_warn("process %d exited with signal %d", child_pid,
  112. + WTERMSIG(status));
  113. +
  114. + return;
  115. +}
  116. +#endif
  117. +
  118. /* linger_option - set the socket linger time (Marc Boucher <marc@cam.org>) */
  119. /* ARGSUSED */
  120. diff -ruNp tcp_wrappers_7.6.orig/hosts_options.5 tcp_wrappers_7.6/hosts_options.5
  121. --- tcp_wrappers_7.6.orig/hosts_options.5 2006-03-01 21:48:43.000000000 +0100
  122. +++ tcp_wrappers_7.6/hosts_options.5 2006-03-01 21:47:39.000000000 +0100
  123. @@ -52,6 +52,23 @@ ALL: ALL: ALLOW
  124. .sp
  125. Notice the leading dot on the domain name patterns.
  126. .SH RUNNING OTHER COMMANDS
  127. +.IP "aclexec shell_command"
  128. +Execute, in a child process, the specified shell command, after
  129. +performing the %<letter> expansions described in the hosts_access(5)
  130. +manual page. The command is executed with stdin, stdout and stderr
  131. +connected to the null device, so that it won't mess up the
  132. +conversation with the client host. Example:
  133. +.sp
  134. +.nf
  135. +.ti +3
  136. +smtp : ALL : aclexec checkdnsbl %a
  137. +.fi
  138. +.sp
  139. +executes, in a background child process, the shell command "checkdnsbl %a"
  140. +after replacing %a by the address of the remote host.
  141. +.sp
  142. +The connection will be allowed or refused depending on whether the
  143. +command returns a true or false exit status.
  144. .IP "spawn shell_command"
  145. Execute, in a child process, the specified shell command, after
  146. performing the %<letter> expansions described in the hosts_access(5)