]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-3.2-20170129
authorWietse Venema <wietse@porcupine.org>
Sun, 29 Jan 2017 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <postfix-users@dukhovni.org>
Wed, 1 Feb 2017 04:17:18 +0000 (23:17 -0500)
postfix/HISTORY
postfix/WISHLIST
postfix/html/postqueue.1.html
postfix/man/man1/postqueue.1
postfix/src/global/mail_version.h
postfix/src/postqueue/postqueue.c
postfix/src/smtp/smtp_map11.c
postfix/src/util/msg_syslog.c
postfix/src/util/unsafe.c

index 888658622c0bee26d659a7b6bcbd9a5f9a925a6c..02a62006247e1682962ae0b41312cbb7ff8de40a 100644 (file)
@@ -22866,9 +22866,9 @@ Apologies for any names omitted.
 
 20170125
 
-       Cleanup: mail_addr_find test scripting. Allow all tests to
-       run in one process, without main.cf dependencies.  Files:
-       global/mail_addr_find.*
+       Cleanup: mail_addr_find test scripting. Eliminate main.cf
+       dependencies, and allow all tests to run in one process.
+       Files: global/mail_addr_find.*
 
 20170127
 
@@ -22880,5 +22880,14 @@ Apologies for any names omitted.
 
        Cleanup: smtp_generic_maps implementation. Reduced the
        number of internal<->external form address conversions,
-       added more rigorous tests, and removed main.cf and
+       added more rigorous tests, and eliminated the main.cf and
        trivial-rewrite dependencies.  Files: smtp_map11.*.
+
+20170129
+
+       Cleanup: environment settings for root and non-root users
+       in set-gid programs. File: postqueue/postqueue.c (enforce
+       import_environment name=value overrides for root users),
+       util/msg_syslog_init.c (don't override non-existent TZ
+       settings), util/unsafe.c (exclude root from privilege
+       escalation concerns).
index f015bdd790a190e5fe7f65a4504bdc05eac1bb57..4d457e647dfaf64dc4314ceb25aaaa0b66e715ce 100644 (file)
@@ -6,8 +6,6 @@ Wish list:
 
        Disable -DSNAPSHOT and -DNONPROD in makedefs.
 
-       Enable external-form lookups for smtpd access maps.
-
        Convert postalias(1) to store external-form keys, and convert
        aliases(5) to perform external-first lookup with fallback to
        internal form, to make it consistent with the rest of Postfix.
@@ -17,9 +15,6 @@ Wish list:
        In the bounce daemon, set util_utf8_enable if returning an
        SMTPUTF8 message.
 
-       Why does postqueue show UTC time, even if TZ is set in
-       the import_environment setting? Because postqueue is set-gid?
-
        Add a header_body_checks extension callback in smtp_proto.c
        that implements the PASS action.
 
index d9d636bc259e9583e9762c143664b7b460861776..258cc8d693dddc9cd2f72bb73f247e6d1e90c602 100644 (file)
@@ -168,11 +168,12 @@ POSTQUEUE(1)                                                      POSTQUEUE(1)
 
        <b><a href="postconf.5.html#alternate_config_directories">alternate_config_directories</a> (empty)</b>
               A list of non-default Postfix configuration directories that may
-              be specified with "-c <a href="postconf.5.html#config_directory">config_directory</a>" on the command line,  or
-              via the MAIL_CONFIG environment parameter.
+              be specified with "-c <a href="postconf.5.html#config_directory">config_directory</a>" on the command line  (in
+              the case of <a href="sendmail.1.html"><b>sendmail</b>(1)</a>, with "-C <a href="postconf.5.html#config_directory">config_directory</a>"), or via the
+              MAIL_CONFIG environment parameter.
 
        <b><a href="postconf.5.html#config_directory">config_directory</a> (see 'postconf -d' output)</b>
-              The  default  location of the Postfix <a href="postconf.5.html">main.cf</a> and <a href="master.5.html">master.cf</a> con-
+              The default location of the Postfix <a href="postconf.5.html">main.cf</a> and  <a href="master.5.html">master.cf</a>  con-
               figuration files.
 
        <b><a href="postconf.5.html#command_directory">command_directory</a> (see 'postconf -d' output)</b>
