[dovecot-cvs] dovecot/src/auth checkpassword-reply.c, 1.1,
1.2 passdb-checkpassword.c, 1.4, 1.5
cras at dovecot.org
cras at dovecot.org
Fri Jan 7 20:25:12 EET 2005
- Previous message: [dovecot-cvs] dovecot/src/auth Makefile.am, 1.39,
1.40 auth-client-connection.c, 1.24, 1.25 userdb.c, 1.14,
1.15 userdb.h, 1.14, 1.15 userdb-passdb.c, NONE, 1.1
- Next message: [dovecot-cvs]
dovecot/src/auth Makefile.am, 1.40, 1.41 auth-cache.c,
1.7, 1.8 auth-client-connection.c, 1.25,
1.26 auth-master-connection.c, 1.20, 1.21 auth-request.c, NONE,
1.1 auth-request.h, NONE, 1.1 main.c, 1.32,
1.33 mech-anonymous.c, 1.7, 1.8 mech-apop.c, 1.7,
1.8 mech-cram-md5.c, 1.14, 1.15 mech-digest-md5.c, 1.28,
1.29 mech-login.c, 1.5, 1.6 mech-ntlm.c, 1.11,
1.12 mech-plain.c, 1.23, 1.24 mech-rpa.c, 1.10, 1.11 mech.c,
1.52, 1.53 mech.h, 1.30, 1.31 userdb.h, 1.15, 1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv12321
Modified Files:
checkpassword-reply.c passdb-checkpassword.c
Log Message:
userdb = passdb works now with checkpassword passdb.
Index: checkpassword-reply.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/checkpassword-reply.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- checkpassword-reply.c 18 Jun 2004 03:40:12 -0000 1.1
+++ checkpassword-reply.c 7 Jan 2005 18:25:10 -0000 1.2
@@ -14,8 +14,20 @@
lib_init();
str = t_str_new(1024);
- str_printfa(str, "USER=%s\nHOME=%s\nSHELL=%s\nUID=%s\nGID=%s\n\n",
- getenv("USER"), getenv("HOME"), getenv("SHELL"),
+ if (strchr(getenv("USER"), '\t') != NULL) {
+ i_error("USER contains TAB");
+ return 1;
+ }
+ if (strchr(getenv("HOME"), '\t') != NULL) {
+ i_error("HOME contains TAB");
+ return 1;
+ }
+
+ str_printfa(str, "userdb_user=%s\t"
+ "userdb_home=%s\t"
+ "userdb_uid=%s\t"
+ "userdb_gid=%s\t",
+ getenv("USER"), getenv("HOME"),
dec2str(getuid()), dec2str(getgid()));
if (write_full(4, str_data(str), str_len(str)) < 0) {
Index: passdb-checkpassword.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-checkpassword.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- passdb-checkpassword.c 6 Dec 2004 16:39:02 -0000 1.4
+++ passdb-checkpassword.c 7 Jan 2005 18:25:10 -0000 1.5
@@ -5,6 +5,7 @@
#include "common.h"
#include "buffer.h"
+#include "str.h"
#include "ioloop.h"
#include "hash.h"
#include "passdb.h"
@@ -19,12 +20,15 @@
struct io *io_out, *io_in;
pid_t pid;
- buffer_t *input_buf;
+ string_t *input_buf;
char *password;
unsigned int write_pos;
struct auth_request *request;
- verify_plain_callback_t *callback;
+ verify_plain_callback_t *callback;
+
+ int exit_status;
+ unsigned int exited:1;
};
static char *checkpassword_path, *checkpassword_reply_path;
@@ -33,11 +37,6 @@
static void checkpassword_request_close(struct chkpw_auth_request *request)
{
- if (request->input_buf != NULL) {
- buffer_free(request->input_buf);
- request->input_buf = NULL;
- }
-
if (request->fd_in != -1) {
if (close(request->fd_in) < 0)
i_error("checkpassword: close() failed: %m");
@@ -61,18 +60,60 @@
{
hash_remove(clients, POINTER_CAST(request->pid));
- /* FIXME: store request->input_buf so userdb can fetch it */
+ if (result == PASSDB_RESULT_OK) {
+ request->request->extra_fields =
+ p_strdup(request->request->pool,
+ str_c(request->input_buf));
+ }
- if (auth_request_unref(request->request))
+ if (auth_request_unref(request->request)) {
request->callback(result, request->request);
+ }
checkpassword_request_close(request);
+ if (request->input_buf != NULL) {
+ str_free(request->input_buf);
+ request->input_buf = NULL;
+ }
+
safe_memset(request->password, 0, strlen(request->password));
i_free(request->password);
i_free(request);
}
+static void
+checkpassword_request_half_finish(struct chkpw_auth_request *request)
+{
+ if (!request->exited || request->fd_in != -1)
+ return;
+
+ switch (request->exit_status) {
+ case 0:
+ if (request->input_buf != NULL) {
+ checkpassword_request_finish(request, PASSDB_RESULT_OK);
+ break;
+ }
+ /* missing input - fall through */
+ case 1:
+ checkpassword_request_finish(request,
+ PASSDB_RESULT_USER_UNKNOWN);
+ break;
+ case 2:
+ /* checkpassword is called with wrong
+ parameters? unlikely */
+ case 111:
+ /* temporary problem, treat as internal error */
+ default:
+ /* whatever error.. */
+ i_error("checkpassword: Child %s exited with status %d",
+ dec2str(request->pid), request->exit_status);
+ checkpassword_request_finish(request,
+ PASSDB_RESULT_INTERNAL_FAILURE);
+ break;
+ }
+}
+
static void wait_timeout(void *context __attr_unused__)
{
struct chkpw_auth_request *request;
@@ -96,29 +137,10 @@
i_error("checkpassword: Child %s died with signal %d",
dec2str(pid), WTERMSIG(status));
} else if (WIFEXITED(status) && request != NULL) {
- switch (WEXITSTATUS(status)) {
- case 0:
- checkpassword_request_finish(request,
- PASSDB_RESULT_OK);
- request = NULL;
- break;
- case 1:
- checkpassword_request_finish(request,
- PASSDB_RESULT_OK);
- request = NULL;
- break;
- case 2:
- /* checkpassword is called with wrong
- parameters? unlikely */
- case 111:
- /* temporary problem, treat as internal error */
- default:
- /* whatever error.. */
- i_error("checkpassword: "
- "Child %s exited with status %d",
- dec2str(pid), WEXITSTATUS(status));
- break;
- }
+ request->exited = TRUE;
+ request->exit_status = WEXITSTATUS(status);
+ checkpassword_request_half_finish(request);
+ request = NULL;
}
if (request != NULL) {
@@ -159,12 +181,11 @@
if (ret < 0)
i_error("checkpassword: read() failed: %m");
checkpassword_request_close(request);
+ checkpassword_request_half_finish(request);
} else {
- if (request->input_buf == NULL) {
- request->input_buf =
- buffer_create_dynamic(default_pool, 512);
- }
- buffer_append(request->input_buf, buf, ret);
+ if (request->input_buf == NULL)
+ request->input_buf = str_new(default_pool, 512);
+ str_append_n(request->input_buf, buf, ret);
}
}
@@ -190,7 +211,8 @@
if (size > 512) {
i_error("checkpassword: output larger than 512 bytes: "
"%"PRIuSIZE_T, size);
- checkpassword_request_close(request);
+ checkpassword_request_finish(request,
+ PASSDB_RESULT_INTERNAL_FAILURE);
return;
}
@@ -199,7 +221,8 @@
if (ret <= 0) {
if (ret < 0)
i_error("checkpassword: write() failed: %m");
- checkpassword_request_close(request);
+ checkpassword_request_finish(request,
+ PASSDB_RESULT_INTERNAL_FAILURE);
return;
}
@@ -282,7 +305,7 @@
if (to_wait == NULL) {
/* FIXME: we could use SIGCHLD */
- to_wait = timeout_add(1000, wait_timeout, NULL);
+ to_wait = timeout_add(100, wait_timeout, NULL);
}
}
- Previous message: [dovecot-cvs] dovecot/src/auth Makefile.am, 1.39,
1.40 auth-client-connection.c, 1.24, 1.25 userdb.c, 1.14,
1.15 userdb.h, 1.14, 1.15 userdb-passdb.c, NONE, 1.1
- Next message: [dovecot-cvs]
dovecot/src/auth Makefile.am, 1.40, 1.41 auth-cache.c,
1.7, 1.8 auth-client-connection.c, 1.25,
1.26 auth-master-connection.c, 1.20, 1.21 auth-request.c, NONE,
1.1 auth-request.h, NONE, 1.1 main.c, 1.32,
1.33 mech-anonymous.c, 1.7, 1.8 mech-apop.c, 1.7,
1.8 mech-cram-md5.c, 1.14, 1.15 mech-digest-md5.c, 1.28,
1.29 mech-login.c, 1.5, 1.6 mech-ntlm.c, 1.11,
1.12 mech-plain.c, 1.23, 1.24 mech-rpa.c, 1.10, 1.11 mech.c,
1.52, 1.53 mech.h, 1.30, 1.31 userdb.h, 1.15, 1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list