dovecot-2.0: lmtp: Switch back to running as root after deliver ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jan 28 23:08:35 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/de1bf8a51556
changeset: 10602:de1bf8a51556
user: Timo Sirainen <tss at iki.fi>
date: Thu Jan 28 23:08:32 2010 +0200
description:
lmtp: Switch back to running as root after deliver a mail.
diffstat:
1 file changed, 10 insertions(+)
src/lmtp/commands.c | 10 ++++++++++
diffs (30 lines):
diff -r 1a7c861bca43 -r de1bf8a51556 src/lmtp/commands.c
--- a/src/lmtp/commands.c Thu Jan 28 22:39:45 2010 +0200
+++ b/src/lmtp/commands.c Thu Jan 28 23:08:32 2010 +0200
@@ -436,9 +436,12 @@ client_deliver(struct client *client, co
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, co
}
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;
}
More information about the dovecot-cvs
mailing list