]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Switch back to running as root after deliver a mail.
authorTimo Sirainen <tss@iki.fi>
Thu, 28 Jan 2010 21:08:32 +0000 (23:08 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 28 Jan 2010 21:08:32 +0000 (23:08 +0200)
--HG--
branch : HEAD

src/lmtp/commands.c

index 979316e4dc196d52dbecd4f4fc1a6f64223cc910..b12e064bc6754310f5631364751c4fd221fee78b 100644 (file)
@@ -436,10 +436,13 @@ client_deliver(struct client *client, const struct mail_recipient *rcpt,
        struct mail_storage *storage;
        const struct mail_storage_service_input *input;
        void **sets;
+       uid_t old_uid;
        const char *error, *username;
        enum mail_error mail_error;
        int ret;
 
+       old_uid = geteuid();
+
        input = mail_storage_service_user_get_input(rcpt->service_user);
        username = t_strdup(input->username);
 
@@ -494,6 +497,13 @@ client_deliver(struct client *client, const struct mail_recipient *rcpt,
                }
                ret = -1;
        }
+       if (old_uid == 0) {
+               /* switch back to running as root, since that's what we're
+                  practically doing anyway. it's also important in case we
+                  lose e.g. config connection and need to reconnect to it. */
+               if (seteuid(0) < 0)
+                       i_fatal("seteuid(0) failed: %m");
+       }
        pool_unref(&dctx.pool);
        return ret;
 }