]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix using NO_RESTRICT_ACCESS flag with TEMP_PRIV_DROP
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 26 Jan 2023 18:28:43 +0000 (20:28 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 27 Jan 2023 11:08:35 +0000 (11:08 +0000)
The following changes will use MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS
with e.g. shared user lookups. The process UID must not be changed in this
case. However, if MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP was set, the
code was still reseting UID to root, which isn't wanted.

src/lib-storage/mail-storage-service.c

index cf4baba95644ba5f6251057be9ad4f9b866c6c42..f1f53587816c2ba5e03e697c123b2ca6c8f808e2 100644 (file)
@@ -1268,7 +1268,8 @@ mail_storage_service_lookup_real(struct mail_storage_service_ctx *ctx,
        flags = mail_storage_service_input_get_flags(ctx, input);
 
        if ((flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0 &&
-           geteuid() != 0) {
+           geteuid() != 0 &&
+           (flags & MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS) == 0) {
                /* we dropped privileges only temporarily. switch back to root
                   before reading settings, so we'll definitely have enough
                   permissions to connect to the config socket. */