dovecot-2.0: auth: passdb/userdb checkpassword args now supports...

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 30 14:39:35 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/5f3f0d5f9dd8
changeset: 11231:5f3f0d5f9dd8
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 30 14:39:32 2010 +0300
description:
auth: passdb/userdb checkpassword args now supports %variable expansion

diffstat:

 src/auth/db-checkpassword.c     |  13 +++++++++++++
 src/auth/db-checkpassword.h     |   4 ++++
 src/auth/passdb-checkpassword.c |   6 +++---
 src/auth/userdb-checkpassword.c |   6 +++---
 4 files changed, 23 insertions(+), 6 deletions(-)

diffs (82 lines):

diff -r 8a8d954b90ba -r 5f3f0d5f9dd8 src/auth/db-checkpassword.c
--- a/src/auth/db-checkpassword.c	Fri Apr 30 14:38:22 2010 +0300
+++ b/src/auth/db-checkpassword.c	Fri Apr 30 14:39:32 2010 +0300
@@ -4,6 +4,7 @@
 
 #if defined(PASSDB_CHECKPASSWORD) || defined(USERDB_CHECKPASSWORD)
 
+#include "var-expand.h"
 #include "db-checkpassword.h"
 
 static void env_put_extra_fields(const char *extra_fields)
@@ -129,6 +130,18 @@
 	}
 }
 
+const char *
+checkpassword_get_cmd(struct auth_request *request, const char *args,
+		      const char *checkpassword_reply_path)
+{
+	string_t *str;
+
+	str = t_str_new(256);
+	var_expand(str, args,
+		   auth_request_get_var_expand_table(request, NULL));
+	return t_strconcat(str_c(str), " ", checkpassword_reply_path, NULL);
+}
+
 void checkpassword_child_input(struct chkpw_auth_request *request)
 {
 	unsigned char buf[1024];
diff -r 8a8d954b90ba -r 5f3f0d5f9dd8 src/auth/db-checkpassword.h
--- a/src/auth/db-checkpassword.h	Fri Apr 30 14:38:22 2010 +0300
+++ b/src/auth/db-checkpassword.h	Fri Apr 30 14:39:32 2010 +0300
@@ -48,6 +48,10 @@
 checkpassword_sigchld_handler(const struct child_wait_status *child_wait_status,
 			      struct chkpw_auth_request *request);
 void checkpassword_setup_env(struct auth_request *request);
+const char *
+checkpassword_get_cmd(struct auth_request *request, const char *args,
+		      const char *checkpassword_reply_path);
+
 void checkpassword_child_input(struct chkpw_auth_request *request);
 void checkpassword_child_output(struct chkpw_auth_request *request);
 
diff -r 8a8d954b90ba -r 5f3f0d5f9dd8 src/auth/passdb-checkpassword.c
--- a/src/auth/passdb-checkpassword.c	Fri Apr 30 14:38:22 2010 +0300
+++ b/src/auth/passdb-checkpassword.c	Fri Apr 30 14:39:32 2010 +0300
@@ -136,12 +136,12 @@
 				       "dup2() failed: %m");
 	} else {
 		checkpassword_setup_env(request);
-		/* very simple argument splitting. */
-		cmd = t_strconcat(module->checkpassword_path, " ",
-				  module->checkpassword_reply_path, NULL);
+		cmd = checkpassword_get_cmd(request, module->checkpassword_path,
+					    module->checkpassword_reply_path);
 		auth_request_log_debug(request, "checkpassword",
 				       "execute: %s", cmd);
 
+		/* very simple argument splitting. */
 		args = t_strsplit(cmd, " ");
 		execv_const(args[0], args);
 	}
diff -r 8a8d954b90ba -r 5f3f0d5f9dd8 src/auth/userdb-checkpassword.c
--- a/src/auth/userdb-checkpassword.c	Fri Apr 30 14:38:22 2010 +0300
+++ b/src/auth/userdb-checkpassword.c	Fri Apr 30 14:39:32 2010 +0300
@@ -121,12 +121,12 @@
 		   handle this. */
 		env_put("AUTHORIZED=1");
 		checkpassword_setup_env(request);
-		/* very simple argument splitting. */
-		cmd = t_strconcat(module->checkpassword_path, " ",
-				  module->checkpassword_reply_path, NULL);
+		cmd = checkpassword_get_cmd(request, module->checkpassword_path,
+					    module->checkpassword_reply_path);
 		auth_request_log_debug(request, "userdb-checkpassword",
 				       "execute: %s", cmd);
 
+		/* very simple argument splitting. */
 		args = t_strsplit(cmd, " ");
 		execv_const(args[0], args);
 	}


More information about the dovecot-cvs mailing list