]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.4-20060825
authorWietse Venema <wietse@porcupine.org>
Fri, 25 Aug 2006 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:32:35 +0000 (06:32 +0000)
postfix/HISTORY
postfix/html/smtp-sink.1.html
postfix/man/man1/smtp-sink.1
postfix/src/cleanup/cleanup_message.c
postfix/src/global/mail_version.h
postfix/src/global/record.c
postfix/src/smtpstone/smtp-sink.c

index 40cc32c2941fdbc94a8345096affa155bab1e688..5f0dc360a816c88d83eb730b7141406d3d0259eb 100644 (file)
@@ -12680,14 +12680,14 @@ Apologies for any names omitted.
 
 20060823
 
-       Bugfix (introduced Postfix 2.2): vstream_fdclose() did not
-       flush unwritten output before disconnecting a stream from
-       its file descriptor.  File: util/vstream.c.
-
        Bugfix (introduced Postfix 2.2): segfault when vstream_fclose()
        attempted to flush unwritten output, after vstream_fdclose()
-       disconnected the stream from its file descriptor.  File:
-       util/vstream.c.
+       had already disconnected the stream from its file descriptor.
+       File: util/vstream.c.
+
+       Bugfix (introduced Postfix 2.2): vstream_fdclose() did not
+       flush unwritten output before disconnecting a stream from
+       its file descriptor(s).  File: util/vstream.c.
 
        Feature: smtp-sink can capture mail to file, either as one
        individual message per file, or as multiple messages per
@@ -12708,6 +12708,17 @@ Apologies for any names omitted.
        Portability: inside functions, GCC 4 refuses forward
        declarations of static functions.  File: smtpstone/smtp-sink.c.
 
+20060825
+
+       Bugfix (introduced Postfix 2.3): with headers-only mail, a
+       Milter "header insert" action corrupted the queue file. The
+       cleanup server executed some end-of-body action before the
+       end-of-header actions. File: cleanup/cleanup_message.c.
+
+       Robustness: mail delivery agents now detect loops in queue
+       files. Files with too many backward jumps are saved to the
+       "corrupt" directory.  File: global/record.c.
+
 Wish list:
 
        Make null local-part handling configurable: either expand
index 04e44eac49d5f994bc17f8d26767ef810db2b438..ec907ebdf66b6fb2af1dd68824b3bc595b6c23ff 100644 (file)
@@ -137,6 +137,11 @@ SMTP-SINK(1)                                                      SMTP-SINK(1)
               and use quotes to  protect  white  space  from  the
               shell. Command names are case-insensitive.
 
+       <b>-R</b> <i>root-directory</i>
+              Change  the process root directory to the specified
+              location.  This option requires  super-user  privi-
+              leges. See also the <b>-u</b> option.
+
        <b>-s</b> <i>command,command,...</i>
               Log the named commands to syslogd.
 
@@ -160,6 +165,13 @@ SMTP-SINK(1)                                                      SMTP-SINK(1)
               Limit the time for receiving a command or sending a
               response.   The time limit is specified in seconds.
 
+       <b>-u</b> <i>username</i>
+              Switch to the specified user privileges after open-
+              ing  the network socket and optionally changing the
+              process root directory.  This  option  is  required
+              when  the  process runs with super-user privileges.
+              See also the <b>-R</b> option.
+
        <b>-v</b>     Show the SMTP conversations.
 
        <b>-w</b> <i>delay</i>
index a1fc05a2d2d69fdd5995905d1d6be554ad3e0dfb..c14515afddf9c9c39c7ec6349535f0dbeed9a3ce 100644 (file)
@@ -119,6 +119,10 @@ Examples of commands are CONNECT, HELO, EHLO, LHLO, MAIL, RCPT, VRFY,
 DATA, ., RSET, NOOP, and QUIT. Separate command names by
 white space or commas, and use quotes to protect white space
 from the shell. Command names are case-insensitive.
+.IP "\fB-R \fIroot-directory\fR"
+Change the process root directory to the specified location.
+This option requires super-user privileges. See also the
+\fB-u\fR option.
 .IP "\fB-s \fIcommand,command,...\fR"
 Log the named commands to syslogd.
 .sp
