Skip to content

Commit

Permalink
Gracefully handle NS cert add myself <fp> (#2128)
Browse files Browse the repository at this point in the history
* Gracefully handle NS cert add myself <fp>

A non-operator with the nick "mynick" attempts to register
a fingerprint to their authenticated account.

They /msg NickServ cert add mynick <fingerprint>

NickServ responds with "Insufficient privileges" because
they've accidentally invoked the operator syntax (to action
other accounts).

This patch allows the user to add the fingerprint if the client's
account is identical to the target account.

Signed-off-by: Matt Hamilton <[email protected]>

* Update nickserv.go

Compare the case-normalized target to Account()

---------

Signed-off-by: Matt Hamilton <[email protected]>
Co-authored-by: Shivaram Lingamneni <[email protected]>
  • Loading branch information
Eriner and slingamn authored Feb 14, 2024
1 parent 7afd6db commit c67835c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions irc/nickserv.go
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,11 @@ func nsCertHandler(service *ircService, server *Server, client *Client, command
case "add", "del":
if 2 <= len(params) {
target, certfp = params[0], params[1]
if cftarget, err := CasefoldName(target); err == nil && client.Account() == cftarget {
// If the target is equal to the account, then the user accidentally invoked operator
// syntax (cert add mynick <fp>) instead of self syntax (cert add <fp>).
target = ""
}
} else if len(params) == 1 {
certfp = params[0]
} else if len(params) == 0 && verb == "add" && rb.session.certfp != "" {
Expand Down

0 comments on commit c67835c

Please sign in to comment.