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.
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. */