Commit afbb33cf afbb33cf9ff750e93a9a4c1f51a3b62d584f056e by Sergey Poznyakoff

Fix a bug in field-map handling.

* libmailutils/cfg/driver.c (parse_mapping): Fix expected value type.
* libmu_auth/sql.c (get_field): Remove left-over mu_assoc_ref call
(see 622bc770).
1 parent afda9ba4
......@@ -72,7 +72,7 @@ is the same as for the global section described above, e.g.:
If the "tls" section is absent, but "tls-mode" is specified and it's
value is anything but "no", the settings from the global "tls" section
will be used. Im this case, it is an error if the global "tls"
will be used. In this case, it is an error if the global "tls"
section is not defined.
......
......@@ -617,10 +617,15 @@ static int
parse_mapping (void *item, void *data)
{
struct mapping_closure *clos = data;
char *str = item;
struct mu_config_value *cval = item;
char const *str;
size_t len;
char *key, *val;
int rc;
if (mu_cfg_assert_value_type (cval, MU_CFG_STRING))
return 1;
str = cval->v.string;
len = strcspn (str, "=");
if (str[len] == 0)
......
......@@ -214,20 +214,23 @@ mu_sql_expand_query (const char *query, const char *ustr)
static int
get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory)
{
const char **name = mu_assoc_ref (mu_sql_module_config.field_map, id);
int rc = mu_sql_get_field (conn, 0, name ? *name : id, ret);
int rc;
const char *name = mu_assoc_get (mu_sql_module_config.field_map, id);
if (!name)
name = id;
rc = mu_sql_get_field (conn, 0, name, ret);
if (rc)
{
if (mandatory || rc != MU_ERR_NOENT)
mu_error (_("cannot get SQL field `%s' (`%s'): %s"),
id, name ? *name : id, mu_strerror (rc));
id, name, mu_strerror (rc));
}
else if (!*ret)
{
if (mandatory)
{
mu_error (_("SQL field `%s' (`%s') has NULL value"),
id, name ? *name : id);
id, name);
rc = MU_ERR_READ;
}
else
......