From: Timo Sirainen Date: Wed, 7 Apr 2010 11:47:40 +0000 (+0300) Subject: lib-master: Fixed errors with post-login scripts. X-Git-Tag: 2.0.beta5~164 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dfb7dad13078cc8674749ac7135436197890bcdc;p=thirdparty%2Fdovecot%2Fcore.git lib-master: Fixed errors with post-login scripts. --HG-- branch : HEAD --- diff --git a/src/lib-master/master-login.c b/src/lib-master/master-login.c index 3a5586bf43..bd7fbf8c98 100644 --- a/src/lib-master/master-login.c +++ b/src/lib-master/master-login.c @@ -337,6 +337,7 @@ master_login_auth_callback(const char *const *auth_args, const char *errormsg, void *context) { struct master_login_client *client = context; + struct master_login_connection *conn = client->conn; struct master_auth_reply reply; memset(&reply, 0, sizeof(reply)); @@ -344,21 +345,27 @@ master_login_auth_callback(const char *const *auth_args, const char *errormsg, reply.status = errormsg == NULL ? MASTER_AUTH_STATUS_OK : MASTER_AUTH_STATUS_INTERNAL_ERROR; reply.mail_pid = getpid(); - o_stream_send(client->conn->output, &reply, sizeof(reply)); + o_stream_send(conn->output, &reply, sizeof(reply)); if (errormsg != NULL || auth_args[0] == NULL) { if (auth_args != NULL) { i_error("login client: Username missing from auth reply"); errormsg = MASTER_AUTH_ERRMSG_INTERNAL_FAILURE; } - client->conn->login->failure_callback(client, errormsg); + conn->login->failure_callback(client, errormsg); master_login_client_free(&client); return; } - if (client->conn->login->postlogin_socket_path == NULL) + if (conn->login->postlogin_socket_path == NULL) master_login_auth_finish(client, auth_args); else { + /* we've sent the reply. the connection is no longer needed, + so disconnect it (before login process disconnects us and + logs an error) */ + master_login_conn_close(conn); + master_login_conn_unref(&conn); + /* execute post-login scripts before finishing auth */ if (master_login_postlogin(client, auth_args) < 0) master_login_client_free(&client);