Bug 842183 - Land in comm-central Instantbird's changes to chat/ - 5 - Bio 1811 - IRC password does not work with ZNC/server password auth, r=aleth.
authorPatrick Cloke <clokep@gmail.com>
Thu, 22 Nov 2012 10:31:46 -0500
changeset 14881 ed567231bd4f3fd6d16fbcb1a809910e0692e539
parent 14880 7a9229f07072a53bd6b181b771c00441fe90c1e2
child 14882 daad988db75ff4efbb1e12c4046e52ca00d5eaa1
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaleth
bugs842183
Bug 842183 - Land in comm-central Instantbird's changes to chat/ - 5 - Bio 1811 - IRC password does not work with ZNC/server password auth, r=aleth.
chat/locales/en-US/irc.properties
chat/protocols/irc/irc.js
chat/protocols/irc/ircBase.jsm
chat/protocols/irc/ircNonStandard.jsm
chat/protocols/irc/ircServices.jsm
--- a/chat/locales/en-US/irc.properties
+++ b/chat/locales/en-US/irc.properties
@@ -2,16 +2,18 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # LOCALIZATION NOTE (connection.error.*):
 #   These will show in the account manager if the account is
 #   disconnected because of an error.
 connection.error.lost=Lost connection with server
 connection.error.timeOut=Connection timed out
+connection.error.invalidPassword=Invalid server password
+connection.error.passwordRequired=Password required
 
 # LOCALIZATION NOTE (joinChat.*):
 #   These show up on the join chat menu. An underscore is for the access key.
 joinChat.channel=_Channel
 joinChat.password=_Password
 
 # LOCALIZATION NOTE (options.*):
 #   These are the protocol specific options shown in the account manager and
--- a/chat/protocols/irc/irc.js
+++ b/chat/protocols/irc/irc.js
@@ -691,16 +691,18 @@ function ircAccount(aProtocol, aImAccoun
 }
 ircAccount.prototype = {
   __proto__: GenericAccountPrototype,
   _socket: null,
   _MODE_WALLOPS: 1 << 2, // mode 'w'
   _MODE_INVISIBLE: 1 << 3, // mode 'i'
   get _mode() 0,
 
+  // Whether to attempt authenticating with NickServ.
+  shouldAuthenticate: true,
   // Whether the user has successfully authenticated with NickServ.
   isAuthenticated: false,
   // The nickname stored in the account name.
   _accountNickname: null,
   // The nickname that will be used when connecting.
   _requestedNickname: null,
   // The prefix minus the nick (!user@host) as returned by the server, this is
   // necessary for guessing message lengths.
--- a/chat/protocols/irc/ircBase.jsm
+++ b/chat/protocols/irc/ircBase.jsm
@@ -1256,18 +1256,19 @@ var ircBase = {
     },
     "463": function(aMessage) { // ERR_NOPERMFORHOST
       // :Your host isn't among the privileged
       // TODO
       return false;
     },
     "464": function(aMessage) { // ERR_PASSWDMISMATCH
       // :Password incorrect
-      // TODO prompt user for new password
-      return false;
+      this.gotDisconnected(Ci.prplIAccount.ERROR_AUTHENTICATION_FAILED,
+                           _("connection.error.invalidPassword"));
+      return true;
     },
     "465": function(aMessage) { // ERR_YOUREBANEDCREEP
       // :You are banned from this server
       serverErrorMessage(this, aMessage, _("error.banned"));
       this.gotDisconnected(Ci.prplIAccount.ERROR_OTHER_ERROR,
                            _("error.banned")); // Notify account manager.
       return true;
     },
--- a/chat/protocols/irc/ircNonStandard.jsm
+++ b/chat/protocols/irc/ircNonStandard.jsm
@@ -20,16 +20,39 @@ Cu.import("resource:///modules/ircHandle
 Cu.import("resource:///modules/ircUtils.jsm");
 
 var ircNonStandard = {
   name: "Non-Standard IRC Extensions",
   priority: ircHandlers.DEFAULT_PRIORITY + 1,
   isEnabled: function() true,
 
   commands: {
+    "NOTICE": function(aMessage) {
+      // NOTICE <msgtarget> <text>
+      // If we receive a ZNC error message requesting a password, the
+      // serverPassword preference was not set by the user. Attempt to log into
+      // ZNC using the account password.
+      if (aMessage.params[0] != "AUTH" ||
+          aMessage.params[1] != "*** You need to send your password. Try /quote PASS <username>:<password>")
+        return false;
+
+      if (this.imAccount.password) {
+        // Send the password now, if it is available.
+        this.shouldAuthenticate = false;
+        this.sendMessage("PASS", this.imAccount.password,
+                         "PASS <password not logged>");
+      }
+      else {
+        // Otherwise, put the account in an error state.
+        this.gotDisconnected(Ci.prplIAccount.ERROR_AUTHENTICATION_IMPOSSIBLE,
+                             _("connection.error.passwordRequired"));
+      }
+      return true;
+    },
+
     "307": function(aMessage) {
       // TODO RPL_SUSERHOST (AustHex)
       // TODO RPL_USERIP (Undernet)
       // <user ips>
 
       // RPL_WHOISREGNICK (Unreal & Bahamut)
       // <nick> :is a registered nick
       if (aMessage.params.length == 3)
--- a/chat/protocols/irc/ircServices.jsm
+++ b/chat/protocols/irc/ircServices.jsm
@@ -47,17 +47,18 @@ function ServiceMessage(aAccount, aMessa
   return aMessage;
 }
 
 var ircServices = {
   name: "IRC Services",
   priority: ircHandlers.HIGH_PRIORITY,
   isEnabled: function() true,
   sendIdentify: function(aAccount) {
-    if (aAccount.imAccount.password && !aAccount.isAuthenticated) {
+    if (aAccount.imAccount.password && this.shouldAuthenticate &&
+        !aAccount.isAuthenticated) {
       aAccount.sendMessage("IDENTIFY", aAccount.imAccount.password,
                            "IDENTIFY <password not logged>");
     }
   },
 
   commands: {
     // If we automatically reply to a NOTICE message this does not abide by RFC
     // 2812. Oh well.
@@ -99,17 +100,17 @@ var ircServices = {
       // We always want the RFC 2812 handler to handle 001, so return false.
       return false;
     },
 
     "421": function(aMessage) { // ERR_UNKNOWNCOMMAND
       // <command> :Unknown command
       // IDENTIFY failed, try NICKSERV IDENTIFY.
       if (aMessage.params[1] == "IDENTIFY" && this.imAccount.password &&
-          !this.isAuthenticated) {
+          this.shouldAuthenticate && !this.isAuthenticated) {
         this.sendMessage("NICKSERV", ["IDENTIFY", this.imAccount.password],
                          "NICKSERV IDENTIFY <password not logged>");
         return true;
       }
       if (aMessage.params[1] == "NICKSERV") {
         WARN("NICKSERV command does not exist.");
         return true;
       }