settings.c revision 868572d42fb8c1e90ea5ab6a5cc5d98f16aec3b6
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "iobuffer.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;
{ "disable_plaintext_auth",
{ "maildir_copy_with_hardlinks",
{ "maildir_check_content_changes",
};
/* common */
char *set_log_path = NULL;
/* login */
char *set_login_user = "imapd";
char *set_login_dir = PKG_RUNDIR;
int set_login_chroot = TRUE;
unsigned int set_login_processes_count = 1;
unsigned int set_max_logging_users = 256;
/* imap */
char *set_valid_chroot_dirs = NULL;
unsigned int set_max_imap_processes = 1024;
char *set_imap_listen = NULL;
char *set_imaps_listen = NULL;
unsigned int set_imap_port = 143;
unsigned int set_imaps_port = 993;
char *set_ssl_cert_file = NULL;
char *set_ssl_key_file = NULL;
int set_disable_plaintext_auth = FALSE;
unsigned int set_umask = 0077;
/* auth */
static void get_login_uid(void)
{
}
static void settings_initialize(void)
{
/* strdup() all default settings */
}
}
}
static void settings_verify(void)
{
i_fatal("Can't use login executable %s: %m",
}
i_fatal("Can't use imap executable %s: %m",
}
if (set_login_processes_count < 1)
i_fatal("login_processes_count must be at least 1");
i_fatal("first_valid_uid can't be larger than last_valid_uid");
i_fatal("first_valid_gid can't be larger than last_valid_gid");
}
{
return auth;
}
static const char *parse_new_auth(const char *name)
{
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;
}
}
}
void settings_read(const char *path)
{
const char *errormsg;
if (fd == -1)
linenum = 0;
for (;;) {
if (io_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",
}
};
}