]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Store enabled flag for webui session
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 26 Oct 2016 09:41:36 +0000 (11:41 +0200)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 26 Oct 2016 10:19:22 +0000 (12:19 +0200)
src/controller.c
src/libserver/worker_util.h

index 8b5fdbaead2c4a0e211cdd91f5c8b6e5d153262d..a3c6dd22fde684184d91d544db1642626ccf90ad 100644 (file)
@@ -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 (
index 63a18a4fe381b83e0fa9234de0c87bd5b489c959..2ad312b0ef28623a8dcbf6cc48edb6ff0a79e7b2 100644 (file)
@@ -81,6 +81,7 @@ struct rspamd_controller_session {
        rspamd_inet_addr_t *from_addr;
        struct rspamd_config *cfg;
        gboolean is_spam;
+       gboolean is_enable;
 };
 
 /**