From 292a46a9f0aa080983ceb51651bca49fe4bbf275 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Thu, 17 Oct 2019 23:28:31 +0200
Subject: [PATCH] managesieve: Store command args to client command contexts
 for debugging purposes.

---
 src/managesieve/managesieve-client.c | 5 +++++
 src/managesieve/managesieve-client.h | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/src/managesieve/managesieve-client.c b/src/managesieve/managesieve-client.c
index f110c573e..c4c8e970d 100644
--- a/src/managesieve/managesieve-client.c
+++ b/src/managesieve/managesieve-client.c
@@ -444,6 +444,7 @@ bool client_read_args(struct client_command_context *cmd, unsigned int count,
 		      const struct managesieve_arg **args_r)
 {
 	const struct managesieve_arg *dummy_args_r = NULL;
+	string_t *str;
 	int ret;
 
 	if (args_r == NULL)
@@ -467,6 +468,10 @@ bool client_read_args(struct client_command_context *cmd, unsigned int count,
 			}
 		}
 
+		str = t_str_new(256);
+		managesieve_write_args(str, *args_r);
+		cmd->args = p_strdup(cmd->pool, str_c(str));
+
 		/* all parameters read successfully */
 		return TRUE;
 	} else if (ret == -2) {
diff --git a/src/managesieve/managesieve-client.h b/src/managesieve/managesieve-client.h
index b640a54a2..9c40448cc 100644
--- a/src/managesieve/managesieve-client.h
+++ b/src/managesieve/managesieve-client.h
@@ -12,7 +12,12 @@ struct client_command_context {
 	struct client *client;
 
 	pool_t pool;
+	/* Name of this command */
 	const char *name;
+	/* Parameters for this command. These are generated from parsed
+	   ManageSieve arguments, so they may not be exactly the same as how
+	   client sent them. */
+	const char *args;
 
 	command_func_t *func;
 	void *context;
-- 
GitLab