summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-04-23 17:57:02 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-04-23 17:57:02 +0400
commit5b697ce84fa67e6d237d21001814b8f3a91342d6 (patch)
treed5d3bc0b9ebac93b72591f886f80afbf788d4476 /src
parentbd557979172ed598e2644575af3dd0ad8fffbd47 (diff)
downloadrspamd-5b697ce84fa67e6d237d21001814b8f3a91342d6.tar.gz
rspamd-5b697ce84fa67e6d237d21001814b8f3a91342d6.zip
* Allow full access to controller's commands without a password if
controller password is not specified in configuration. Fix some minor stuff while I'm here.
Diffstat (limited to 'src')
-rw-r--r--src/client/rspamc.c13
-rw-r--r--src/controller.c11
2 files changed, 9 insertions, 15 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index d91b8cdf0..7219d35b5 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -395,7 +395,7 @@ learn_rspamd_stdin (gboolean is_spam)
gint r = 0, len;
GError *err = NULL;
- if (password == NULL || (statfile == NULL && classifier == NULL)) {
+ if ((statfile == NULL && classifier == NULL)) {
fprintf (stderr, "cannot learn message without password and symbol/classifier name\n");
exit (EXIT_FAILURE);
}
@@ -462,7 +462,7 @@ learn_rspamd_file (gboolean is_spam, const gchar *file)
{
GError *err = NULL;
- if (password == NULL || (statfile == NULL && classifier == NULL)) {
+ if ((statfile == NULL && classifier == NULL)) {
fprintf (stderr, "cannot learn message without password and symbol/classifier name\n");
exit (EXIT_FAILURE);
}
@@ -514,10 +514,6 @@ fuzzy_rspamd_stdin (gboolean delete)
gint r = 0, len;
GError *err = NULL;
- if (password == NULL) {
- fprintf (stderr, "cannot learn message without password\n");
- exit (EXIT_FAILURE);
- }
/* Add server */
add_rspamd_server (TRUE);
@@ -559,11 +555,6 @@ fuzzy_rspamd_file (const gchar *file, gboolean delete)
{
GError *err = NULL;
- if (password == NULL) {
- fprintf (stderr, "cannot learn message without password\n");
- exit (EXIT_FAILURE);
- }
-
if (!rspamd_fuzzy_file (client, file, password, weight, flag, delete, &err)) {
if (err != NULL) {
fprintf (stderr, "cannot learn message: %s\n", err->message);
diff --git a/src/controller.c b/src/controller.c
index c24d240c8..d11edbfe6 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -194,7 +194,7 @@ free_session (void *ud)
close (session->sock);
memory_pool_delete (session->session_pool);
- g_free (session);
+ g_slice_free1 (sizeof (struct controller_session), session);
}
static gint
@@ -478,7 +478,7 @@ process_command (struct controller_command *cmd, gchar **cmd_args, struct contro
return TRUE;
}
if (ctx->password == NULL) {
- r = rspamd_snprintf (out_buf, sizeof (out_buf), "password command disabled in config, authorized access unallowed" CRLF);
+ r = rspamd_snprintf (out_buf, sizeof (out_buf), "password command disabled in config, authorized access granted" CRLF);
if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) {
return FALSE;
}
@@ -1196,12 +1196,12 @@ accept_socket (gint fd, short what, void *arg)
return;
}
- new_session = g_malloc (sizeof (struct controller_session));
+ new_session = g_slice_alloc0 (sizeof (struct controller_session));
if (new_session == NULL) {
msg_err ("cannot allocate memory for task, %s", strerror (errno));
return;
}
- bzero (new_session, sizeof (struct controller_session));
+
new_session->worker = worker;
new_session->sock = nfd;
new_session->cfg = worker->srv->cfg;
@@ -1209,6 +1209,9 @@ accept_socket (gint fd, short what, void *arg)
new_session->session_pool = memory_pool_new (memory_pool_get_size () - 1);
new_session->resolver = ctx->resolver;
new_session->ev_base = ctx->ev_base;
+ if (ctx->password == NULL) {
+ new_session->authorized = TRUE;
+ }
worker->srv->stat->control_connections_count++;
/* Set up dispatcher */