On Freitag, 17. Juli 2009, Philipp Marek wrote:
> So I looked into the sources, and came up with the attached (untested, not
> even compiled) patch against 1.2.1.
...
> I've now looked into the sources, and tried to sketch the basic change that
> I imagine; please see the attached patch.

The newer version in this mail actually compiles - I used the wrong structure 
to address the env_name.


Regards,

Phil

diff -ur dovecot-1.2.1.ori/src/lib-dict/dict-sql.c dovecot-1.2.1/src/lib-dict/dict-sql.c
--- dovecot-1.2.1.ori/src/lib-dict/dict-sql.c	2009-06-28 03:57:12.000000000 +0200
+++ dovecot-1.2.1/src/lib-dict/dict-sql.c	2009-07-17 11:08:08.000000000 +0200
@@ -12,6 +12,7 @@
 
 #include <unistd.h>
 #include <fcntl.h>
+#include <stdlib.h>
 
 #define DICT_SQL_MAX_UNUSED_CONNECTIONS 10
 
@@ -250,6 +251,10 @@
 		str_printfa(query, " %s = '%s'", map->username_field,
 			    sql_escape_string(dict->db, dict->username));
 	}
+
+	if (map->env_name)
+		str_printfa(query, " AND %s = '%s'", map->env_name,
+				sql_escape_string(dict->db, getenv(map->env_name)));
 }
 
 static int sql_dict_lookup(struct dict *_dict, pool_t pool,
diff -ur dovecot-1.2.1.ori/src/lib-dict/dict-sql-settings.c dovecot-1.2.1/src/lib-dict/dict-sql-settings.c
--- dovecot-1.2.1.ori/src/lib-dict/dict-sql-settings.c	2009-06-28 04:15:52.000000000 +0200
+++ dovecot-1.2.1/src/lib-dict/dict-sql-settings.c	2009-07-17 10:15:10.000000000 +0200
@@ -34,6 +34,7 @@
 	DEF_STR(table),
 	DEF_STR(username_field),
 	DEF_STR(value_field),
+	DEF_STR(env_name),
 
 	{ 0, NULL, 0 }
 };
diff -ur dovecot-1.2.1.ori/src/lib-dict/dict-sql-settings.h dovecot-1.2.1/src/lib-dict/dict-sql-settings.h
--- dovecot-1.2.1.ori/src/lib-dict/dict-sql-settings.h	2009-01-07 19:33:25.000000000 +0100
+++ dovecot-1.2.1/src/lib-dict/dict-sql-settings.h	2009-07-17 10:29:47.000000000 +0200
@@ -8,6 +8,7 @@
 	const char *table;
 	const char *username_field;
 	const char *value_field;
+	const char *env_name;
 
 	ARRAY_TYPE(const_string) sql_fields;
 };

Reply via email to