From: Timo Sirainen Date: Sun, 28 Jun 2009 02:16:40 +0000 (-0400) Subject: dict sql: If pattern, table or value_field is unset, fail early with an error. X-Git-Tag: 2.0.alpha1~506 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8856a91711f93e099b6d1dfc89af7248017ffe5e;p=thirdparty%2Fdovecot%2Fcore.git dict sql: If pattern, table or value_field is unset, fail early with an error. --HG-- branch : HEAD --- diff --git a/src/lib-dict/dict-sql-settings.c b/src/lib-dict/dict-sql-settings.c index 0afa362189..c9a16e6833 100644 --- a/src/lib-dict/dict-sql-settings.c +++ b/src/lib-dict/dict-sql-settings.c @@ -120,6 +120,18 @@ static const char *dict_sql_fields_map(struct setting_parser_ctx *ctx) static const char *dict_sql_map_finish(struct setting_parser_ctx *ctx) { + if (ctx->cur_map.pattern == NULL) + return "Missing setting: pattern"; + if (ctx->cur_map.table == NULL) + return "Missing setting: table"; + if (ctx->cur_map.value_field == NULL) + return "Missing setting: value_field"; + + if (ctx->cur_map.username_field == NULL) { + /* not all queries require this */ + ctx->cur_map.username_field = "'username_field not set'"; + } + if (!array_is_created(&ctx->cur_map.sql_fields)) { /* no fields besides value. allocate the array anyway. */ p_array_init(&ctx->cur_map.sql_fields, ctx->pool, 1);