Mercurial > dovecot > core-2.2
changeset 10602:de1bf8a51556 HEAD
lmtp: Switch back to running as root after deliver a mail.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 28 Jan 2010 23:08:32 +0200 |
parents | 1a7c861bca43 |
children | 25c1ed070b3c |
files | src/lmtp/commands.c |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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,10 +436,13 @@ 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 @@ } 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; }