@@ -137,6 +141,11 @@ character).
 .IP "\fB-t \fItimeout\fR (default: 100)"
 Limit the time for receiving a command or sending a response.
 The time limit is specified in seconds.
+.IP "\fB-u \fIusername\fR"
+Switch to the specified user privileges after opening the
+network socket and optionally changing the process root
+directory. This option is required when the process runs
+with super-user privileges. See also the \fB-R\fR option.
 .IP \fB-v\fR
 Show the SMTP conversations.
 .IP "\fB-w \fIdelay\fR"
index c990cdd7c6e71614324f25484116d6b7b1f93361..5af24c59c636d8cd45032fdea34ba6b8115e8d73 100644 (file)
@@ -797,10 +797,10 @@ static void cleanup_message_headerbody(CLEANUP_STATE *state, int type,
      * current file position so we can compute the message size lateron.
      */
     else if (type == REC_TYPE_XTRA) {
+       state->mime_errs = mime_state_update(state->mime_state, type, buf, len);
        if (state->milters || cleanup_milters)
            /* Make room for body modification. */
            cleanup_out_format(state, REC_TYPE_PTR, REC_TYPE_PTR_FORMAT, 0L);
-       state->mime_errs = mime_state_update(state->mime_state, type, buf, len);
        /* Ignore header truncation after primary message headers. */
        state->mime_errs &= ~MIME_ERR_TRUNC_HEADER;
        if (state->mime_errs && state->reason == 0) {
index 3c334f4f567353855fe60af86a70aa18d58f4fa2..44bb8bfd5bf3dd6f9975c87f18d03ae307247737 100644 (file)
@@ -20,7 +20,7 @@
   * Patches change both the patchlevel and the release date. Snapshots have no
   * patchlevel; they change the release date only.
   */
-#define MAIL_RELEASE_DATE      "20060824"
+#define MAIL_RELEASE_DATE      "20060825"
 #define MAIL_VERSION_NUMBER    "2.4"
 
 #ifdef SNAPSHOT
index 6e4a78dcbdd211e9bddcc6aa6d2645fa3f858e73..a52003e75bc26b58a651b0d54a5846f2668892d2 100644 (file)
@@ -293,18 +293,42 @@ int     rec_get_raw(VSTREAM *stream, VSTRING *buf, ssize_t maxsize, int flags)
 int     rec_goto(VSTREAM *stream, const char *buf)
 {
     off_t   offset;
+    static const char *saved_path;
+    static off_t saved_offset;
+    static int reverse_count;
 
+    /*
+     * Crude workaround for queue file loops. VSTREAMs currently have no
+     * option to attach application-specific data, so we use global state and
+     * simple logic to detect if an application switches streams. We trigger
+     * on reverse jumps only. There's one reverse jump for every inserted
+     * header, but only one reverse jump for all appended recipients. No-one
+     * is likely to insert 10000 message headers, but someone might append
+     * 10000 recipients.
+     */
+#define STREQ(x,y) ((x) == (y) && strcmp((x), (y)) == 0)
+#define REVERSE_JUMP_LIMIT     10000
+
+    if (!STREQ(saved_path, VSTREAM_PATH(stream))) {
+       saved_path = VSTREAM_PATH(stream);
+       reverse_count = 0;
+       saved_offset = 0;
+    }
     while (ISSPACE(*buf))
        buf++;
     if ((offset = off_cvt_string(buf)) < 0) {
        msg_warn("%s: malformed pointer record value: %s",
                 VSTREAM_PATH(stream), buf);
        return (REC_TYPE_ERROR);
+    } else if (offset < saved_offset && ++reverse_count > REVERSE_JUMP_LIMIT) {
+       msg_warn("%s: too many reverse jump records", VSTREAM_PATH(stream));
+       return (REC_TYPE_ERROR);
     } else if (offset > 0 && vstream_fseek(stream, offset, SEEK_SET) < 0) {
        msg_warn("%s: seek error after pointer record: %m",
                 VSTREAM_PATH(stream));
        return (REC_TYPE_ERROR);
     } else {
+       saved_offset = offset;
        return (0);
     }
 }
index faa7861f858e9bb916d1cc5b440278426a035758..f89fae7e74716af8623c6173eeecea16c23f1fb9 100644 (file)
 /*     DATA, ., RSET, NOOP, and QUIT. Separate command names by
 /*     white space or commas, and use quotes to protect white space
 /*     from the shell. Command names are case-insensitive.
+/* .IP "\fB-R \fIroot-directory\fR"
+/*     Change the process root directory to the specified location.
+/*     This option requires super-user privileges. See also the
+/*     \fB-u\fR option.
 /* .IP "\fB-s \fIcommand,command,...\fR"
 /*     Log the named commands to syslogd.
 /* .sp
 /* .IP "\fB-t \fItimeout\fR (default: 100)"
 /*     Limit the time for receiving a command or sending a response.
 /*     The time limit is specified in seconds.
+/* .IP "\fB-u \fIusername\fR"
+/*     Switch to the specified user privileges after opening the
+/*     network socket and optionally changing the process root
+/*     directory. This option is required when the process runs
+/*     with super-user privileges. See also the \fB-R\fR option.
 /* .IP \fB-v\fR
 /*     Show the SMTP conversations.
 /* .IP "\fB-w \fIdelay\fR"
@@ -1193,7 +1202,7 @@ static void connect_event(int unused_event, char *unused_context)
 
 static void usage(char *myname)
 {
-    msg_fatal("usage: %s [-468acCeEFLpPv] [-f commands] [-h hostname] [-m max_concurrency] [-n quit_count] [-q commands] [-r commands] [-s commands] [-w delay] [-d dump-template] [-D dump-template] [-S start-string] [host]:port backlog", myname);
+    msg_fatal("usage: %s [-468acCeEFLpPv] [-f commands] [-h hostname] [-m max_concurrency] [-n quit_count] [-q commands] [-r commands] [-s commands] [-w delay] [-d dump-template] [-D dump-template] [-R root-dir] [-S start-string] [-u user_privs] [host]:port backlog", myname);
 }
 
 int     main(int argc, char **argv)
@@ -1202,6 +1211,8 @@ int     main(int argc, char **argv)
     int     ch;
     const char *protocols = INET_PROTO_NAME_ALL;
     INET_PROTO_INFO *proto_info;
+    const char *root_dir = 0;
+    const char *user_privs = 0;
 
     /*
      * Fix 20051207.
@@ -1216,7 +1227,7 @@ int     main(int argc, char **argv)
     /*
      * Parse JCL.
      */
-    while ((ch = GETOPT(argc, argv, "468acCeEf:Fh:Ln:m:pPq:r:s:S:t:vw:d:D:")) > 0) {
+    while ((ch = GETOPT(argc, argv, "468acCd:D:eEf:Fh:Ln:m:pPq:r:R:s:S:t:u:vw:")) > 0) {
        switch (ch) {
        case '4':
            protocols = INET_PROTO_NAME_IPV4;
@@ -1285,6 +1296,9 @@ int     main(int argc, char **argv)
            set_cmds_flags(optarg, FLAG_SOFT_ERR);
            disable_pipelining = 1;
            break;
+       case 'R':
+           root_dir = optarg;
+           break;
        case 's':
            openlog(basename(argv[0]), LOG_PID, LOG_MAIL);
            set_cmds_flags(optarg, FLAG_SYSLOG);
@@ -1297,6 +1311,9 @@ int     main(int argc, char **argv)
            if ((var_tmout = atoi(optarg)) <= 0)
                msg_fatal("bad timeout: %s", optarg);
            break;
+       case 'u':
+           user_privs = optarg;
+           break;
        case 'v':
            msg_verbose++;
            break;
@@ -1314,6 +1331,8 @@ int     main(int argc, char **argv)
        usage(argv[0]);
     if (single_template && shared_template)
        msg_fatal("use only one of -d or -D, but not both");
+    if (geteuid() == 0 && user_privs == 0)
+       msg_fatal("-u option is required if running as root");
 
     /*
      * Initialize.
@@ -1331,6 +1350,8 @@ int     main(int argc, char **argv)
            argv[optind] += 5;
        sock = inet_listen(argv[optind], backlog, BLOCKING);
     }
+    if (user_privs)
+       chroot_uid(root_dir, user_privs);
 
     if (single_template)
        mysrand((int) time((time_t *) 0));