Browse Source

fix #2135

Handling of reserved nicknames is special-cased due to #1594, but we want to send
ERR_NICKNAMEINUSE if the nickname is actually in use, since that doesn't pose any
client compatibility problems.
pull/2136/head
Shivaram Lingamneni 1 month ago
parent
commit
837f6ac1a2
2 changed files with 10 additions and 1 deletions
  1. 8
    1
      irc/client_lookup_set.go
  2. 2
    0
      irc/nickname.go

+ 8
- 1
irc/client_lookup_set.go View File

@@ -116,6 +116,8 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
116 116
 		useAccountName = alwaysOn || config.Accounts.NickReservation.ForceNickEqualsAccount
117 117
 	}
118 118
 
119
+	nickIsReserved := false
120
+
119 121
 	if useAccountName {
120 122
 		if registered && newNick != accountName {
121 123
 			return "", errNickAccountMismatch, false
@@ -167,7 +169,9 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
167 169
 
168 170
 		reservedAccount, method := client.server.accounts.EnforcementStatus(newCfNick, newSkeleton)
169 171
 		if method == NickEnforcementStrict && reservedAccount != "" && reservedAccount != account {
170
-			return "", errNicknameReserved, false
172
+			// see #2135: we want to enter the critical section, see if the nick is actually in use,
173
+			// and return errNicknameInUse in that case
174
+			nickIsReserved = true
171 175
 		}
172 176
 	}
173 177
 
@@ -219,6 +223,9 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
219 223
 	if skeletonHolder != nil && skeletonHolder != client {
220 224
 		return "", errNicknameInUse, false
221 225
 	}
226
+	if nickIsReserved {
227
+		return "", errNicknameReserved, false
228
+	}
222 229
 
223 230
 	if dryRun {
224 231
 		return "", nil, false

+ 2
- 0
irc/nickname.go View File

@@ -43,6 +43,8 @@ func performNickChange(server *Server, client *Client, target *Client, session *
43 43
 		}
44 44
 	} else if err == errNicknameReserved {
45 45
 		if !isSanick {
46
+			// see #1594 for context: ERR_NICKNAMEINUSE can confuse clients if the nickname is not
47
+			// literally in use:
46 48
 			if !client.registered {
47 49
 				rb.Add(nil, server.name, ERR_NICKNAMEINUSE, details.nick, utils.SafeErrorParam(nickname), client.t("Nickname is reserved by a different account"))
48 50
 			}

Loading…
Cancel
Save