imap-process.c revision 1138ef5e898296a167d1904e825ee654ee421591
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "restrict-access.h"
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <grp.h>
static unsigned int imap_process_count = 0;
{
if (uid == 0) {
i_error("imap process isn't allowed for root");
return FALSE;
}
i_error("imap process isn't allowed to be in group 0");
return FALSE;
}
i_error("imap process isn't allowed to use UID %ld",
(long) uid);
return FALSE;
}
i_error("imap process isn't allowed to use "
return FALSE;
}
return TRUE;
}
static int validate_chroot(const char *dir)
{
char *const *chroot_dirs;
if (*dir == '\0')
return TRUE;
if (set_valid_chroot_dirs == '\0')
return FALSE;
while (*chroot_dirs != NULL) {
return TRUE;
chroot_dirs++;
}
return FALSE;
}
{
int i, j, err;
if (imap_process_count == set_max_imap_processes) {
i_error("Maximum number of imap processes exceeded");
return MASTER_RESULT_INTERNAL_FAILURE;
}
return MASTER_RESULT_FAILURE;
return MASTER_RESULT_FAILURE;
if (pid < 0) {
i_error("fork() failed: %m");
return MASTER_RESULT_INTERNAL_FAILURE;
}
if (pid != 0) {
/* master */
return MASTER_RESULT_SUCCESS;
}
/* move the imap socket into stdin, stdout and stderr fds */
for (i = 0; i < 3; i++) {
for (j = 0; j < i; j++)
(void)close(j);
i_fatal("imap: dup2() failed: %m");
}
}
/* setup environment */
env += 2;
}
if (set_mail_save_crlf)
putenv("MAIL_SAVE_CRLF=1");
putenv("MAILDIR_COPY_WITH_HARDLINKS=1");
putenv("MAILDIR_CHECK_CONTENT_CHANGES=1");
putenv("OVERWRITE_INCOMPATIBLE_INDEX=1");
/* setup access environment - needs to be done after
clean_child_process() since it clears environment */
/* hide the path, it's ugly */
for (i = 0; i < 3; i++)
(void)close(i);
/* not reached */
return 0;
}
{
}