settings.c revision 8de7a7c427f5b98e67e65655692328512498a441
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "ibuffer.h"
#include "settings.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <pwd.h>
typedef enum {
} SettingType;
typedef struct {
const char *name;
void *ptr;
} Setting;
{ "ssl_parameters_regenerate",
{ "disable_plaintext_auth",
{ "login_process_per_connection",
{ "login_processes_count",
{ "mail_never_cache_fields",
{ "mailbox_check_interval",
{ "maildir_copy_with_hardlinks",
{ "maildir_check_content_changes",
{ "mbox_dotlock_change_timeout",
{ "overwrite_incompatible_index",
};
/* common */
char *set_log_path = NULL;
/* general */
unsigned int set_imap_port = 143;
unsigned int set_imaps_port = 993;
char *set_imap_listen = NULL;
char *set_imaps_listen = NULL;
char *set_ssl_cert_file = "/etc/ssl/certs/imapd.pem";
char *set_ssl_key_file = "/etc/ssl/private/imapd.pem";
unsigned int set_ssl_parameters_regenerate = 24;
int set_disable_plaintext_auth = FALSE;
/* login */
char *set_login_user = "imapd";
int set_login_chroot = TRUE;
unsigned int set_login_processes_count = 3;
unsigned int set_login_max_processes_count = 128;
unsigned int set_max_logging_users = 256;
/* imap */
char *set_valid_chroot_dirs = NULL;
unsigned int set_max_imap_processes = 1024;
int set_verbose_proctitle = FALSE;
char *set_mail_cache_fields = "MessagePart";
char *set_mail_never_cache_fields = NULL;
unsigned int set_mailbox_check_interval = 30;
int set_mail_save_crlf = FALSE;
char *set_mbox_locks = "dotlock fcntl flock";
int set_mbox_read_dotlock = FALSE;
unsigned int set_mbox_lock_timeout = 300;
unsigned int set_mbox_dotlock_change_timeout = 30;
unsigned int set_umask = 0077;
/* auth */
static void get_login_uid(void)
{
}
static void auth_settings_verify(void)
{
i_fatal("Can't use auth executable %s: %m",
auth->executable);
}
i_fatal("Can't access auth chroot directory %s: %m",
}
}
}
static void settings_verify(void)
{
char *const *str;
i_fatal("Can't use login executable %s: %m",
}
i_fatal("Can't use imap executable %s: %m",
}
deleted */
if (set_max_imap_processes < 1)
i_fatal("max_imap_processes must be at least 1");
if (set_login_processes_count < 1)
i_fatal("login_processes_count must be at least 1");
if (set_max_logging_users < 1)
i_fatal("max_logging_users must be at least 1");
if (set_last_valid_uid != 0 &&
i_fatal("first_valid_uid can't be larger than last_valid_uid");
if (set_last_valid_gid != 0 &&
i_fatal("first_valid_gid can't be larger than last_valid_gid");
dotlock_got = TRUE;
else
}
#ifndef HAVE_FLOCK
i_fatal("mbox_locks: Only flock selected, "
"and flock() isn't supported in this system");
}
#endif
i_fatal("mbox_locks: No mbox locking methods selected");
i_warning("mbox_locks: Only dotlock selected, forcing "
"mbox_read_dotlock = yes to avoid corruption.");
}
}
{
return auth;
}
{
}
static const char *parse_new_auth(const char *name)
{
return "Authentication process name must not contain '/'";
return "Authentication process already exists "
"with the same name";
}
}
(void)auth_config_new(name);
return NULL;
}
{
const char *p;
char **ptr;
return "Authentication process name not defined yet";
/* check the easy string values first */
else
return NULL;
}
/* split it into userinfo + userinfo_args */
p++;
while (*p == ' ') p++;
return NULL;
}
return NULL;
}
}
{
return parse_new_auth(value);
case SET_STR:
break;
case SET_INT:
/* use %i so we can handle eg. 0600
as octal value with umasks */
return t_strconcat("Invalid number: ",
break;
case SET_BOOL:
else
return t_strconcat("Invalid boolean: ",
break;
}
return NULL;
}
}
}
static void settings_free(void)
{
while (auth_processes_config != NULL) {
}
}
void settings_read(const char *path)
{
const char *errormsg;
if (fd < 0)
linenum = 0;
for (;;) {
if (i_buffer_read(inbuf) <= 0)
break;
continue;
}
linenum++;
/* skip whitespace */
line++;
/* ignore comments or empty lines */
continue;
/* all lines must be in format "key = value" */
line++;
*line++ = '\0';
}
if (*line != '=') {
errormsg = "Missing value";
} else {
/* skip whitespace after '=' */
*line++ = '\0';
/* skip trailing whitespace */
p--;
*p = '\0';
}
i_fatal("Error in configuration file %s line %d: %s",
}
};
}
void settings_init(void)
{
/* strdup() all default settings */
}
}
}