Browse Source

Gracefully handle NS cert add myself <fp> (#2128)

* 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 <m@tthamilton.com>

* Update nickserv.go

Compare the case-normalized target to Account()

---------

Signed-off-by: Matt Hamilton <m@tthamilton.com>
Co-authored-by: Shivaram Lingamneni <slingamn@cs.stanford.edu>
pull/2131/head
Matt Hamilton 2 months ago
parent
commit
c67835ce5c
No account linked to committer's email address
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      irc/nickserv.go

+ 5
- 0
irc/nickserv.go View File

@@ -1398,6 +1398,11 @@ func nsCertHandler(service *ircService, server *Server, client *Client, command
1398 1398
 	case "add", "del":
1399 1399
 		if 2 <= len(params) {
1400 1400
 			target, certfp = params[0], params[1]
1401
+			if cftarget, err := CasefoldName(target); err == nil && client.Account() == cftarget {
1402
+				// If the target is equal to the account, then the user accidentally invoked operator
1403
+				// syntax (cert add mynick <fp>) instead of self syntax (cert add <fp>).
1404
+				target = ""
1405
+			}
1401 1406
 		} else if len(params) == 1 {
1402 1407
 			certfp = params[0]
1403 1408
 		} else if len(params) == 0 && verb == "add" && rb.session.certfp != "" {

Loading…
Cancel
Save