Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2135 #2136

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion irc/client_lookup_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
useAccountName = alwaysOn || config.Accounts.NickReservation.ForceNickEqualsAccount
}

nickIsReserved := false

if useAccountName {
if registered && newNick != accountName {
return "", errNickAccountMismatch, false
Expand Down Expand Up @@ -167,7 +169,9 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick

reservedAccount, method := client.server.accounts.EnforcementStatus(newCfNick, newSkeleton)
if method == NickEnforcementStrict && reservedAccount != "" && reservedAccount != account {
return "", errNicknameReserved, false
// see #2135: we want to enter the critical section, see if the nick is actually in use,
// and return errNicknameInUse in that case
nickIsReserved = true
}
}

Expand Down Expand Up @@ -219,6 +223,9 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
if skeletonHolder != nil && skeletonHolder != client {
return "", errNicknameInUse, false
}
if nickIsReserved {
return "", errNicknameReserved, false
}

if dryRun {
return "", nil, false
Expand Down
2 changes: 2 additions & 0 deletions irc/nickname.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func performNickChange(server *Server, client *Client, target *Client, session *
}
} else if err == errNicknameReserved {
if !isSanick {
// see #1594 for context: ERR_NICKNAMEINUSE can confuse clients if the nickname is not
// literally in use:
if !client.registered {
rb.Add(nil, server.name, ERR_NICKNAMEINUSE, details.nick, utils.SafeErrorParam(nickname), client.t("Nickname is reserved by a different account"))
}
Expand Down
Loading