From: Vsevolod Stakhov Date: Wed, 26 Oct 2016 09:41:36 +0000 (+0200) Subject: [Feature] Store enabled flag for webui session X-Git-Tag: 1.4.0~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afa99d6cb1443fbea654027c3ecaa4057b610000;p=thirdparty%2Frspamd.git [Feature] Store enabled flag for webui session --- diff --git a/src/controller.c b/src/controller.c index 8b5fdbaead..a3c6dd22fd 100644 --- a/src/controller.c +++ b/src/controller.c @@ -505,6 +505,7 @@ static gboolean rspamd_controller_check_password( } else if (is_enable && (ctx->password == NULL && ctx->enable_password == NULL)) { + session->is_enable = TRUE; return TRUE; } } @@ -551,6 +552,10 @@ static gboolean rspamd_controller_check_password( "no password to check while executing a privileged command"); ret = FALSE; } + + if (ret) { + session->is_enable = TRUE; + } } else { /* Accept both normal and enable passwords */ @@ -594,6 +599,10 @@ static gboolean rspamd_controller_check_password( password, check, pbkdf, TRUE); } + + if (check_enable) { + session->is_enable = TRUE; + } } else { check_enable = FALSE; @@ -2246,6 +2255,8 @@ rspamd_controller_handle_stat_common ( task->http_conn = rspamd_http_connection_ref (conn_ent->conn);; task->sock = conn_ent->conn->fd; + ucl_object_insert_key (top, ucl_object_frombool (!session->is_enable), + "read_only", 0, false); ucl_object_insert_key (top, ucl_object_fromint ( stat->messages_scanned), "scanned", 0, false); ucl_object_insert_key (top, ucl_object_fromint ( diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h index 63a18a4fe3..2ad312b0ef 100644 --- a/src/libserver/worker_util.h +++ b/src/libserver/worker_util.h @@ -81,6 +81,7 @@ struct rspamd_controller_session { rspamd_inet_addr_t *from_addr; struct rspamd_config *cfg; gboolean is_spam; + gboolean is_enable; }; /**