mail-process.c revision b75aa058233423af13c2d3a8ddc725884b7ffbc5
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "fd-close-on-exec.h"
#include "env-util.h"
#include "str.h"
#include "network.h"
#include "restrict-access.h"
#include "restrict-process-size.h"
#include "var-expand.h"
#include "mail-process.h"
#include <stdlib.h>
#include <unistd.h>
#include <grp.h>
#include <syslog.h>
static unsigned int mail_process_count = 0;
{
if (uid == 0) {
return FALSE;
}
i_error("Logins with UID %s (user %s) not permitted "
"(modify first_valid_uid in config file)",
return FALSE;
}
i_error("Logins for users with primary group ID %s (user %s) "
"not permitted (see first_valid_gid in config file).",
return FALSE;
}
return TRUE;
}
static int validate_chroot(const char *dir)
{
const char *const *chroot_dirs;
if (*dir == '\0')
return FALSE;
return FALSE;
while (*chroot_dirs != NULL) {
if (**chroot_dirs != '\0' &&
return TRUE;
chroot_dirs++;
}
return FALSE;
}
const char *home)
{
const char *p;
/* it's either type:data or just data */
if (p != NULL) {
while (env != p) {
env++;
}
}
/* expand home */
env++;
}
/* expand %vars */
}
const char *executable, const char *module_dir,
unsigned int process_size, int process_type,
{
char title[1024];
int i, err;
i_error("Maximum number of mail processes exceeded");
return FALSE;
}
return FALSE;
return FALSE;
}
if (pid < 0) {
i_error("fork() failed: %m");
return FALSE;
}
if (pid != 0) {
/* master */
return TRUE;
}
/* move the client socket into stdin and stdout fds */
i_fatal("mail: dup2(stdin) failed: %m");
i_fatal("mail: dup2(stdout) failed: %m");
i_error("mail: close(mail client) failed: %m");
/* setup environment - set the most important environment first
(paranoia about filling up environment without noticing) */
if (*home_dir != '\0') {
if (chdir(full_home_dir) < 0)
}
env_put("LOGGED_IN=1");
if (set->mail_save_crlf)
env_put("MAIL_SAVE_CRLF=1");
if (set->mail_read_mmaped)
env_put("MAIL_READ_MMAPED=1");
env_put("MAILDIR_COPY_WITH_HARDLINKS=1");
env_put("MAILDIR_CHECK_CONTENT_CHANGES=1");
env_put("FULL_FILESYSTEM_ACCESS=1");
set->mbox_lock_timeout));
if (set->mbox_read_dotlock)
env_put("MBOX_READ_DOTLOCK=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. */
home_dir);
}
if (set->verbose_proctitle) {
addr = "??";
}
/* make sure we don't leak syslog fd, but do it last so that
any errors above will be logged */
closelog();
/* hide the path, it's ugly */
for (i = 0; i < 3; i++)
(void)close(i);
/* not reached */
return FALSE;
}
{
}