Skip to content
Snippets Groups Projects
Commit 3e2a8df4 authored by Stephan Bosch's avatar Stephan Bosch Committed by aki.tuomi
Browse files

managesieve-login: Pass forward_ passdb args using XCLIENT command.

parent a869b1a8
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
#include "ostream.h"
#include "str.h"
#include "str-sanitize.h"
#include "strescape.h"
#include "safe-memset.h"
#include "buffer.h"
#include "base64.h"
......@@ -31,13 +32,43 @@ static const char *managesieve_proxy_state_names[MSIEVE_PROXY_STATE_COUNT] = {
"none", "tls-start", "tls-ready", "xclient", "auth"
};
static string_t *
proxy_compose_xclient_forward(struct managesieve_client *client)
{
const char *const *arg;
string_t *str;
if (*client->common.auth_passdb_args == NULL)
return NULL;
str = t_str_new(128);
for (arg = client->common.auth_passdb_args; *arg != NULL; arg++) {
if (strncasecmp(*arg, "forward_", 8) == 0) {
if (str_len(str) > 0)
str_append_c(str, '\t');
str_append_tabescaped(str, (*arg)+8);
}
}
if (str_len(str) == 0)
return NULL;
return str;
}
static void
proxy_write_xclient(struct managesieve_client *client, string_t *str)
{
str_printfa(str, "XCLIENT ADDR=%s PORT=%u SESSION=%s TTL=%u\r\n",
string_t *fwd = proxy_compose_xclient_forward(client);
str_printfa(str, "XCLIENT ADDR=%s PORT=%u SESSION=%s TTL=%u",
net_ip2addr(&client->common.ip), client->common.remote_port,
client_get_session_id(&client->common),
client->common.proxy_ttl - 1);
if (fwd != NULL) {
str_append(str, " FORWARD=");
base64_encode(str_data(fwd), str_len(fwd), str);
}
str_append(str, "\r\n");
}
static void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.