Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4965:9246d9308caa HEAD
-n and -a parameters shouldn't be deleting auth sockets.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 28 Dec 2006 17:06:31 +0200 |
parents | 3ed0749731d2 |
children | 5df66ce64c0c |
files | src/master/main.c src/master/master-settings.c src/master/master-settings.h |
diffstat | 3 files changed, 75 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/master/main.c Thu Dec 28 16:47:38 2006 +0200 +++ b/src/master/main.c Thu Dec 28 17:06:31 2006 +0200 @@ -139,7 +139,7 @@ auth_processes_destroy_all(); dict_process_kill(); - if (!master_settings_read(configfile, FALSE)) + if (!master_settings_read(configfile, FALSE, FALSE)) i_warning("Invalid configuration, keeping old one"); else { if (!IS_INETD()) { @@ -752,7 +752,7 @@ if (i == argc) i_fatal("Missing config file argument"); configfile = argv[i]; } else if (strcmp(argv[i], "-n") == 0) { - dump_config_nondefaults = TRUE; + dump_config_nondefaults = dump_config = TRUE; } else if (strcmp(argv[i], "-p") == 0) { /* Ask SSL private key password */ ask_key_pass = TRUE; @@ -785,7 +785,7 @@ foreground = TRUE; } - if (dump_config || dump_config_nondefaults) { + if (dump_config) { /* print the config file path before parsing it, so in case of errors it's still shown */ printf("# %s\n", configfile); @@ -794,11 +794,12 @@ /* read and verify settings before forking */ t_push(); master_settings_init(); - if (!master_settings_read(configfile, exec_protocol != NULL)) + if (!master_settings_read(configfile, exec_protocol != NULL, + dump_config)) exit(FATAL_DEFAULT); t_pop(); - if (dump_config || dump_config_nondefaults) { + if (dump_config) { master_settings_dump(settings_root, dump_config_nondefaults); return 0; }
--- a/src/master/master-settings.c Thu Dec 28 16:47:38 2006 +0200 +++ b/src/master/master-settings.c Thu Dec 28 17:06:31 2006 +0200 @@ -592,7 +592,6 @@ static bool settings_verify(struct settings *set) { const char *dir; - struct stat st; int facility; if (!get_login_uid(set)) @@ -654,6 +653,63 @@ } #endif + if (set->max_mail_processes < 1) { + i_error("max_mail_processes must be at least 1"); + return FALSE; + } + + if (set->last_valid_uid != 0 && + set->first_valid_uid > set->last_valid_uid) { + i_error("first_valid_uid can't be larger than last_valid_uid"); + return FALSE; + } + if (set->last_valid_gid != 0 && + set->first_valid_gid > set->last_valid_gid) { + i_error("first_valid_gid can't be larger than last_valid_gid"); + return FALSE; + } + if (set->mail_drop_priv_before_exec && *set->mail_chroot != '\0') { + i_error("mail_drop_priv_before_exec=yes and mail_chroot " + "don't work together"); + return FALSE; + } + + if (access(t_strcut(set->login_executable, ' '), X_OK) < 0) { + i_error("Can't use login executable %s: %m", + t_strcut(set->login_executable, ' ')); + return FALSE; + } + + if (set->login_processes_count < 1) { + i_error("login_processes_count must be at least 1"); + return FALSE; + } + if (set->login_max_connections < 1) { + i_error("login_max_connections must be at least 1"); + return FALSE; + } + +#ifdef HAVE_MODULES + if (*set->mail_plugins != '\0' && + access(set->mail_plugin_dir, R_OK | X_OK) < 0) { + i_error("Can't access mail module directory: %s: %m", + set->mail_plugin_dir); + return FALSE; + } +#else + if (*set->mail_plugins != '\0') { + i_error("Module support wasn't built into Dovecot, " + "can't load modules: %s", set->mail_plugins); + return FALSE; + } +#endif + return TRUE; +} + +static bool settings_do_fixes(struct settings *set) +{ + struct stat st; + /* since base dir is under /var/run by default, it may have been deleted. */ if (mkdir_parents(set->base_dir, 0777) < 0 && errno != EEXIST) { @@ -700,65 +756,17 @@ unlink_auth_sockets(set->login_dir); } - if (set->max_mail_processes < 1) { - i_error("max_mail_processes must be at least 1"); - return FALSE; - } - - if (set->last_valid_uid != 0 && - set->first_valid_uid > set->last_valid_uid) { - i_error("first_valid_uid can't be larger than last_valid_uid"); - return FALSE; - } - if (set->last_valid_gid != 0 && - set->first_valid_gid > set->last_valid_gid) { - i_error("first_valid_gid can't be larger than last_valid_gid"); - return FALSE; - } - if (set->mail_drop_priv_before_exec && *set->mail_chroot != '\0') { - i_error("mail_drop_priv_before_exec=yes and mail_chroot " - "don't work together"); - return FALSE; - } - - if (access(t_strcut(set->login_executable, ' '), X_OK) < 0) { - i_error("Can't use login executable %s: %m", - t_strcut(set->login_executable, ' ')); - return FALSE; - } - - if (set->login_processes_count < 1) { - i_error("login_processes_count must be at least 1"); - return FALSE; - } - if (set->login_max_connections < 1) { - i_error("login_max_connections must be at least 1"); - return FALSE; - } - #ifdef HAVE_MODULES - if (*set->mail_plugins != '\0' && - access(set->mail_plugin_dir, R_OK | X_OK) < 0) { - i_error("Can't access mail module directory: %s: %m", - set->mail_plugin_dir); - return FALSE; - } if (*set->mail_plugins != '\0' && set->protocol == MAIL_PROTOCOL_IMAP && *set->imap_capability == '\0') { if (!get_imap_capability(set)) return FALSE; } -#else - if (*set->mail_plugins != '\0') { - i_error("Module support wasn't built into Dovecot, " - "can't load modules: %s", set->mail_plugins); - return FALSE; - } #endif return TRUE; } -static bool settings_fix(struct settings *set, bool nochecks) +static bool settings_fix(struct settings *set, bool nochecks, bool nofixes) { /* fix relative paths */ fix_base_path(set, &set->login_dir); @@ -771,7 +779,11 @@ "Use only one of them."); return FALSE; } - return nochecks ? TRUE : settings_verify(set); + if (nochecks) + return TRUE; + if (!settings_verify(set)) + return FALSE; + return nofixes ? TRUE : settings_do_fixes(set); } static struct auth_settings * @@ -1214,7 +1226,7 @@ return FALSE; } -bool master_settings_read(const char *path, bool nochecks) +bool master_settings_read(const char *path, bool nochecks, bool nofixes) { struct settings_parse_ctx ctx; struct server_settings *server, *prev; @@ -1254,13 +1266,14 @@ } if (!settings_is_active(server->imap)) { if (strcmp(server->imap->protocols, "none") == 0) { - if (!settings_fix(server->imap, nochecks)) + if (!settings_fix(server->imap, nochecks, + nofixes)) return FALSE; server->defaults = server->imap; } server->imap = NULL; } else { - if (!settings_fix(server->imap, nochecks)) + if (!settings_fix(server->imap, nochecks, nofixes)) return FALSE; server->defaults = server->imap; } @@ -1268,7 +1281,7 @@ if (!settings_is_active(server->pop3)) server->pop3 = NULL; else { - if (!settings_fix(server->pop3, nochecks)) + if (!settings_fix(server->pop3, nochecks, nofixes)) return FALSE; if (server->defaults == NULL) server->defaults = server->pop3;
--- a/src/master/master-settings.h Thu Dec 28 16:47:38 2006 +0200 +++ b/src/master/master-settings.h Thu Dec 28 17:06:31 2006 +0200 @@ -234,7 +234,7 @@ extern struct server_settings *settings_root; -bool master_settings_read(const char *path, bool nochecks); +bool master_settings_read(const char *path, bool nochecks, bool nofixes); void master_settings_dump(struct server_settings *set, bool nondefaults);