client_destroy(client, destroy_reason);
}
+void client_rawlog_init(struct client *client)
+{
+ if (login_rawlog_dir == NULL)
+ return;
+
+ client->pre_rawlog_input = client->input;
+ client->pre_rawlog_output = client->output;
+ if (iostream_rawlog_create(login_rawlog_dir, &client->input,
+ &client->output) < 0) {
+ login_rawlog_dir = NULL;
+ return;
+ }
+ client->rawlog_input = client->input;
+ client->rawlog_output = client->output;
+}
+
+void client_rawlog_deinit(struct client *client)
+{
+ if (client->rawlog_input == NULL)
+ return;
+
+ i_assert(client->rawlog_input == client->input);
+ i_assert(client->rawlog_output == client->output);
+ i_stream_ref(client->pre_rawlog_input);
+ o_stream_ref(client->pre_rawlog_output);
+ i_stream_destroy(&client->rawlog_input);
+ o_stream_destroy(&client->rawlog_output);
+ client->input = client->pre_rawlog_input;
+ client->output = client->pre_rawlog_output;
+}
+
static void client_open_streams(struct client *client)
{
client->input = i_stream_create_fd(client->fd, LOGIN_MAX_INBUF_SIZE);
client->output = o_stream_create_fd(client->fd, LOGIN_MAX_OUTBUF_SIZE);
o_stream_set_no_error_handling(client->output, TRUE);
- if (login_rawlog_dir != NULL) {
- if (iostream_rawlog_create(login_rawlog_dir, &client->input,
- &client->output) < 0)
- login_rawlog_dir = NULL;
- }
+ client_rawlog_init(client);
}
static const char *
if (client->v.iostream_change_pre != NULL)
client->v.iostream_change_pre(client);
+ client_rawlog_deinit(client);
const struct ssl_iostream_server_autocreate_parameters parameters = {
.event_parent = client->event,
.application_protocols = login_binary->application_protocols,
&client->ssl_iostream, &error);
if (client->v.iostream_change_post != NULL)
client->v.iostream_change_post(client);
+ client_rawlog_init(client);
if (ret < 0) {
e_error(client->event,
"Failed to initialize SSL connection: %s", error);
int fd;
struct istream *input;
struct ostream *output;
+ /* The rawlog streams don't hold any references */
+ struct istream *pre_rawlog_input, *rawlog_input;
+ struct ostream *pre_rawlog_output, *rawlog_output;
/* If non-NULL, this is the multiplex ostream. It is usually the same
as the output pointer, but some plugins may make them different.
This isn't holding a reference, so it must not be unreferenced. */
void client_ref(struct client *client);
bool client_unref(struct client **client) ATTR_NOWARN_UNUSED_RESULT;
+void client_rawlog_init(struct client *client);
+void client_rawlog_deinit(struct client *client);
+
int client_init_ssl(struct client *client);
void client_cmd_starttls(struct client *client);
client->output = proxy->client_output;
/* iostream_change_pre() may change iostreams */
- if (client->v.iostream_change_pre != NULL) {
+ if (client->v.iostream_change_pre != NULL)
client->v.iostream_change_pre(client);
- proxy->client_input = client->input;
- proxy->client_output = client->output;
- }
+ client_rawlog_deinit(client);
+
+ proxy->client_input = client->input;
+ proxy->client_output = client->output;
}
void login_proxy_replace_client_iostream_post(struct login_proxy *proxy,
if (client->v.iostream_change_post != NULL)
client->v.iostream_change_post(client);
+ client_rawlog_init(client);
/* iostream_change_post() may have replaced the iostreams */
proxy->client_input = client->input;