Skip to content

Commit

Permalink
Try to authenticate using server password if user authentication hasn…
Browse files Browse the repository at this point in the history
…'t happened
  • Loading branch information
olabiniV2 committed Mar 26, 2020
1 parent b076a99 commit 495d699
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/grumble/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 495d699

Please sign in to comment.