changeset 4032:7140f09b464f HEAD

Allow checkpassword program to send extra parameters to Dovecot. EXTRA environment contains a list of environment variables that are passed to Dovecot.
author Timo Sirainen <timo.sirainen@movial.fi>
date Mon, 20 Feb 2006 15:39:37 +0200
parents 357175e274b4
children 7dbfff239206
files src/auth/checkpassword-reply.c src/auth/passdb-checkpassword.c
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/checkpassword-reply.c	Mon Feb 20 15:29:31 2006 +0200
+++ b/src/auth/checkpassword-reply.c	Mon Feb 20 15:39:37 2006 +0200
@@ -10,6 +10,7 @@
 int main(void)
 {
 	string_t *str;
+	const char *extra_env, *value, *const *tmp;
 
 	lib_init();
 	str = t_str_new(1024);
@@ -30,6 +31,17 @@
 		    getenv("USER"), getenv("HOME"),
 		    dec2str(getuid()), dec2str(getgid()));
 
+	extra_env = getenv("EXTRA");
+	if (extra_env != NULL) {
+		for (tmp = t_strsplit(extra_env, " "); *tmp != NULL; tmp++) {
+			value = getenv(*tmp);
+			if (value != NULL) {
+				str_printfa(str, "%s=%s\t",
+					    t_str_lcase(*tmp), value);
+			}
+		}
+	}
+
 	if (write_full(4, str_data(str), str_len(str)) < 0) {
 		i_error("write_full() failed: %m");
 		exit(111);
--- a/src/auth/passdb-checkpassword.c	Mon Feb 20 15:29:31 2006 +0200
+++ b/src/auth/passdb-checkpassword.c	Mon Feb 20 15:39:37 2006 +0200
@@ -67,6 +67,12 @@
 
 	hash_remove(module->clients, POINTER_CAST(request->pid));
 
+	if (strchr(str_c(request->input_buf), '\n') != NULL) {
+		auth_request_log_error(request->request, "checkpassword",
+				       "LF characters in checkpassword reply");
+		result = PASSDB_RESULT_INTERNAL_FAILURE;
+	}
+
 	if (result == PASSDB_RESULT_OK) {
 		request->request->extra_fields =
 			auth_stream_reply_init(request->request);