1
0
Fork 0
forked from External/grumble

Try to authenticate using server password if user authentication hasn't happened

This commit is contained in:
Ola Bini 2020-03-26 16:11:47 +00:00
parent b076a99492
commit 495d699ec8
No known key found for this signature in database
GPG key ID: 6786A150F6A2B28F

View file

@ -256,6 +256,10 @@ func (server *Server) CheckServerPassword(password string) bool {
return server.checkConfigPassword("ServerPassword", password) 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. // Called by the server to initiate a new client connection.
func (server *Server) handleIncomingClient(conn net.Conn) (err error) { func (server *Server) handleIncomingClient(conn net.Conn) (err error) {
client := new(Client) 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. // Setup the cryptstate for the client.
err = client.crypt.GenerateKey(client.CryptoMode) err = client.crypt.GenerateKey(client.CryptoMode)
if err != nil { if err != nil {