]> git.pld-linux.org Git - packages/postfix.git/blame - postfix-size-check-before-proxy.patch
- proper name for dict subpackages
[packages/postfix.git] / postfix-size-check-before-proxy.patch
CommitLineData
6e624b19
JR
1Backported from 2.3:
2
3 Bugfix: the SMTP server now separates the message size check
4 from the queue space check, so that the size check can be
5 done before an SMTPD proxy filter. Files: smtpd/smtpd.c,
6 smtpd/smtpd_check.c.
7
8diff -ur postfix-2.2.3/src/smtpd/smtpd.c postfix-2.2.3-size/src/smtpd/smtpd.c
9--- postfix-2.2.3/src/smtpd/smtpd.c 2005-03-09 21:07:43.000000000 +0100
10+++ postfix-2.2.3-size/src/smtpd/smtpd.c 2005-09-07 01:57:23.933600904 +0200
11@@ -1555,6 +1555,10 @@
12 return (-1);
13 }
14 }
15+ if ((err = smtpd_check_size(state, state->msg_size)) != 0) {
16+ smtpd_chat_reply(state, "%s", err);
17+ return (-1);
18+ }
19 if (verp_delims && argv[2].strval[0] == 0) {
20 smtpd_chat_reply(state, "503 Error: %s requires non-null sender",
21 VERP_CMD);
22@@ -1573,7 +1577,7 @@
23 * Check the queue file space, if applicable.
24 */
25 if (!USE_SMTPD_PROXY(state)) {
26- if ((err = smtpd_check_size(state, state->msg_size)) != 0) {
27+ if ((err = smtpd_check_queue(state)) != 0) {
28 smtpd_chat_reply(state, "%s", err);
29 return (-1);
30 }
31diff -ur postfix-2.2.3/src/smtpd/smtpd_check.c postfix-2.2.3-size/src/smtpd/smtpd_check.c
32--- postfix-2.2.3/src/smtpd/smtpd_check.c 2005-03-05 02:13:10.000000000 +0100
33+++ postfix-2.2.3-size/src/smtpd/smtpd_check.c 2005-09-07 02:04:32.193697648 +0200
34@@ -39,6 +39,13 @@
35 /*
36 /* char *smtpd_check_eod(state)
37 /* SMTPD_STATE *state;
38+/*
39+/* char *smtpd_check_size(state, size)
40+/* SMTPD_STATE *state;
41+/* off_t size;
42+/*
43+/* char *smtpd_check_queue(state)
44+/* SMTPD_STATE *state;
45 /* DESCRIPTION
46 /* This module implements additional checks on SMTP client requests.
47 /* A client request is validated in the context of the session state.
48@@ -101,11 +108,13 @@
49 /* .PP
50 /* smtpd_check_size() checks if a message with the given size can
51 /* be received (zero means that the message size is unknown). The
52-/* message is rejected when:
53-/* .IP \(bu
54-/* The message size exceeds the non-zero bound specified with the
55+/* message is rejected when
56+/* the message size exceeds the non-zero bound specified with the
57 /* \fImessage_size_limit\fR configuration parameter. This is a
58 /* permanent error.
59+/*
60+/* smtpd_check_queue() checks the available queue file system
61+/* space. The message is rejected when:
62 /* .IP \(bu
63 /* The available queue file system space is less than the amount
64 /* specified with the \fImin_queue_free\fR configuration parameter.
65@@ -4115,8 +4124,6 @@
66
67 char *smtpd_check_size(SMTPD_STATE *state, off_t size)
68 {
69- char *myname = "smtpd_check_size";
70- struct fsspace fsbuf;
71 int status;
72
73 /*
74@@ -4127,16 +4134,38 @@
75 return (status == SMTPD_CHECK_REJECT ? STR(error_text) : 0);
76
77 /*
78- * Avoid overflow/underflow when comparing message size against available
79- * space.
80+ * Check against file size limit.
81 */
82-#define BLOCKS(x) ((x) / fsbuf.block_size)
83
84 if (var_message_limit > 0 && size > var_message_limit) {
85 (void) smtpd_check_reject(state, MAIL_ERROR_POLICY,
86 "552 Message size exceeds fixed limit");
87 return (STR(error_text));
88 }
89+ return (0);
90+}
91+
92+/* smtpd_check_queue - check queue space */
93+
94+char *smtpd_check_queue(SMTPD_STATE *state)
95+{
96+ char *myname = "smtpd_check_queue";
97+ struct fsspace fsbuf;
98+ int status;
99+
100+ /*
101+ * Return here in case of serious trouble.
102+ */
103+ SMTPD_CHECK_RESET();
104+ if ((status = setjmp(smtpd_check_buf)) != 0)
105+ return (status == SMTPD_CHECK_REJECT ? STR(error_text) : 0);
106+
107+ /*
108+ * Avoid overflow/underflow when comparing message size against available
109+ * space.
110+ */
111+#define BLOCKS(x) ((x) / fsbuf.block_size)
112+
113 fsspace(".", &fsbuf);
114 if (msg_verbose)
115 msg_info("%s: blocks %lu avail %lu min_free %lu msg_size_limit %lu",
116diff -ur postfix-2.2.3/src/smtpd/smtpd_check.h postfix-2.2.3-size/src/smtpd/smtpd_check.h
117--- postfix-2.2.3/src/smtpd/smtpd_check.h 2004-11-19 14:23:23.000000000 +0100
118+++ postfix-2.2.3-size/src/smtpd/smtpd_check.h 2005-09-07 02:02:10.668212792 +0200
119@@ -19,6 +19,7 @@
120 extern char *smtpd_check_helo(SMTPD_STATE *, char *);
121 extern char *smtpd_check_mail(SMTPD_STATE *, char *);
122 extern char *smtpd_check_size(SMTPD_STATE *, off_t);
123+extern char *smtpd_check_queue(SMTPD_STATE *);
124 extern char *smtpd_check_rcpt(SMTPD_STATE *, char *);
125 extern char *smtpd_check_etrn(SMTPD_STATE *, char *);
126 extern char *smtpd_check_data(SMTPD_STATE *);
This page took 0.035153 seconds and 4 git commands to generate.