コード例 #1
0
ファイル: postconf_master.c プロジェクト: DabeDotCom/postfix
static void pcf_extract_field(ARGV *argv, int field, const char *parens)
{
    char   *arg = argv->argv[field];
    char   *err;

    if ((err = extpar(&arg, parens, EXTPAR_FLAG_STRIP)) != 0) {
	msg_warn("%s: %s", MASTER_CONF_FILE, err);
	myfree(err);
    }
    argv_replace_one(argv, field, arg);
}
コード例 #2
0
ファイル: milter.c プロジェクト: terbolous/postfix
MILTERS *milter_new(const char *names,
		            int conn_timeout,
		            int cmd_timeout,
		            int msg_timeout,
		            const char *protocol,
		            const char *def_action,
		            MILTER_MACROS *macros)
{
    MILTERS *milters;
    MILTER *head = 0;
    MILTER *tail = 0;
    char   *name;
    MILTER *milter;
    const char *sep = ", \t\r\n";
    const char *parens = "{}";
    int     my_conn_timeout;
    int     my_cmd_timeout;
    int     my_msg_timeout;
    const char *my_protocol;
    const char *my_def_action;

    /*
     * Initialize.
     */
    link_override_table_to_variable(time_table, my_conn_timeout);
    link_override_table_to_variable(time_table, my_cmd_timeout);
    link_override_table_to_variable(time_table, my_msg_timeout);
    link_override_table_to_variable(str_table, my_protocol);
    link_override_table_to_variable(str_table, my_def_action);

    /*
     * Parse the milter list.
     */
    milters = (MILTERS *) mymalloc(sizeof(*milters));
    if (names != 0 && *names != 0) {
	char   *saved_names = mystrdup(names);
	char   *cp = saved_names;
	char   *op;
	char   *err;

	/*
	 * Instantiate Milters, allowing for per-Milter overrides.
	 */
	while ((name = mystrtokq(&cp, sep, parens)) != 0) {
	    my_conn_timeout = conn_timeout;
	    my_cmd_timeout = cmd_timeout;
	    my_msg_timeout = msg_timeout;
	    my_protocol = protocol;
	    my_def_action = def_action;
	    if (name[0] == '{') {		/* } */
		op = name;
		if ((err = extpar(&op, parens, EXTPAR_FLAG_NONE)) != 0)
		    msg_fatal("milter service syntax error: %s", err);
		if ((name = mystrtok(&op, sep)) == 0)
		    msg_fatal("empty milter definition: \"%s\"", names);
		attr_override(op, sep, parens,
			      ATTR_OVER_STR_TABLE, str_table,
			      ATTR_OVER_TIME_TABLE, time_table,
			      0);
	    }
	    milter = milter8_create(name, my_conn_timeout, my_cmd_timeout,
				    my_msg_timeout, my_protocol,
				    my_def_action, milters);
	    if (head == 0) {
		head = milter;
	    } else {
		tail->next = milter;
	    }
	    tail = milter;
	}
	myfree(saved_names);
    }
    milters->milter_list = head;
    milters->mac_lookup = 0;
    milters->mac_context = 0;
    milters->macros = macros;
    milters->add_header = 0;
    milters->upd_header = milters->ins_header = 0;
    milters->del_header = 0;
    milters->add_rcpt = milters->del_rcpt = 0;
    milters->repl_body = 0;
    milters->chg_context = 0;
    return (milters);
}
コード例 #3
0
ファイル: postconf_dbms.c プロジェクト: terbolous/postfix
static void pcf_register_dbms_helper(char *str_value,
         const char *(flag_parameter) (const char *, int, PCF_MASTER_ENT *),
				             PCF_MASTER_ENT *local_scope)
{
    const PCF_DBMS_INFO *dp;
    char   *db_type;
    char   *prefix;
    static VSTRING *candidate = 0;
    const char **cpp;
    char   *err;

    /*
     * Naive parsing. We don't really know if this substring specifies a
     * database or some other text.
     */
    while ((db_type = mystrtokq(&str_value, " ,\t\r\n", "{}")) != 0) {

	/*
	 * Skip over "proxy:" maptypes, to emulate the proxymap(8) server's
	 * behavior when opening a local database configuration file.
	 */
	while ((prefix = split_at(db_type, ':')) != 0
	       && strcmp(db_type, DICT_TYPE_PROXY) == 0)
	    db_type = prefix;

	/*
	 * Look for database:prefix where the prefix is not a pathname and
	 * the database is a known type. Synthesize candidate parameter names
	 * from the user-defined prefix and from the database-defined suffix
	 * list, and see if those parameters have a "name=value" entry in the
	 * local or global namespace.
	 */
	if (prefix != 0 && *prefix != '/' && *prefix != '.') {
	    if (*prefix == '{') {		/* } */
		if ((err = extpar(&prefix, "{}", EXTPAR_FLAG_NONE)) != 0) {
		    /* XXX Encapsulate this in pcf_warn() function. */
		    if (local_scope)
			msg_warn("%s:%s: %s",
				 MASTER_CONF_FILE, local_scope->name_space,
				 err);
		    else
			msg_warn("%s: %s", MAIN_CONF_FILE, err);
		    myfree(err);
		}
		pcf_register_dbms_helper(prefix, flag_parameter,
					 local_scope);
	    } else {
		for (dp = pcf_dbms_info; dp->db_type != 0; dp++) {
		    if (strcmp(db_type, dp->db_type) == 0) {
			for (cpp = dp->db_suffixes; *cpp; cpp++) {
			    vstring_sprintf(candidate ? candidate :
					    (candidate = vstring_alloc(30)),
					    "%s_%s", prefix, *cpp);
			    flag_parameter(STR(candidate),
				  PCF_PARAM_FLAG_DBMS | PCF_PARAM_FLAG_USER,
					   local_scope);
			}
			break;
		    }
		}
	    }
	}
    }
}