From 9d53d9ff3a74bad5f04357240d2d71935ddf5e66 Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Wed, 14 Feb 2024 00:58:14 -0500 Subject: [PATCH 1/2] Gracefully handle NS cert add myself A non-operator with the nick "mynick" attempts to register a fingerprint to their authenticated account. They /msg NickServ cert add mynick 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 --- irc/nickserv.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/irc/nickserv.go b/irc/nickserv.go index 94004070..6caf4112 100644 --- a/irc/nickserv.go +++ b/irc/nickserv.go @@ -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 client.Account() == target { + // If the target is equal to the account, then the user accidentally invoked operator + // syntax (cert add mynick ) instead of self syntax (cert add ). + target = "" + } } else if len(params) == 1 { certfp = params[0] } else if len(params) == 0 && verb == "add" && rb.session.certfp != "" { From 136dd1a2c100ec0ce72a46d41afd635c6ab3a52a Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 14 Feb 2024 09:53:17 -0500 Subject: [PATCH 2/2] Update nickserv.go Compare the case-normalized target to Account() --- irc/nickserv.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irc/nickserv.go b/irc/nickserv.go index 6caf4112..3e859160 100644 --- a/irc/nickserv.go +++ b/irc/nickserv.go @@ -1398,7 +1398,7 @@ func nsCertHandler(service *ircService, server *Server, client *Client, command case "add", "del": if 2 <= len(params) { target, certfp = params[0], params[1] - if client.Account() == target { + 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 ) instead of self syntax (cert add ). target = ""