Пример #1
0
char   *get_mail_conf_raw(const char *name, const char *defval,
		               int min, int max)
{
    const char *strval;

    if ((strval = mail_conf_lookup(name)) == 0) {
	strval = defval;
	mail_conf_update(name, strval);
    }
    check_mail_conf_raw(name, strval, min, max);
    return (mystrdup(strval));
}
Пример #2
0
static void check_legacy_defaults(void)
{

    /*
     * Basic idea: when an existing parameter default is changed, or a new
     * parameter is introduced with incompatible default behavior, force
     * Postfix to run with backwards-compatible default settings and log a
     * warning when the backwards-compatible behavior is used.
     * 
     * Based on a review of Postfix logging the system administrator can decide
     * whether or not to make backwards-compatible default settings permanent
     * in main.cf or master.cf.
     * 
     * To turn off further warnings and deploy the new default settings, the
     * system administrator should update the compatibility_level setting as
     * recommended in the RELASE_NOTES file.
     * 
     * Each incompatible change has its own flag variable, instead of bit in a
     * shared variable. We don't want to rip up code when we need more flag
     * bits.
     */

    /*
     * Look for specific parameters whose default changed when the
     * compatibility level changed to 2.
     */
    if (var_compat_level < 2) {
	if (mail_conf_lookup(VAR_RELAY_DOMAINS) == 0) {
	    warn_compat_break_relay_domains = 1;
	    if (mail_conf_lookup(VAR_FFLUSH_DOMAINS) == 0)
		warn_compat_break_flush_domains = 1;
	}
	if (mail_conf_lookup(VAR_MYNETWORKS) == 0
	    && mail_conf_lookup(VAR_MYNETWORKS_STYLE) == 0)
	    warn_compat_break_mynetworks_style = 1;
    }

    /*
     * Look for specific parameters whose default changed when the
     * compatibility level changed from 0 to 1.
     */
    if (var_compat_level < 1) {
	if (mail_conf_lookup(VAR_APP_DOT_MYDOMAIN) == 0)
	    warn_compat_break_app_dot_mydomain = 1;

	/*
	 * Not: #ifndef NO_EAI. They must configure SMTPUTF8_ENABLE=no if a
	 * warning message is logged, so that they don't suddenly start to
	 * lose mail after Postfix is built with EAI support.
	 */
	if (mail_conf_lookup(VAR_SMTPUTF8_ENABLE) == 0)
	    warn_compat_break_smtputf8_enable = 1;
	warn_compat_break_chroot = 1;
    }
}
Пример #3
0
static const char *register_dbms_parameters_cb(const char *mac_name,
					               int unused_mode,
					               char *context)
{
    PC_MASTER_ENT *local_scope = (PC_MASTER_ENT *) context;
    const char *mac_val;

    /*
     * Local namespace "name=value" settings are always explicit. They have
     * precedence over global namespace "name=value" settings which are
     * either explicit or defined by their default value.
     */
    if (local_scope == 0
	|| (mac_val = dict_get(local_scope->all_params, mac_name)) == 0)
	mac_val = mail_conf_lookup(mac_name);
    return (mac_val);
}
Пример #4
0
static void post_jail_init(char *unused_name, char **unused_argv)
{
    const NAME_CODE actions[] = {
	PSC_NAME_ACT_DROP, PSC_ACT_DROP,
	PSC_NAME_ACT_ENFORCE, PSC_ACT_ENFORCE,
	PSC_NAME_ACT_IGNORE, PSC_ACT_IGNORE,
	PSC_NAME_ACT_CONT, PSC_ACT_IGNORE,	/* compatibility */
	0, -1,
    };
    int     cache_flags;
    const char *tmp;

    /*
     * This routine runs after the skeleton code has entered the chroot jail.
     * Prevent automatic process suicide after a limited number of client
     * requests. It is OK to terminate after a limited amount of idle time.
     */
    var_use_limit = 0;

    /*
     * Workaround for parameters whose values may contain "$", and that have
     * a default of "$parametername". Not sure if it would be a good idea to
     * always to this in the mail_conf_raw(3) module.
     */
    if (*var_psc_rej_footer == '$'
	&& mail_conf_lookup(var_psc_rej_footer + 1)) {
	tmp = mail_conf_eval_once(var_psc_rej_footer);
	myfree(var_psc_rej_footer);
	var_psc_rej_footer = mystrdup(tmp);
    }
    if (*var_psc_exp_filter == '$'
	&& mail_conf_lookup(var_psc_exp_filter + 1)) {
	tmp = mail_conf_eval_once(var_psc_exp_filter);
	myfree(var_psc_exp_filter);
	var_psc_exp_filter = mystrdup(tmp);
    }

    /*
     * Other one-time initialization.
     */
    psc_temp = vstring_alloc(10);
    vstring_sprintf(psc_temp, "%s/%s", MAIL_CLASS_PRIVATE, var_smtpd_service);
    psc_smtpd_service_name = mystrdup(STR(psc_temp));
    psc_dnsbl_init();
    psc_early_init();
    psc_smtpd_init();

    if ((psc_blist_action = name_code(actions, NAME_CODE_FLAG_NONE,
				      var_psc_blist_action)) < 0)
	msg_fatal("bad %s value: %s", VAR_PSC_BLIST_ACTION,
		  var_psc_blist_action);
    if ((psc_dnsbl_action = name_code(actions, NAME_CODE_FLAG_NONE,
				      var_psc_dnsbl_action)) < 0)
	msg_fatal("bad %s value: %s", VAR_PSC_DNSBL_ACTION,
		  var_psc_dnsbl_action);
    if ((psc_pregr_action = name_code(actions, NAME_CODE_FLAG_NONE,
				      var_psc_pregr_action)) < 0)
	msg_fatal("bad %s value: %s", VAR_PSC_PREGR_ACTION,
		  var_psc_pregr_action);
    if ((psc_pipel_action = name_code(actions, NAME_CODE_FLAG_NONE,
				      var_psc_pipel_action)) < 0)
	msg_fatal("bad %s value: %s", VAR_PSC_PIPEL_ACTION,
		  var_psc_pipel_action);
    if ((psc_nsmtp_action = name_code(actions, NAME_CODE_FLAG_NONE,
				      var_psc_nsmtp_action)) < 0)
	msg_fatal("bad %s value: %s", VAR_PSC_NSMTP_ACTION,
		  var_psc_nsmtp_action);
    if ((psc_barlf_action = name_code(actions, NAME_CODE_FLAG_NONE,
				      var_psc_barlf_action)) < 0)
	msg_fatal("bad %s value: %s", VAR_PSC_BARLF_ACTION,
		  var_psc_barlf_action);
    /* Fail "closed" on error. */
    psc_wlist_if = addr_match_list_init(MATCH_FLAG_RETURN, var_psc_wlist_if);

    /*
     * Start the cache maintenance pseudo thread last. Early cleanup makes
     * verbose logging more informative (we get positive confirmation that
     * the cleanup thread runs).
     */
    cache_flags = DICT_CACHE_FLAG_STATISTICS;
    if (msg_verbose > 1)
	cache_flags |= DICT_CACHE_FLAG_VERBOSE;
    if (psc_cache_map != 0 && var_psc_cache_scan > 0)
	dict_cache_control(psc_cache_map,
			   DICT_CACHE_CTL_FLAGS, cache_flags,
			   DICT_CACHE_CTL_INTERVAL, var_psc_cache_scan,
			   DICT_CACHE_CTL_VALIDATOR, psc_cache_validator,
			   DICT_CACHE_CTL_CONTEXT, (char *) 0,
			   DICT_CACHE_CTL_END);

    /*
     * Pre-compute the minimal and maximal TTL.
     */
    psc_min_ttl =
	PSC_MIN(PSC_MIN(var_psc_pregr_ttl, var_psc_dnsbl_ttl),
		PSC_MIN(PSC_MIN(var_psc_pipel_ttl, var_psc_nsmtp_ttl),
			var_psc_barlf_ttl));
    psc_max_ttl =
	PSC_MAX(PSC_MAX(var_psc_pregr_ttl, var_psc_dnsbl_ttl),
		PSC_MAX(PSC_MAX(var_psc_pipel_ttl, var_psc_nsmtp_ttl),
			var_psc_barlf_ttl));

    /*
     * Pre-compute the stress and normal command time limits.
     */
    mail_conf_update(VAR_STRESS, "yes");
    psc_stress_cmd_time_limit =
	get_mail_conf_time(VAR_PSC_CMD_TIME, DEF_PSC_CMD_TIME, 1, 0);
    psc_stress_greet_wait =
	get_mail_conf_time(VAR_PSC_GREET_WAIT, DEF_PSC_GREET_WAIT, 1, 0);

    mail_conf_update(VAR_STRESS, "");
    psc_normal_cmd_time_limit =
	get_mail_conf_time(VAR_PSC_CMD_TIME, DEF_PSC_CMD_TIME, 1, 0);
    psc_normal_greet_wait =
	get_mail_conf_time(VAR_PSC_GREET_WAIT, DEF_PSC_GREET_WAIT, 1, 0);

    psc_lowat_check_queue_length = .7 * var_psc_pre_queue_limit;
    psc_hiwat_check_queue_length = .9 * var_psc_pre_queue_limit;
    if (msg_verbose)
	msg_info(VAR_PSC_CMD_TIME ": stress=%d normal=%d lowat=%d hiwat=%d",
		 psc_stress_cmd_time_limit, psc_normal_cmd_time_limit,
		 psc_lowat_check_queue_length, psc_hiwat_check_queue_length);

    if (psc_lowat_check_queue_length == 0)
	msg_panic("compiler error: 0.7 * %d = %d", var_psc_pre_queue_limit,
		  psc_lowat_check_queue_length);
    if (psc_hiwat_check_queue_length == 0)
	msg_panic("compiler error: 0.9 * %d = %d", var_psc_pre_queue_limit,
		  psc_hiwat_check_queue_length);

    /*
     * Per-client concurrency.
     */
    psc_client_concurrency = htable_create(var_psc_pre_queue_limit);
}