master-settings.c revision aef6f8c49e4286e970bf2f37dc502e7239e3766e
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (C) 2002 Timo Sirainen */
ece0a20249ce26208db3415ba2e79423678856f8Timo Sirainen { type, #name, offsetof(struct settings, name) }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen /* general */
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen { type, #name, offsetof(struct login_settings, name) }
6468191d64827a2d1481c091ec499874583c834eTimo Sirainenstatic struct setting_def login_setting_defs[] = {
009217abb57a24a4076092e8e4e165545747839eStephan Bosch { type, #name, offsetof(struct auth_settings, name) }
973c8fc1d7e9f982f7caf6385adb78dfacd9fb80Timo Sirainenstatic struct setting_def auth_setting_defs[] = {
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen MEMBER(log_timestamp) DEFAULT_FAILURE_STAMP_FORMAT,
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen /* general */
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen MEMBER(ssl_cert_file) SSLDIR"/certs/dovecot.pem",
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen MEMBER(ssl_key_file) SSLDIR"/private/dovecot.pem",
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen MEMBER(ssl_parameters_file) "ssl-parameters.dat",
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen MEMBER(imap_executable) PKG_LIBEXECDIR"/imap",
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen MEMBER(pop3_executable) PKG_LIBEXECDIR"/pop3",
6468191d64827a2d1481c091ec499874583c834eTimo Sirainenstruct login_settings default_login_settings = {
6468191d64827a2d1481c091ec499874583c834eTimo Sirainenstatic void fix_base_path(struct settings *set, const char **str)
6468191d64827a2d1481c091ec499874583c834eTimo Sirainen if (*str != NULL && **str != '\0' && **str != '/') {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic void get_login_uid(struct settings *set,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen i_fatal("Login user doesn't exist: %s", login_set->user);
2efe19d9045768d985a3bd549cff12f65ba40cc8Timo Sirainen i_fatal("All login process users must belong to same group "
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic void auth_settings_verify(struct auth_settings *auth)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen i_fatal("Can't use auth executable %s: %m", auth->executable);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if (auth->chroot != NULL && access(auth->chroot, X_OK) < 0) {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen i_fatal("Can't access auth chroot directory %s: %m",
009217abb57a24a4076092e8e4e165545747839eStephan Boschstatic void login_settings_verify(struct login_settings *login)
958e5ae51a755558b6d022a39b194614726b4225Timo Sirainen if (strstr(set->protocols, login->name) != NULL) {
ece0a20249ce26208db3415ba2e79423678856f8Timo Sirainen i_fatal("login_processes_count must be at least 1");
ece0a20249ce26208db3415ba2e79423678856f8Timo Sirainen i_fatal("max_logging_users must be at least 1");
c1d01419ffbeb0e00f86a653db70bfd47110e7fcTimo Sirainenstatic const char *get_directory(const char *path)
edd318d5866ac3fbc6e8df28fb24a4dfef93c884Timo Sirainenstatic void settings_verify(struct settings *set)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen const char *const *str;
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen const char *dir;
ece0a20249ce26208db3415ba2e79423678856f8Timo Sirainen for (login = set->logins; login != NULL; login = login->next) {
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen i_fatal("Can't access log directory %s: %m", dir);
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen i_fatal("Can't access info log directory %s: %m", dir);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen /* fix relative paths */
7ee226c2a66aa4dce7f13e8b17687db285c981bdTimo Sirainen fix_base_path(set, &set->ssl_parameters_file);
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen /* since they're under /var/run by default, they may have been
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen if (safe_mkdir(set->base_dir, 0700, geteuid(), getegid()) == 0) {
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen i_warning("Corrected permissions for base directory %s",
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen /* wipe out contents of login directory, if it exists */
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen if (unlink_directory(set->login_dir, FALSE) < 0)
d6b3cfd855c0eebed68be50d3111de1b5a6afeb0Timo Sirainen i_fatal("unlink_directory() failed for %s: %m", set->login_dir);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if (safe_mkdir(set->login_dir, 0750, geteuid(), set->login_gid) == 0) {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen i_warning("Corrected permissions for login directory %s",
#ifndef HAVE_FLOCK
return NULL;
return NULL;
void *context)
const char *error;
return NULL;
return error;
void master_settings_init(void)
void master_settings_deinit(void)