-
Notifications
You must be signed in to change notification settings - Fork 2
/
10-control_socket.patch
60 lines (57 loc) · 1.9 KB
/
10-control_socket.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Read socket location from config
diff -Nurp a/src/rspamadm/control.c b/src/rspamadm/control.c
--- a/src/rspamadm/control.c 2020-05-10 21:06:38.829101979 +0100
+++ b/src/rspamadm/control.c 2020-05-15 17:35:55.707002101 +0100
@@ -14,7 +14,10 @@
* limitations under the License.
*/
#include "config.h"
+#include "rspamd.h"
#include "rspamadm.h"
+#include "cfg_file.h"
+#include "cfg_rcl.h"
#include "cryptobox.h"
#include "printf.h"
#include "libserver/http/http_connection.h"
@@ -25,7 +28,12 @@
#include "libutil/util.h"
#include "lua/lua_common.h"
-static gchar *control_path = RSPAMD_DBDIR "/rspamd.sock";
+extern struct rspamd_main *rspamd_main;
+/* Defined in modules.c */
+extern module_t *modules[];
+extern worker_t *workers[];
+
+static gchar *control_path = NULL;
static gboolean json = FALSE;
static gboolean ucl = TRUE;
static gboolean compact = FALSE;
@@ -76,7 +84,7 @@ rspamadm_control_help (gboolean full_hel
"-c: output compacted json\n"
"-j: output linted json\n"
"-u: output ucl (default)\n"
- "-s: use the following socket instead of " RSPAMD_DBDIR "/rspamd.sock\n"
+ "-s: use the following socket instead of configured one\n"
"-t: set IO timeout (1.0 seconds default)\n"
"--help: shows available options and commands\n\n"
"Supported commands:\n"
@@ -171,6 +179,20 @@ rspamadm_control (gint argc, gchar **arg
struct rspamd_http_message *msg;
rspamd_inet_addr_t *addr;
static struct rspamadm_control_cbdata cbdata;
+ struct rspamd_config *cfg = rspamd_main->cfg;
+
+ cfg->compiled_modules = modules;
+ cfg->compiled_workers = workers;
+ cfg->cfg_name = FIXED_CONFIG_FILE;
+
+ if (!rspamd_config_read (cfg, cfg->cfg_name, NULL, rspamd_main,
+ ucl_vars, FALSE, lua_env)) {
+ control_path = RSPAMD_DBDIR "/rspamd.sock";
+ }
+ else
+ {
+ control_path = cfg->control_socket_path;
+ }
context = g_option_context_new (
"control - manage rspamd main control interface");