[dovecot-cvs] dovecot/src/auth auth-request.c, 1.70, 1.71 auth-request.h, 1.28, 1.29 auth-worker-client.c, 1.26, 1.27 auth.c, 1.31, 1.32 db-sql.c, 1.8, 1.9 db-sql.h, 1.3, 1.4 mech-anonymous.c, 1.16, 1.17 mech-apop.c, 1.22, 1.23 mech-cram-md5.c, 1.24, 1.25 mech-digest-md5.c, 1.42, 1.43 mech-gssapi.c, 1.8, 1.9 mech-login.c, 1.18, 1.19 mech-ntlm.c, 1.26, 1.27 mech-plain.c, 1.36, 1.37 mech-rpa.c, 1.26, 1.27 mech.h, 1.38, 1.39 passdb-blocking.c, 1.12, 1.13 passdb-blocking.h, 1.1, 1.2 passdb-bsdauth.c, 1.15, 1.16 passdb-checkpassword.c, 1.26, 1.27 passdb-ldap.c, 1.52, 1.53 passdb-pam.c, 1.42, 1.43 passdb-passwd-file.c, 1.30, 1.31 passdb-passwd.c, 1.17, 1.18 passdb-shadow.c, 1.18, 1.19 passdb-sia.c, 1.2, 1.3 passdb-sql.c, 1.29, 1.30 passdb-vpopmail.c, 1.25, 1.26 passdb.h, 1.34, 1.35
tss at dovecot.org
tss at dovecot.org
Wed Nov 8 20:22:12 UTC 2006
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv6904
Modified Files:
auth-request.c auth-request.h auth-worker-client.c auth.c
db-sql.c db-sql.h mech-anonymous.c mech-apop.c mech-cram-md5.c
mech-digest-md5.c mech-gssapi.c mech-login.c mech-ntlm.c
mech-plain.c mech-rpa.c mech.h passdb-blocking.c
passdb-blocking.h passdb-bsdauth.c passdb-checkpassword.c
passdb-ldap.c passdb-pam.c passdb-passwd-file.c
passdb-passwd.c passdb-shadow.c passdb-sia.c passdb-sql.c
passdb-vpopmail.c passdb.h
Log Message:
Added auth_request_set_credentials() to modify credentials in passdb and
implemented it for SQL passdb. Added passdb_need_set_credentials boolean to
mechanisms to indicate that it's required (OTP will need it). Patch by
Andrey Panin.
Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- auth-request.c 5 Nov 2006 15:51:41 -0000 1.70
+++ auth-request.c 8 Nov 2006 20:22:08 -0000 1.71
@@ -536,6 +536,34 @@
}
}
+void auth_request_set_credentials(struct auth_request *request,
+ enum passdb_credentials credentials,
+ const char *data,
+ set_credentials_callback_t *callback)
+{
+ struct passdb_module *passdb = request->passdb->passdb;
+ const char *cache_key, *new_credentials;
+
+ cache_key = passdb_cache == NULL ? NULL : passdb->cache_key;
+ if (cache_key != NULL)
+ auth_cache_remove(passdb_cache, request, cache_key);
+
+ request->private_callback.set_credentials = callback;
+
+ new_credentials = t_strconcat("{",
+ passdb_credentials_to_str(credentials), "}", data, NULL);
+
+ if (passdb->blocking)
+ passdb_blocking_set_credentials(request, new_credentials);
+ else if (passdb->iface.set_credentials != NULL) {
+ passdb->iface.set_credentials(request, new_credentials,
+ callback);
+ } else {
+ /* this passdb doesn't support credentials update */
+ callback(PASSDB_RESULT_INTERNAL_FAILURE, request);
+ }
+}
+
void auth_request_userdb_callback(struct auth_stream_reply *reply,
struct auth_request *request)
{
Index: auth-request.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- auth-request.h 31 May 2006 11:03:53 -0000 1.28
+++ auth-request.h 8 Nov 2006 20:22:08 -0000 1.29
@@ -59,6 +59,7 @@
union {
verify_plain_callback_t *verify_plain;
lookup_credentials_callback_t *lookup_credentials;
+ set_credentials_callback_t *set_credentials;
userdb_callback_t *userdb;
} private_callback;
enum passdb_credentials credentials;
@@ -149,6 +150,10 @@
void auth_request_lookup_credentials_callback(enum passdb_result result,
const char *credentials,
struct auth_request *request);
+void auth_request_set_credentials(struct auth_request *request,
+ enum passdb_credentials credentials,
+ const char *data,
+ set_credentials_callback_t *callback);
void auth_request_userdb_callback(struct auth_stream_reply *reply,
struct auth_request *request);
Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- auth-worker-client.c 17 Oct 2006 11:26:43 -0000 1.26
+++ auth-worker-client.c 8 Nov 2006 20:22:08 -0000 1.27
@@ -234,6 +234,70 @@
}
static void
+set_credentials_callback(enum passdb_result result,
+ struct auth_request *request)
+{
+ struct auth_worker_client *client = request->context;
+
+ string_t *str;
+
+ str = t_str_new(64);
+ str_printfa(str, "%u\t", request->id);
+
+ if (result != PASSDB_RESULT_OK)
+ str_printfa(str, "FAIL\t%d\t", result);
+ else
+ str_printfa(str, "OK\t%s\t", request->user);
+ str_append_c(str, '\n');
+ o_stream_send(client->output, str_data(str), str_len(str));
+
+ auth_request_unref(&request);
+ auth_worker_client_check_throttle(client);
+ auth_worker_client_unref(&client);
+}
+
+static void
+auth_worker_handle_setcred(struct auth_worker_client *client,
+ unsigned int id, const char *args)
+{
+ struct auth_request *auth_request;
+ unsigned int passdb_id;
+ const char *data;
+
+ passdb_id = atoi(t_strcut(args, '\t'));
+ args = strchr(args, '\t');
+ if (args == NULL) {
+ i_error("BUG: Auth worker server sent us invalid SETCRED");
+ return;
+ }
+ args++;
+
+ data = t_strcut(args, '\t');
+ args = strchr(args, '\t');
+ if (args != NULL) args++;
+
+ auth_request = worker_auth_request_new(client, id, args);
+
+ if (auth_request->user == NULL || auth_request->service == NULL) {
+ i_error("BUG: SETCRED had missing parameters");
+ auth_request_unref(&auth_request);
+ return;
+ }
+
+ while (auth_request->passdb->id != passdb_id) {
+ auth_request->passdb = auth_request->passdb->next;
+ if (auth_request->passdb == NULL) {
+ i_error("BUG: SETCRED had invalid passdb ID");
+ auth_request_unref(&auth_request);
+ return;
+ }
+ }
+
+ auth_request->passdb->passdb->iface.
+ set_credentials(auth_request, data, set_credentials_callback);
+}
+
+static void
lookup_user_callback(struct auth_stream_reply *reply,
struct auth_request *auth_request)
{
@@ -303,6 +367,8 @@
auth_worker_handle_passv(client, id, line + 6);
else if (strncmp(line, "PASSL\t", 6) == 0)
auth_worker_handle_passl(client, id, line + 6);
+ else if (strncmp(line, "SETCRED\t", 8) == 0)
+ auth_worker_handle_setcred(client, id, line + 8);
else if (strncmp(line, "USER\t", 5) == 0)
auth_worker_handle_user(client, id, line + 5);
Index: auth.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- auth.c 12 Apr 2006 14:36:58 -0000 1.31
+++ auth.c 8 Nov 2006 20:22:08 -0000 1.32
@@ -143,6 +143,17 @@
return FALSE;
}
+static int auth_passdb_list_have_set_credentials(struct auth *auth)
+{
+ struct auth_passdb *passdb;
+
+ for (passdb = auth->passdbs; passdb != NULL; passdb = passdb->next) {
+ if (passdb->passdb->iface.set_credentials != NULL)
+ return TRUE;
+ }
+ return FALSE;
+}
+
static void auth_mech_list_verify_passdb(struct auth *auth)
{
struct mech_module_list *list;
@@ -154,6 +165,9 @@
if (list->module.passdb_need_credentials &&
!auth_passdb_list_have_credentials(auth))
break;
+ if (list->module.passdb_need_set_credentials &&
+ !auth_passdb_list_have_set_credentials(auth))
+ break;
}
if (list != NULL) {
Index: db-sql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-sql.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- db-sql.c 16 Jun 2006 09:33:10 -0000 1.8
+++ db-sql.c 8 Nov 2006 20:22:08 -0000 1.9
@@ -18,6 +18,7 @@
DEF(SET_STR, connect),
DEF(SET_STR, password_query),
DEF(SET_STR, user_query),
+ DEF(SET_STR, update_query),
DEF(SET_STR, default_pass_scheme),
{ 0, NULL, 0 }
@@ -28,6 +29,7 @@
MEMBER(connect) NULL,
MEMBER(password_query) "SELECT password FROM users WHERE userid = '%u'",
MEMBER(user_query) "SELECT home, uid, gid FROM users WHERE userid = '%u'",
+ MEMBER(update_query) "UPDATE users SET password = '%w' WHERE userid = '%u'",
MEMBER(default_pass_scheme) "PLAIN-MD5"
};
Index: db-sql.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-sql.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- db-sql.h 14 Jan 2006 18:47:20 -0000 1.3
+++ db-sql.h 8 Nov 2006 20:22:08 -0000 1.4
@@ -8,6 +8,7 @@
const char *connect;
const char *password_query;
const char *user_query;
+ const char *update_query;
const char *default_pass_scheme;
};
Index: mech-anonymous.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-anonymous.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mech-anonymous.c 17 Jun 2006 19:15:20 -0000 1.16
+++ mech-anonymous.c 8 Nov 2006 20:22:08 -0000 1.17
@@ -41,6 +41,7 @@
MEMBER(passdb_need_plain) FALSE,
MEMBER(passdb_need_credentials) FALSE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_anonymous_auth_new,
mech_generic_auth_initial,
Index: mech-apop.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-apop.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- mech-apop.c 17 Jun 2006 19:15:20 -0000 1.22
+++ mech-apop.c 8 Nov 2006 20:22:08 -0000 1.23
@@ -156,6 +156,7 @@
MEMBER(passdb_need_plain) FALSE,
MEMBER(passdb_need_credentials) TRUE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_apop_auth_new,
mech_apop_auth_initial,
Index: mech-cram-md5.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-cram-md5.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- mech-cram-md5.c 17 Jun 2006 19:15:20 -0000 1.24
+++ mech-cram-md5.c 8 Nov 2006 20:22:08 -0000 1.25
@@ -188,6 +188,7 @@
MEMBER(passdb_need_plain) FALSE,
MEMBER(passdb_need_credentials) TRUE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_cram_md5_auth_new,
mech_cram_md5_auth_initial,
Index: mech-digest-md5.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-digest-md5.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- mech-digest-md5.c 15 Oct 2006 13:05:27 -0000 1.42
+++ mech-digest-md5.c 8 Nov 2006 20:22:08 -0000 1.43
@@ -619,6 +619,7 @@
MEMBER(passdb_need_plain) FALSE,
MEMBER(passdb_need_credentials) TRUE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_digest_md5_auth_new,
mech_digest_md5_auth_initial,
Index: mech-gssapi.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-gssapi.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mech-gssapi.c 22 Sep 2006 14:55:53 -0000 1.8
+++ mech-gssapi.c 8 Nov 2006 20:22:08 -0000 1.9
@@ -402,6 +402,7 @@
MEMBER(passdb_need_plain) FALSE,
MEMBER(passdb_need_credentials) FALSE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_gssapi_auth_new,
mech_gssapi_auth_initial,
Index: mech-login.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-login.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mech-login.c 17 Jun 2006 19:15:20 -0000 1.18
+++ mech-login.c 8 Nov 2006 20:22:08 -0000 1.19
@@ -84,6 +84,7 @@
MEMBER(passdb_need_plain) TRUE,
MEMBER(passdb_need_credentials) FALSE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_login_auth_new,
mech_login_auth_initial,
Index: mech-ntlm.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-ntlm.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mech-ntlm.c 17 Jun 2006 19:15:20 -0000 1.26
+++ mech-ntlm.c 8 Nov 2006 20:22:08 -0000 1.27
@@ -262,6 +262,7 @@
MEMBER(passdb_need_plain) FALSE,
MEMBER(passdb_need_credentials) TRUE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_ntlm_auth_new,
mech_generic_auth_initial,
Index: mech-plain.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-plain.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- mech-plain.c 17 Jun 2006 19:15:20 -0000 1.36
+++ mech-plain.c 8 Nov 2006 20:22:08 -0000 1.37
@@ -91,6 +91,7 @@
MEMBER(passdb_need_plain) TRUE,
MEMBER(passdb_need_credentials) FALSE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_plain_auth_new,
mech_generic_auth_initial,
Index: mech-rpa.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-rpa.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mech-rpa.c 17 Jun 2006 19:15:20 -0000 1.26
+++ mech-rpa.c 8 Nov 2006 20:22:08 -0000 1.27
@@ -601,6 +601,7 @@
MEMBER(passdb_need_plain) FALSE,
MEMBER(passdb_need_credentials) TRUE,
+ MEMBER(passdb_need_set_credentials) FALSE,
mech_rpa_auth_new,
mech_generic_auth_initial,
Index: mech.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- mech.h 17 Jun 2006 19:15:20 -0000 1.38
+++ mech.h 8 Nov 2006 20:22:08 -0000 1.39
@@ -26,6 +26,7 @@
enum mech_security_flags flags;
unsigned int passdb_need_plain:1;
unsigned int passdb_need_credentials:1;
+ unsigned int passdb_need_set_credentials:1;
struct auth_request *(*auth_new)(void);
void (*auth_initial)(struct auth_request *request,
Index: passdb-blocking.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-blocking.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- passdb-blocking.c 17 Oct 2006 11:26:43 -0000 1.12
+++ passdb-blocking.c 8 Nov 2006 20:22:08 -0000 1.13
@@ -163,3 +163,24 @@
auth_worker_call(request, str_c(str), lookup_credentials_callback);
}
+
+static void
+set_credentials_callback(struct auth_request *request, const char *reply)
+{
+ enum passdb_result result = check_failure(request, &reply);
+
+ request->private_callback.set_credentials(result, request);
+}
+
+void passdb_blocking_set_credentials(struct auth_request *request,
+ const char *new_credentials)
+{
+ string_t *str;
+
+ str = t_str_new(64);
+ str_printfa(str, "SETCRED\t%u\t%s\t",
+ request->passdb->id, new_credentials);
+ auth_request_export(request, str);
+
+ auth_worker_call(request, str_c(str), set_credentials_callback);
+}
Index: passdb-blocking.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-blocking.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- passdb-blocking.h 2 Mar 2005 20:46:25 -0000 1.1
+++ passdb-blocking.h 8 Nov 2006 20:22:08 -0000 1.2
@@ -3,5 +3,7 @@
void passdb_blocking_verify_plain(struct auth_request *request);
void passdb_blocking_lookup_credentials(struct auth_request *request);
+void passdb_blocking_set_credentials(struct auth_request *request,
+ const char *new_credentials);
#endif
Index: passdb-bsdauth.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-bsdauth.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- passdb-bsdauth.c 15 Oct 2006 21:31:20 -0000 1.15
+++ passdb-bsdauth.c 8 Nov 2006 20:22:08 -0000 1.16
@@ -72,6 +72,7 @@
bsdauth_deinit,
bsdauth_verify_plain,
+ NULL,
NULL
};
Index: passdb-checkpassword.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-checkpassword.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- passdb-checkpassword.c 2 Nov 2006 21:34:49 -0000 1.26
+++ passdb-checkpassword.c 8 Nov 2006 20:22:08 -0000 1.27
@@ -458,6 +458,7 @@
checkpassword_deinit,
checkpassword_verify_plain,
+ NULL,
NULL
};
Index: passdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-ldap.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- passdb-ldap.c 7 Nov 2006 16:16:11 -0000 1.52
+++ passdb-ldap.c 8 Nov 2006 20:22:08 -0000 1.53
@@ -532,7 +532,8 @@
passdb_ldap_deinit,
ldap_verify_plain,
- ldap_lookup_credentials
+ ldap_lookup_credentials,
+ NULL
};
#endif
Index: passdb-pam.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-pam.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- passdb-pam.c 11 Aug 2006 15:09:38 -0000 1.42
+++ passdb-pam.c 8 Nov 2006 20:22:08 -0000 1.43
@@ -490,6 +490,7 @@
pam_deinit,
pam_verify_plain,
+ NULL,
NULL
};
Index: passdb-passwd-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-passwd-file.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- passdb-passwd-file.c 15 Oct 2006 20:06:53 -0000 1.30
+++ passdb-passwd-file.c 8 Nov 2006 20:22:08 -0000 1.31
@@ -162,7 +162,8 @@
passwd_file_deinit,
passwd_file_verify_plain,
- passwd_file_lookup_credentials
+ passwd_file_lookup_credentials,
+ NULL
};
#endif
Index: passdb-passwd.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-passwd.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- passdb-passwd.c 13 Jan 2006 20:25:57 -0000 1.17
+++ passdb-passwd.c 8 Nov 2006 20:22:08 -0000 1.18
@@ -76,6 +76,7 @@
passwd_deinit,
passwd_verify_plain,
+ NULL,
NULL
};
Index: passdb-shadow.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-shadow.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- passdb-shadow.c 13 Jan 2006 20:25:57 -0000 1.18
+++ passdb-shadow.c 8 Nov 2006 20:22:08 -0000 1.19
@@ -76,6 +76,7 @@
shadow_deinit,
shadow_verify_plain,
+ NULL,
NULL
};
Index: passdb-sia.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-sia.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- passdb-sia.c 8 Oct 2006 21:25:17 -0000 1.2
+++ passdb-sia.c 8 Nov 2006 20:22:08 -0000 1.3
@@ -54,7 +54,8 @@
NULL,
local_sia_verify_plain,
- NULL
+ NULL,
+ NULL
};
#endif
Index: passdb-sql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-sql.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- passdb-sql.c 2 Nov 2006 21:19:45 -0000 1.29
+++ passdb-sql.c 8 Nov 2006 20:22:08 -0000 1.30
@@ -7,6 +7,7 @@
#include "str.h"
#include "strescape.h"
#include "var-expand.h"
+#include "safe-memset.h"
#include "password-scheme.h"
#include "auth-cache.h"
#include "db-sql.h"
@@ -26,6 +27,7 @@
union {
verify_plain_callback_t *verify_plain;
lookup_credentials_callback_t *lookup_credentials;
+ set_credentials_callback_t *set_credentials;
} callback;
};
@@ -177,6 +179,56 @@
sql_lookup_pass(sql_request);
}
+static void sql_set_credentials_callback(const char *error, void *context)
+{
+ struct passdb_sql_request *sql_request = context;
+ enum passdb_result result;
+
+ if (error == NULL)
+ result = PASSDB_RESULT_OK;
+ else {
+ result = PASSDB_RESULT_INTERNAL_FAILURE;
+ auth_request_log_error(sql_request->auth_request, "sql",
+ "Set credentials query failed: %s",
+ error);
+ }
+ sql_request->callback.set_credentials(result,
+ sql_request->auth_request);
+ i_free(sql_request);
+}
+
+static int sql_set_credentials(struct auth_request *request,
+ const char *new_credentials,
+ set_credentials_callback_t *callback)
+{
+ struct sql_passdb_module *module =
+ (struct sql_passdb_module *) request->passdb->passdb;
+ struct sql_transaction_context *transaction;
+ struct passdb_sql_request *sql_request;
+ string_t *query;
+
+ t_push();
+
+ request->mech_password = p_strdup(request->pool, new_credentials);
+
+ query = t_str_new(512);
+ var_expand(query, module->conn->set.update_query,
+ auth_request_get_var_expand_table(request,
+ passdb_sql_escape));
+
+ sql_request = i_new(struct passdb_sql_request, 1);
+ sql_request->auth_request = request;
+ sql_request->callback.set_credentials = callback;
+
+ transaction = sql_transaction_begin(module->conn->db);
+ sql_update(transaction, str_c(query));
+ sql_transaction_commit(&transaction,
+ sql_set_credentials_callback, sql_request);
+
+ t_pop();
+ return 0;
+}
+
static struct passdb_module *
passdb_sql_preinit(struct auth_passdb *auth_passdb, const char *args)
{
@@ -223,7 +275,8 @@
passdb_sql_deinit,
sql_verify_plain,
- sql_lookup_credentials
+ sql_lookup_credentials,
+ sql_set_credentials
};
#endif
Index: passdb-vpopmail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-vpopmail.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- passdb-vpopmail.c 15 Oct 2006 20:30:06 -0000 1.25
+++ passdb-vpopmail.c 8 Nov 2006 20:22:08 -0000 1.26
@@ -153,7 +153,8 @@
vpopmail_deinit,
vpopmail_verify_plain,
- vpopmail_lookup_credentials
+ vpopmail_lookup_credentials,
+ NULL
};
#endif
Index: passdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- passdb.h 16 Jun 2006 10:01:25 -0000 1.34
+++ passdb.h 8 Nov 2006 20:22:08 -0000 1.35
@@ -35,6 +35,8 @@
typedef void lookup_credentials_callback_t(enum passdb_result result,
const char *password,
struct auth_request *request);
+typedef void set_credentials_callback_t(enum passdb_result result,
+ struct auth_request *request);
struct passdb_module_interface {
const char *name;
@@ -52,6 +54,11 @@
auth_request->credentials. */
void (*lookup_credentials)(struct auth_request *request,
lookup_credentials_callback_t *callback);
+
+ /* Update credentials */
+ int (*set_credentials)(struct auth_request *request,
+ const char *new_credentials,
+ set_credentials_callback_t *callback);
};
struct passdb_module {
More information about the dovecot-cvs
mailing list