postfix.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. https://rt.openpkg.org/Ticket/Display.html?id=285
  2. USE_SOFTLIMITONLY kludge
  3. Index: src/util/file_limit.c
  4. --- src/util/file_limit.c.orig 2003-10-22 20:48:36 +0200
  5. +++ src/util/file_limit.c 2005-02-06 13:34:59 +0100
  6. @@ -80,12 +80,21 @@
  7. void set_file_limit(off_t limit)
  8. {
  9. #ifdef USE_ULIMIT
  10. +#ifdef USE_SOFTLIMITONLY
  11. +#error "USE_ULIMIT and USE_SOFTLIMITONLY are mutual exclusive"
  12. +#endif
  13. if (ulimit(UL_SETFSIZE, limit / ULIMIT_BLOCK_SIZE) < 0)
  14. msg_fatal("ulimit: %m");
  15. #else
  16. struct rlimit rlim;
  17. +#ifdef USE_SOFTLIMITONLY
  18. + if (getrlimit(RLIMIT_FSIZE, &rlim) < 0)
  19. + rlim.rlim_max = RLIM_INFINITY;
  20. + rlim.rlim_cur = limit;
  21. +#else
  22. rlim.rlim_cur = rlim.rlim_max = limit;
  23. +#endif
  24. if (setrlimit(RLIMIT_FSIZE, &rlim) < 0)
  25. msg_fatal("setrlimit: %m");
  26. #ifdef SIGXFSZ
  27. Index: src/util/msg_syslog.c
  28. --- src/util/msg_syslog.c.orig 2004-01-04 17:14:58 +0100
  29. +++ src/util/msg_syslog.c 2005-02-06 13:34:59 +0100
  30. @@ -50,6 +50,11 @@
  31. #include <syslog.h>
  32. #include <string.h>
  33. #include <time.h>
  34. +#ifdef USE_SOFTLIMITONLY
  35. +#include <sys/time.h>
  36. +#include <sys/resource.h>
  37. +#include <signal.h>
  38. +#endif
  39. /* Application-specific. */
  40. @@ -144,6 +149,9 @@
  41. static void msg_syslog_print(int level, const char *text)
  42. {
  43. +#ifdef USE_SOFTLIMITONLY
  44. + struct rlimit save, rlim;
  45. +#endif
  46. static int log_level[] = {
  47. LOG_INFO, LOG_WARNING, LOG_ERR, LOG_CRIT, LOG_CRIT,
  48. };
  49. @@ -154,6 +162,15 @@
  50. if (level < 0 || level >= (int) (sizeof(log_level) / sizeof(log_level[0])))
  51. msg_panic("msg_syslog_print: invalid severity level: %d", level);
  52. +#ifdef USE_SOFTLIMITONLY
  53. + if (getrlimit(RLIMIT_FSIZE, &save) < 0) {
  54. + save.rlim_cur = RLIM_INFINITY;
  55. + save.rlim_max = RLIM_INFINITY;
  56. + }
  57. + rlim.rlim_cur = save.rlim_max;
  58. + rlim.rlim_max = save.rlim_max;
  59. + (void)setrlimit(RLIMIT_FSIZE, &rlim);
  60. +#endif
  61. if (level == MSG_INFO) {
  62. syslog(syslog_facility | log_level[level], "%.*s",
  63. (int) MSG_SYSLOG_RECLEN, text);
  64. @@ -161,6 +178,9 @@
  65. syslog(syslog_facility | log_level[level], "%s: %.*s",
  66. severity_name[level], (int) MSG_SYSLOG_RECLEN, text);
  67. }
  68. +#ifdef USE_SOFTLIMITONLY
  69. + (void)setrlimit(RLIMIT_FSIZE, &save);
  70. +#endif
  71. }
  72. /* msg_syslog_init - initialize */
  73. -----------------------------------------------------------------------------
  74. Steffen Hansen has patched postfix-2.1.5 for making various client
  75. information (ip, hostname etc.) available to processes run via the pipe
  76. transport. The code has been accepted for postfix-2.2, but depending on
  77. how far away from release that is, it might be a good idea to have the
  78. patch in OpenPKG.
  79. Index: man/man8/pipe.8
  80. --- man/man8/pipe.8.orig 2004-08-09 16:51:07 +0200
  81. +++ man/man8/pipe.8 2005-02-06 13:34:59 +0100
  82. @@ -128,6 +128,22 @@
  83. and replaced with corresponding information from the Postfix queue
  84. manager delivery request:
  85. .RS
  86. +.IP \fB${\fBclient_address\fR}\fR
  87. +This macro expands to the remote client network address.
  88. +.sp
  89. +This is available in Postfix 2.2 and later.
  90. +.IP \fB${\fBclient_helo\fR}\fR
  91. +This macro expands to the remote client HELO command parameter.
  92. +.sp
  93. +This is available in Postfix 2.2 and later.
  94. +.IP \fB${\fBclient_hostname\fR}\fR
  95. +This macro expands to the remote client hostname.
  96. +.sp
  97. +This is available in Postfix 2.2 and later.
  98. +.IP \fB${\fBclient_protocol\fR}\fR
  99. +This macro expands to the remote client protocol.
  100. +.sp
  101. +This is available in Postfix 2.2 and later.
  102. .IP \fB${\fBextension\fR}\fR
  103. This macro expands to the extension part of a recipient address.
  104. For example, with an address \fIuser+foo@domain\fR the extension is
  105. Index: src/pipe/pipe.c
  106. --- src/pipe/pipe.c.orig 2004-07-24 01:09:21 +0200
  107. +++ src/pipe/pipe.c 2005-02-06 13:34:59 +0100
  108. @@ -332,6 +332,10 @@
  109. #define PIPE_DICT_EXTENSION "extension" /* key */
  110. #define PIPE_DICT_MAILBOX "mailbox" /* key */
  111. #define PIPE_DICT_SIZE "size" /* key */
  112. +#define PIPE_DICT_CLIENT_ADDR "client_address" /* key */
  113. +#define PIPE_DICT_CLIENT_NAME "client_hostname" /* key */
  114. +#define PIPE_DICT_CLIENT_PROTO "client_protocol" /* key */
  115. +#define PIPE_DICT_CLIENT_HELO "client_helo" /* key */
  116. /*
  117. * Flags used to pass back the type of special parameter found by
  118. @@ -412,6 +416,10 @@
  119. PIPE_DICT_EXTENSION, PIPE_FLAG_EXTENSION,
  120. PIPE_DICT_MAILBOX, PIPE_FLAG_MAILBOX,
  121. PIPE_DICT_SIZE, 0,
  122. + PIPE_DICT_CLIENT_ADDR, 0,
  123. + PIPE_DICT_CLIENT_NAME, 0,
  124. + PIPE_DICT_CLIENT_PROTO, 0,
  125. + PIPE_DICT_CLIENT_HELO, 0,
  126. 0, 0,
  127. };
  128. struct cmd_flags *p;
  129. @@ -954,6 +962,15 @@
  130. dict_update(PIPE_DICT_TABLE, PIPE_DICT_SIZE, STR(buf));
  131. vstring_free(buf);
  132. + dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_ADDR,
  133. + request->client_addr);
  134. + dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_HELO,
  135. + request->client_helo);
  136. + dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_NAME,
  137. + request->client_name);
  138. + dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_PROTO,
  139. + request->client_proto);
  140. +
  141. if ((expanded_argv = expand_argv(service, attr.command,
  142. rcpt_list, attr.flags)) == 0) {
  143. deliver_status = eval_command_status(PIPE_STAT_DEFER, service,
  144. -----------------------------------------------------------------------------
  145. Index: makedefs
  146. --- makedefs.orig 2004-04-14 20:59:43 +0200
  147. +++ makedefs 2005-02-06 13:34:59 +0100
  148. @@ -93,6 +93,8 @@
  149. ;;
  150. FreeBSD.5*) SYSTYPE=FREEBSD5
  151. ;;
  152. + FreeBSD.6*) SYSTYPE=FREEBSD6
  153. + ;;
  154. OpenBSD.2*) SYSTYPE=OPENBSD2
  155. ;;
  156. OpenBSD.3*) SYSTYPE=OPENBSD3
  157. Index: src/util/sys_defs.h
  158. --- src/util/sys_defs.h.orig 2004-08-01 23:05:23 +0200
  159. +++ src/util/sys_defs.h 2005-02-06 13:34:59 +0100
  160. @@ -24,7 +24,7 @@
  161. * 4.4BSD and close derivatives.
  162. */
  163. #if defined(FREEBSD2) || defined(FREEBSD3) || defined(FREEBSD4) \
  164. - || defined(FREEBSD5) \
  165. + || defined(FREEBSD5) || defined(FREEBSD6) \
  166. || defined(BSDI2) || defined(BSDI3) || defined(BSDI4) \
  167. || defined(OPENBSD2) || defined(OPENBSD3) \
  168. || defined(NETBSD1) || defined(NETBSD2) \