@@ -183,7 +184,7 @@ POSTQUEUE(1)                                                      POSTQUEUE(1)
               tion logfiles with mail that is queued to those destinations.
 
        <b><a href="postconf.5.html#import_environment">import_environment</a> (see 'postconf -d' output)</b>
-              The  list  of environment parameters that a Postfix process will
+              The list of environment parameters that a Postfix  process  will
               import from a non-Postfix parent process.
 
        <b><a href="postconf.5.html#queue_directory">queue_directory</a> (see 'postconf -d' output)</b>
@@ -193,11 +194,11 @@ POSTQUEUE(1)                                                      POSTQUEUE(1)
               The syslog facility of Postfix logging.
 
        <b><a href="postconf.5.html#syslog_name">syslog_name</a> (see 'postconf -d' output)</b>
-              A prefix that  is  prepended  to  the  process  name  in  syslog
+              A  prefix  that  is  prepended  to  the  process  name in syslog
               records, so that, for example, "smtpd" becomes "prefix/smtpd".
 
        <b><a href="postconf.5.html#trigger_timeout">trigger_timeout</a> (10s)</b>
-              The  time  limit  for sending a trigger to a Postfix daemon (for
+              The time limit for sending a trigger to a  Postfix  daemon  (for
               example, the <a href="pickup.8.html"><b>pickup</b>(8)</a> or <a href="qmgr.8.html"><b>qmgr</b>(8)</a> daemon).
 
        Available in Postfix version 2.2 and later:
index 10c68858135398de699a7214cfad98811aa6a032..9a3da416727df09031c6d6893a5a7d4995446403 100644 (file)
@@ -180,8 +180,9 @@ The text below provides only a parameter summary. See
 \fBpostconf\fR(5) for more details including examples.
 .IP "\fBalternate_config_directories (empty)\fR"
 A list of non\-default Postfix configuration directories that may
-be specified with "\-c config_directory" on the command line, or
-via the MAIL_CONFIG environment parameter.
+be specified with "\-c config_directory" on the command line (in the
+case of \fBsendmail\fR(1), with "\-C config_directory"), or via the MAIL_CONFIG
+environment parameter.
 .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
 The default location of the Postfix main.cf and master.cf
 configuration files.
index 4855227894d49049b0699c5b3a2a74536a208454..9dcf670798ad64aaa195f23fd8c06ea8a51b3f6b 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      "20170128"
+#define MAIL_RELEASE_DATE      "20170129"
 #define MAIL_VERSION_NUMBER    "3.2"
 
 #ifdef SNAPSHOT
index 6da050b4066db0bc6a2650fe59e0c222e5de582f..29f0a9c5ffbdf8bd854407257ab7c3300b1e953a 100644 (file)
 /*     \fBpostconf\fR(5) for more details including examples.
 /* .IP "\fBalternate_config_directories (empty)\fR"
 /*     A list of non-default Postfix configuration directories that may
-/*     be specified with "-c config_directory" on the command line, or
-/*     via the MAIL_CONFIG environment parameter.
+/*     be specified with "-c config_directory" on the command line (in the
+/*     case of \fBsendmail\fR(1), with "-C config_directory"), or via the MAIL_CONFIG
+/*     environment parameter.
 /* .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
 /*     The default location of the Postfix main.cf and master.cf
 /*     configuration files.
@@ -642,16 +643,13 @@ int     main(int argc, char **argv)
 
     /*
      * This program is designed to be set-gid, which makes it a potential
-     * target for attack. If not running as root, strip the environment so we
-     * don't have to trust the C library. If running as root, don't strip the
-     * environment so that showq can receive non-default configuration
-     * directory info when the mail system is down.
+     * target for attack. Strip and optionally override the process
+     * environment so that we don't have to trust the C library.
      */
-    if (geteuid() != 0) {
-       import_env = mail_parm_split(VAR_IMPORT_ENVIRON, var_import_environ);
-       clean_env(import_env->argv);
-       argv_free(import_env);
-    }
+    import_env = mail_parm_split(VAR_IMPORT_ENVIRON, var_import_environ);
+    clean_env(import_env->argv);
+    argv_free(import_env);
+
     if (chdir(var_queue_dir))
        msg_fatal_status(EX_UNAVAILABLE, "chdir %s: %m", var_queue_dir);
 
index 20b74d3c1138d7766de797429c593f782873d1c3..3732a0bf52063e4e5b4256e44c15bf2128410172 100644 (file)
@@ -146,8 +146,11 @@ int     smtp_map11_external(VSTRING *addr, MAPS *maps, int propagate)
 
 VSTRING *canon_addr_external(VSTRING *result, const char *addr)
 {
+    char   *at;
+
     vstring_strcpy(result, addr);
-    if (strchr(addr, '@') == 0)
+    if ((at = strrchr(addr, '@')) == 0
+       || (at + 1)[strcspn(at + 1, "\"\\")] != 0)
        vstring_sprintf_append(result, "@%s", var_myorigin);
     return (result);
 }
@@ -249,6 +252,9 @@ int     main(int argc, char **argv)
            if (mystrtok(&bp, ":") != 0)
                msg_fatal("garbage after result field");
 
+           /*
+            * Perform the mapping.
+            */
            if (strcmp(cmd, "external") == 0) {
                vstring_strcpy(addr_buf, addr_field);
                have_result = smtp_map11_external(addr_buf, maps, 1);
@@ -260,9 +266,6 @@ int     main(int argc, char **argv)
                TOK822 **addr_list;
                TOK822 **tpp;
 
-               /*
-                * Parse the input and expectations.
-                */
                tree = tok822_parse(addr_field);
                addr_list = tok822_grep(tree, TOK822_ADDR);
                for (tpp = addr_list; *tpp; tpp++)
index bbf2e8080b70c8a88407bdd10eafd1fabc5350cf..5476393940f6ace635cef721d7f04ce19b26ae49 100644 (file)
@@ -168,13 +168,18 @@ static void msg_syslog_print(int level, const char *text)
 void    msg_syslog_init(const char *name, int logopt, int facility)
 {
     static int first_call = 1;
+    extern char **environ;
 
     /*
      * XXX If this program is set-gid, then TZ must not be trusted. This
      * scrubbing code is in the wrong place.
      */
     if (unsafe())
-       putenv("TZ=UTC");
+       while (getenv("TZ"))                    /* There may be multiple. */
+           if (unsetenv("TZ") < 0) {           /* Desperate measures. */
+               environ[0] = 0;
+               msg_fatal("unsetenv: %m");
+           }
     tzset();
     openlog(name, LOG_NDELAY | logopt, facility);
     if (first_call) {
index 8d3f34ad02acfc9cf92002ceca773176b41702ff..47d886a4ef15cbef829c2860d48f8d1e38fcf0a0 100644 (file)
 /*     On UNIX systems, the result is true when any of the following
 /*     conditions is true:
 /* .IP \(bu
+/*     The real UID is non-zero.
+/* .IP \(bu
+/*     The effective UID is non-zero.
+/* .PP
+/*     Additionally, any of the following conditions must be true:
+/* .IP \(bu
 /*     The issetuid kernel flag is non-zero (on systems that support
 /*     this concept).
 /* .IP \(bu
 /*     The real and effective user id differ.
 /* .IP \(bu
 /*     The real and effective group id differ.
+/* .PP
+/*     Thus, when a process runs as the super-user, it is excluded
+/*     from privilege-escalation concerns, but only if both real
+/*     UID and effective UID are zero.
 /* LICENSE
 /* .ad
 /* .fi
 
 int     unsafe(void)
 {
-    return (geteuid() != getuid()
+    return ((getuid() || geteuid())
+           && (geteuid() != getuid()
 #ifdef HAS_ISSETUGID
-           || issetugid()
+               || issetugid()
 #endif
-           || getgid() != getegid());
+               || getgid() != getegid()));
 }