Code

frontend/connection: Require authentication before allowing any commands.
authorSebastian Harl <sh@tokkee.org>
Wed, 5 Feb 2014 21:08:54 +0000 (22:08 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 5 Feb 2014 21:08:54 +0000 (22:08 +0100)
src/frontend/connection.c

index f780979cac6ed333104d26f15bf2c8829184fb24..24735de2f0e55fac5ce8f7313445068f0ce9263e 100644 (file)
@@ -173,6 +173,13 @@ command_handle(sdb_conn_t *conn)
        sdb_log(SDB_LOG_DEBUG, "frontend: Handling command %u (len: %u)",
                        conn->cmd, conn->cmd_len);
 
+       if ((! conn->username) && (conn->cmd != CONNECTION_STARTUP)) {
+               const char *errmsg = "Authentication required";
+               sdb_connection_send(conn, CONNECTION_ERROR,
+                               (uint32_t)strlen(errmsg), errmsg);
+               return -1;
+       }
+
        /* reset */
        sdb_strbuf_sprintf(conn->errbuf, "");