summaryrefslogtreecommitdiff
path: root/postfix/postfix-pipe-allow-empty-sender.patch
blob: 85b4ed72669d0e24d91ecb616c6bf454a427e16c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
diff -upr ../postfix-2.1.5.orig/src/pipe/pipe.c ./src/pipe/pipe.c
--- ../postfix-2.1.5.orig/src/pipe/pipe.c	2004-07-24 01:09:21.000000000 +0200
+++ ./src/pipe/pipe.c	2005-05-31 04:30:55.000000000 +0200
@@ -41,7 +41,7 @@
 /* .fi
 /*	The external command attributes are given in the \fBmaster.cf\fR
 /*	file at the end of a service definition.  The syntax is as follows:
-/* .IP "\fBflags=BDFORhqu.>\fR (optional)"
+/* .IP "\fBflags=BDFORhnqu.>\fR (optional)"
 /*	Optional message processing flags. By default, a message is
 /*	copied unchanged.
 /* .RS
@@ -68,6 +68,9 @@
 /*	Fold the command-line \fB$recipient\fR domain name and \fB$nexthop\fR
 /*	host name to lower case.
 /*	This is recommended for delivery via \fBUUCP\fR.
+/* .IP \fBn\fR
+/*      Don't rewrite empty \fB$sender\fR. The default is to rewrite empty 
+/*      \fB$sender\fR to MAILER-DAEMON.
 /* .IP \fBq\fR
 /*	Quote white space and other special characters in the command-line
 /*	\fB$sender\fR and \fB$recipient\fR address localparts (text to the
@@ -349,6 +352,7 @@
 #define PIPE_OPT_FOLD_USER	(1<<16)
 #define PIPE_OPT_FOLD_HOST	(1<<17)
 #define PIPE_OPT_QUOTE_LOCAL	(1<<18)
+#define PIPE_OPT_ALLOW_NO_SENDER (1<<19)
 
 #define PIPE_OPT_FOLD_FLAGS	(PIPE_OPT_FOLD_USER | PIPE_OPT_FOLD_HOST)
 
@@ -660,6 +664,9 @@ static void get_service_attr(PIPE_ATTR *
 		case 'h':
 		    attr->flags |= PIPE_OPT_FOLD_HOST;
 		    break;
+		case 'n':
+		    attr->flags |= PIPE_OPT_ALLOW_NO_SENDER;
+		    break;
 		case 'q':
 		    attr->flags |= PIPE_OPT_QUOTE_LOCAL;
 		    break;
@@ -835,22 +842,6 @@ static int deliver_message(DELIVER_REQUE
 	msg_info("%s: from <%s>", myname, request->sender);
 
     /*
-     * First of all, replace an empty sender address by the mailer daemon
-     * address. The resolver already fixes empty recipient addresses.
-     * 
-     * XXX Should sender and recipient be transformed into external (i.e.
-     * quoted) form? Problem is that the quoting rules are transport
-     * specific. Such information must evidently not be hard coded into
-     * Postfix, but would have to be provided in the form of lookup tables.
-     */
-    if (request->sender[0] == 0) {
-	buf = vstring_alloc(100);
-	canon_addr_internal(buf, MAIL_ADDR_MAIL_DAEMON);
-	myfree(request->sender);
-	request->sender = vstring_export(buf);
-    }
-
-    /*
      * Sanity checks. The get_service_params() and get_service_attr()
      * routines also do some sanity checks. Look up service attributes and
      * config information only once. This is safe since the information comes
@@ -866,6 +857,22 @@ static int deliver_message(DELIVER_REQUE
     }
 
     /*
+     * First of all, replace an empty sender address by the mailer daemon
+     * address. The resolver already fixes empty recipient addresses.
+     * 
+     * XXX Should sender and recipient be transformed into external (i.e.
+     * quoted) form? Problem is that the quoting rules are transport
+     * specific. Such information must evidently not be hard coded into
+     * Postfix, but would have to be provided in the form of lookup tables.
+     */
+    if ((attr.flags & PIPE_OPT_ALLOW_NO_SENDER) == 0 && request->sender[0] == 0) {
+	buf = vstring_alloc(100);
+	canon_addr_internal(buf, MAIL_ADDR_MAIL_DAEMON);
+	myfree(request->sender);
+	request->sender = vstring_export(buf);
+    }
+
+    /*
      * The D flag cannot be specified for multi-recipient deliveries.
      */
     if ((attr.flags & MAIL_COPY_DELIVERED) && (rcpt_list->len > 1)) {
Kun i ./src/pipe: pipe.c~