mail-process.c revision 0c450f355c18905dd18d1559bf815d6b6332cd26
2ronwalf/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */ 2ronwalf/* Timeout chdir() completely after this many seconds */ 2ronwalf/* Give a warning about chdir() taking a while if it took longer than this 2ronwalf /* processes array acts also as refcount */ 2ronwalf/* type+user -> struct mail_process_group */ i_error(
"user %s: Logins with login_user's UID %s " i_error(
"user %s: Logins with UID %s not permitted " "(see first_valid_uid in config file).",
i_error(
"user %s: Logins for users with primary group ID %s " "not permitted (see first_valid_gid in config file).",
"/HOME_DIRECTORY_USED_BUT_NOT_GIVEN_BY_USERDB";
/* it's either type:data or just data */ (
env[
1] ==
'/' ||
env[
1] ==
'\0' ||
env[
1] ==
':')) {
/* expand variables, eg. ~%u/ can be useful */ /* We care about POP3 UIDL format in all process types */ env_put(
"MAILBOX_LIST_INDEX_DISABLE=1");
env_put(
"MAILDIR_COPY_WITH_HARDLINKS=1");
env_put(
"MAILDIR_COPY_PRESERVE_FILENAME=1");
env_put(
"FULL_FILESYSTEM_ACCESS=1");
env_put(
"MBOX_VERY_DIRTY_SYNCS=1");
/* when running dump-capability log still points to stderr, and io_add()ing it might break (epoll_ctl() gives EPERM) */ env_put(
"STDERR_CLOSE_SHUTDOWN=1");
/* user given environment - may be malicious. virtual_user comes from auth process, but don't trust that too much either. Some auth mechanism might allow leaving extra data there. */ for (i = 0; i <
count; i +=
2) {
/* external binary. section contains path for it. */ i_fatal(
"External binary parameter not given");
/* indexes set separately */ /* autodetection for path */ i_fatal(
"Mailbox indexes in %s are in NFS mount. " "You must set mmap_disable=yes to avoid index corruptions. " "If you're sure this check was wrong, set nfs_check=no.",
path);
const char *
user,
const char *
const *
args,
i_error(
"Maximum number of mail processes exceeded");
/* check process limit for this user */ i_error(
"uid specified multiple times for %s",
/* if uid/gid wasn't returned, use the defaults */ i_error(
"User %s is missing UID (set mail_uid)",
user);
i_error(
"User %s is missing GID (set mail_gid)",
user);
/* wu-ftpd like <chroot>/./<home> - check only if there's even a possibility of using them (non-empty valid_chroot_dirs)*/ /* home directories should never be relative, but force this i_error(
"Invalid chroot directory '%s' (user %s) " "(see valid_chroot_dirs in config file)",
/* mail_chroot setting's value doesn't need to be in i_error(
"Can't chroot to directory '%s' (user %s) " "with mail_drop_priv_before_exec=yes",
/* See if we need to do the initial NFS check. We want to do this only once, so the check code needs to be before fork(). */ /* move the client socket into stdin and stdout fds, log to stderr */ i_fatal(
"dup2(stdout) failed: %m");
i_fatal(
"dup2(stderr) failed: %m");
/* setup environment - set the most important environment first (paranoia about filling up environment without noticing) */ /* NOTE: if home directory is NFS-mounted, we might not have access to it as root. Change the effective UID and GID temporarily to make it work. */ /* Change UID back. No need to change GID back, it doesn't /* If user's home directory doesn't exist and we're not trying to chroot anywhere, fallback to /tmp as the mails could be stored elsewhere. The ENOTDIR check is mostly for i_fatal(
"chdir(%s) failed with uid %s: %m",
/* We still have to change to some directory where we have rx-access. /tmp should exist everywhere. */ /* extra args. uppercase key value. */ for (i = 0; i <
count; i++) {
/* Should be caught by dovecot-auth already */ i_fatal(
"Userdb returned data with empty key (%s)",
/* ideally we should check all of the namespaces, but for now don't bother. */ /* make sure we don't leak syslog fd, but do it last so that any errors above will be logged */ /* privileged GID is now only in saved-GID. if we want to preserve it accross exec, it needs to be temporarily /* last process in this group */ for (i = 0; i <
count; i++) {