Exemple #1
0
static const char *pc_mynetworks(void)
{
    static const char *networks;
    INET_PROTO_INFO *proto_info;
    const char *junk;

    /*
     * Use cached result.
     */
    if (networks)
	return (networks);

    if (var_inet_interfaces == 0) {
	if ((cmd_mode & SHOW_DEFS)
	    || (junk = mail_conf_lookup_eval(VAR_INET_INTERFACES)) == 0)
	    junk = DEF_INET_INTERFACES;
	var_inet_interfaces = mystrdup(junk);
    }
    if (var_mynetworks_style == 0) {
	if ((cmd_mode & SHOW_DEFS)
	    || (junk = mail_conf_lookup_eval(VAR_MYNETWORKS_STYLE)) == 0)
	    junk = DEF_MYNETWORKS_STYLE;
	var_mynetworks_style = mystrdup(junk);
    }
    if (var_inet_protocols == 0) {
	if ((cmd_mode & SHOW_DEFS)
	    || (junk = mail_conf_lookup_eval(VAR_INET_PROTOCOLS)) == 0)
	    junk = DEF_INET_PROTOCOLS;
	var_inet_protocols = mystrdup(junk);
	proto_info = inet_proto_init(VAR_INET_PROTOCOLS, var_inet_protocols);
    }
    return (networks = mystrdup(mynetworks()));
}
Exemple #2
0
static const char *check_myhostname(void)
{
    static const char *name;
    const char *dot;
    const char *domain;

    /*
     * Use cached result.
     */
    if (name)
	return (name);

    /*
     * If the local machine name is not in FQDN form, try to append the
     * contents of $mydomain. Use a default domain as a final workaround.
     * 
     * DO NOT CALL GETHOSTBYNAME OR GETNAMEINFO HERE - IT MAKES EVERY POSTFIX
     * PROGRAM HANG WHEN DNS SERVICE IS UNAVAILABLE. IF YOU DON'T LIKE THE
     * DEFAULT, THEN EDIT MAIN.CF.
     */
    name = get_hostname();
    /* DO NOT CALL GETHOSTBYNAME OR GETNAMEINFO HERE - EDIT MAIN.CF */
    if ((dot = strchr(name, '.')) == 0) {
	/* DO NOT CALL GETHOSTBYNAME OR GETNAMEINFO HERE - EDIT MAIN.CF */
	if ((domain = mail_conf_lookup_eval(VAR_MYDOMAIN)) == 0)
	    domain = DEF_MYDOMAIN;
	/* DO NOT CALL GETHOSTBYNAME OR GETNAMEINFO HERE - EDIT MAIN.CF */
	name = concatenate(name, ".", domain, (char *) 0);
    }
    /* DO NOT CALL GETHOSTBYNAME OR GETNAMEINFO HERE - EDIT MAIN.CF */
    return (name);
}
Exemple #3
0
static void pcf_get_myhostname(void)
{
    const char *name;

    if ((name = mail_conf_lookup_eval(VAR_MYHOSTNAME)) == 0)
	name = pcf_check_myhostname();
    var_myhostname = mystrdup(name);
}
static int convert_mail_conf_time(const char *name, int *intval, int def_unit)
{
    const char *strval;

    if ((strval = mail_conf_lookup_eval(name)) == 0)
	return (0);
    if (conv_time(strval, intval, def_unit) == 0)
	msg_fatal("parameter %s: bad time value or unit: %s", name, strval);
    return (1);
}
Exemple #5
0
static int convert_mail_conf_long(const char *name, long *longval)
{
    const char *strval;
    char    junk;

    if ((strval = mail_conf_lookup_eval(name)) != 0) {
	if (sscanf(strval, "%ld%c", longval, &junk) != 1)
	    msg_fatal("bad numerical configuration: %s = %s", name, strval);
	return (1);
    }
    return (0);
}
Exemple #6
0
char   *get_mail_conf_str_fn(const char *name, stupid_indent_str defval,
			             int min, int max)
{
    const char *strval;

    if ((strval = mail_conf_lookup_eval(name)) == 0) {
	strval = mail_conf_eval(defval());
	mail_conf_update(name, strval);
    }
    check_mail_conf_str(name, strval, min, max);
    return (mystrdup(strval));
}
Exemple #7
0
void    debug_process(void)
{
    const char *command;

    /*
     * Expand $debugger_command then run it.
     */
    command = mail_conf_lookup_eval(VAR_DEBUG_COMMAND);
    if (command == 0 || *command == 0)
	msg_fatal("no %s variable set up", VAR_DEBUG_COMMAND);
    msg_info("running: %s", command);
    system(command);
}
Exemple #8
0
static const char *pcf_mynetworks(void)
{
    static const char *networks;
    const char *junk;

    /*
     * Use cached result.
     */
    if (networks)
	return (networks);

    if (var_inet_interfaces == 0) {
	if ((pcf_cmd_mode & PCF_SHOW_DEFS)
	    || (junk = mail_conf_lookup_eval(VAR_INET_INTERFACES)) == 0)
	    junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode,
					      DEF_INET_INTERFACES,
					      (PCF_MASTER_ENT *) 0);
	var_inet_interfaces = mystrdup(junk);
    }
    if (var_mynetworks_style == 0) {
	if ((pcf_cmd_mode & PCF_SHOW_DEFS)
	    || (junk = mail_conf_lookup_eval(VAR_MYNETWORKS_STYLE)) == 0)
	    junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode,
					      DEF_MYNETWORKS_STYLE,
					      (PCF_MASTER_ENT *) 0);
	var_mynetworks_style = mystrdup(junk);
    }
    if (var_inet_protocols == 0) {
	if ((pcf_cmd_mode & PCF_SHOW_DEFS)
	    || (junk = mail_conf_lookup_eval(VAR_INET_PROTOCOLS)) == 0)
	    junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode,
					      DEF_INET_PROTOCOLS,
					      (PCF_MASTER_ENT *) 0);
	var_inet_protocols = mystrdup(junk);
	(void) inet_proto_init(VAR_INET_PROTOCOLS, var_inet_protocols);
    }
    return (networks = mystrdup(mynetworks()));
}
Exemple #9
0
static int convert_mail_conf_nint(const char *name, int *intval)
{
    const char *strval;
    char   *end;
    long    longval;

    if ((strval = mail_conf_lookup_eval(name)) != 0) {
	errno = 0;
	*intval = longval = strtol(strval, &end, 10);
	if (*strval == 0 || *end != 0 || errno == ERANGE || longval != *intval)
	    msg_fatal("bad numerical configuration: %s = %s", name, strval);
	return (1);
    }
    return (0);
}
Exemple #10
0
char   *get_mail_conf_str2(const char *name1, const char *name2,
			           const char *defval,
			           int min, int max)
{
    const char *strval;
    char   *name;

    name = concatenate(name1, name2, (char *) 0);
    if ((strval = mail_conf_lookup_eval(name)) == 0) {
	strval = mail_conf_eval(defval);
	mail_conf_update(name, strval);
    }
    check_mail_conf_str(name, strval, min, max);
    myfree(name);
    return (mystrdup(strval));
}
Exemple #11
0
static const char *pcf_check_myhostname(void)
{
    static const char *name;
    const char *dot;
    const char *domain;

    /*
     * Use cached result.
     */
    if (name)
	return (name);

    /*
     * If the local machine name is not in FQDN form, try to append the
     * contents of $mydomain.
     */
    name = get_hostname();
    if ((dot = strchr(name, '.')) == 0) {
	if ((domain = mail_conf_lookup_eval(VAR_MYDOMAIN)) == 0)
	    domain = DEF_MYDOMAIN;
	name = concatenate(name, ".", domain, (char *) 0);
    }
    return (name);
}