From 495d699ec82b30187eca72cadfdd1c755798b6e5 Mon Sep 17 00:00:00 2001 From: Ola Bini Date: Thu, 26 Mar 2020 16:11:47 +0000 Subject: Try to authenticate using server password if user authentication hasn't happened --- cmd/grumble/server.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/grumble/server.go b/cmd/grumble/server.go index edc6a6f..663b791 100644 --- a/cmd/grumble/server.go +++ b/cmd/grumble/server.go @@ -256,6 +256,10 @@ func (server *Server) CheckServerPassword(password string) bool { return server.checkConfigPassword("ServerPassword", password) } +func (server *Server) hasServerPassword() bool { + return server.cfg.StringValue("ServerPassword") != "" +} + // Called by the server to initiate a new client connection. func (server *Server) handleIncomingClient(conn net.Conn) (err error) { client := new(Client) @@ -535,6 +539,13 @@ func (server *Server) handleAuthenticate(client *Client, msg *Message) { } } + if client.user == nil && server.hasServerPassword() { + if auth.Password == nil || !server.CheckServerPassword(*auth.Password) { + client.RejectAuth(mumbleproto.Reject_WrongServerPW, "Invalid server password") + return + } + } + // Setup the cryptstate for the client. err = client.crypt.GenerateKey(client.CryptoMode) if err != nil { -- cgit v1.2.3