From: Sebastian Harl Date: Wed, 5 Feb 2014 21:08:54 +0000 (+0100) Subject: frontend/connection: Require authentication before allowing any commands. X-Git-Tag: sysdb-0.1.0~219 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7b0d0d7f084465e71ac2fcfbe4efffa71a69a8d0;p=sysdb.git frontend/connection: Require authentication before allowing any commands. --- diff --git a/src/frontend/connection.c b/src/frontend/connection.c index f780979..24735de 100644 --- a/src/frontend/connection.c +++ b/src/frontend/connection.c @@ -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, "");