After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 772915 - Fails to automatically identify using NickServ on OFTC network
Fails to automatically identify using NickServ on OFTC network
Status: RESOLVED FIXED
Product: polari
Classification: Applications
Component: general
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: Polari maintainers
Polari maintainers
: 773052 778384 784217 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-10-14 06:32 UTC by Mohammed Sadiq
Modified: 2017-06-26 14:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix for bug (1.13 KB, patch)
2017-04-13 15:10 UTC, justyn temme
none Details | Review
Proposed fix with method recomended (3.21 KB, patch)
2017-04-23 21:47 UTC, justyn temme
none Details | Review
Fixed with proposed issues (3.47 KB, patch)
2017-04-27 02:18 UTC, justyn temme
none Details | Review
Proposed patch (1.51 KB, patch)
2017-04-27 18:11 UTC, justyn temme
none Details | Review
patch (1.73 KB, patch)
2017-05-04 18:51 UTC, justyn temme
none Details | Review
Userserv error (7.69 KB, image/png)
2017-05-05 11:25 UTC, Florian Müllner
  Details
Patches (2.44 KB, patch)
2017-05-09 20:26 UTC, justyn temme
none Details | Review
First set of patches for proposed fix (3.09 KB, patch)
2017-05-10 11:56 UTC, justyn temme
none Details | Review
room: Make username parameter to send_identify() optional (2.01 KB, patch)
2017-06-21 16:41 UTC, Florian Müllner
committed Details | Review
telepathyClient: Only identify with nickname when necessary (1.58 KB, patch)
2017-06-21 16:41 UTC, Florian Müllner
committed Details | Review
telepathyClient: Always include username when it's known to work (3.39 KB, patch)
2017-06-21 16:41 UTC, Florian Müllner
committed Details | Review

Description Mohammed Sadiq 2016-10-14 06:32:58 UTC
Polari fails to Automatically identify on OFTC network

The syntax for NickServ identify seems different than the normal one, from NickServ Help:
Usage: IDENTIFY password [nick]
Comment 1 Florian Müllner 2016-10-16 19:15:49 UTC
*** Bug 773052 has been marked as a duplicate of this bug. ***
Comment 2 Bastian Ilsø 2016-12-22 17:07:59 UTC
i dont know what one would do for custom networks but for predefined networks one way to solve this would be by adding a new field in networks.json so we can define special cases like OFTC, fx:

  {
    "name": "OFTC",
    "id": "oftc",
    "authorder": {"password", "nick"},
    "servers": [
      { "ssl": false, "port": 6667, "address": "irc.oftc.net" }
    ]
  },

and then update the code inside polari-room.c / polari-util.c to be aware of this.

I guess the "real" solution is to support SASL though.
Comment 3 Florian Müllner 2017-02-09 11:08:51 UTC
*** Bug 778384 has been marked as a duplicate of this bug. ***
Comment 4 justyn temme 2017-04-12 23:32:10 UTC
I'm investigating this issue now.
Comment 5 justyn temme 2017-04-13 15:09:06 UTC
After checking out around 20 of the most popular irc networks i have come to find that most support "/msg nickserv identify password". Even if some supported the current paradigm most do not. The only ones that did not accept the paradigm offered by the patch required a whole separate form of ident generally of "/ident xxx xxx"

I will attach the patch i have suggested to remove the username field from the identify message.
Comment 6 justyn temme 2017-04-13 15:10:06 UTC
Created attachment 349824 [details] [review]
Proposed fix for bug

see last comment for explanation.
Comment 7 Florian Müllner 2017-04-21 23:44:34 UTC
Review of attachment 349824 [details] [review]:

The drawback of this approach is that NickServ identification doesn't work when connecting with a different nick (say, 'nick_'), and users have to revert back to manually identifying. Sorry, but I'm much more interested in working as best as we can with GNOME/Freenode than with some "wide range of irc servers".

Thinking about it, we may be able to do both without an elaborate scheme to determine what parameters a particular bot supports:
Just include the username parameter iff the configured nickname doesn't match the currently used one. This should work in all cases where identification currently works (unlike your patch), but also work for bots that don't understand the username parameter if the nickname matches the configured one (we'd still send a "wrong" identify command if the nickname doesn't match, but then the "correct" command would fail anyway because the nick isn't the registered one).

::: src/lib/polari-room.c
@@ +297,3 @@
   room->priv->ignore_identify = TRUE;
 
+  text = g_strdup_printf ("%s %s %s", command, password); //Updated to not send the username as most irc connections either don't require or will not be able to process with username.

Mismatch between number of format specifiers and parameters - this not only results in a compiler warning, but actually breaks nickserv identification where two parameters are supported.

Also: Try to keep lines at ~80 characters
Comment 8 justyn temme 2017-04-22 20:48:26 UTC
Sounds like i get to do some more research! Thanks for your suggestion i will look at implementing it and submitting a patch with the proposed idea. I think it is important to remember a large group of users use other irc networks as well so i want to make sure polari is rocking for those users as well (which just happens to include myself :)).
Comment 9 justyn temme 2017-04-23 21:47:19 UTC
Created attachment 350274 [details] [review]
Proposed fix with method recomended

Here is a patch with the solution as recommended.
Comment 10 Florian Müllner 2017-04-24 18:22:15 UTC
Review of attachment 350274 [details] [review]:

In addition to the errors below, please try to provide a proper commit message - https://chris.beams.io/posts/git-commit/ can provide some guidance. Multiple complete sentences on the *subject* line are a complete no-go ...

(Something like:
room: Only identify with nickname when necessary

Many NickServ bots only take a password parameter, which we don't support
as we currently always send the username parameter along to make sure
that identification is still possible when connecting with a nickname
that doesn't match the registered one. 
To address this without regressing for networks where the username is
understood, omit the optional parameter if it matches the currently
used nickname.

::: src/lib/polari-room.c
@@ +297,3 @@
   /* Don't emit ::identify-sent for our own identify message */
   room->priv->ignore_identify = TRUE;
+  if (strcmp(active_username, username)!=1) {

- the check is wrong - we want to know when the two
  nicknames are equal (== 0), not when they differ in
  some specific way
- style nit: space before opening parentheses and around
  operators
- style nit: use GNU-style indentation, omit braces when
  all blocks are single lines

::: src/lib/polari-room.h
@@ +40,3 @@
 void polari_room_send_identify_message_async (PolariRoom          *room,
                                               const char          *command,
+                                              const char          *active_username,

What is the use case for using any string other than the currently active username? If the answer is: "there is none", then the parameter shouldn't exist.

::: src/telepathyClient.js
@@ +311,3 @@
                 let room = this._roomManager.lookupRoomByChannel(channel);
+                let active_username = room.channel.connection.self_contact.alias;
+                log(active_username)

Left-over debug
Comment 11 justyn temme 2017-04-27 02:18:00 UTC
Created attachment 350520 [details] [review]
Fixed with proposed issues

Corrected the issues you raised, asked on irc about your statement 

"What is the use case for using any string other than the currently active username? If the answer is: "there is none", then the parameter shouldn't exist."

As i don't quite understand what issue you are raising, (forgive my ignorance) however it seems we are in different time zones, and i'm not always on irc, i figured bugzilla would be a better form of communication.

If there is something else that needs fixed please let me know and I will get right to work on it. 
-justyn
Comment 12 Florian Müllner 2017-04-27 09:34:10 UTC
(In reply to justyn temme from comment #11)
> Corrected the issues you raised, asked on irc about your statement 
> 
> "What is the use case for using any string other than the currently active
> username? If the answer is: "there is none", then the parameter shouldn't
> exist."

The 'active_username' parameter is awkward, so unless there is a good reason for it, I don't want it. "Getting the active nick is more verbose in C" is *not* a good reason, so unless there's a use case for passing in a different string, the patch should only change the send_identify_message() implementation, not the API.
Comment 13 justyn temme 2017-04-27 18:11:28 UTC
Created attachment 350576 [details] [review]
Proposed patch

Was able to consolidate the fix to a lot less code than originally submitted. Thanks for the advice i would have to agree with what you are saying. Again if there is another issue just let me know.
Comment 14 Florian Müllner 2017-04-27 21:15:12 UTC
Review of attachment 350576 [details] [review]:

::: src/lib/polari-room.c
@@ +300,3 @@
   room->priv->ignore_identify = TRUE;
 
+  if (strcmp (room->priv->self_nick, username) == 0)

No, that's not correct - "self_nick" is the string we use to decide whether a message should be highlighted, not necessarily the active nick:

https://git.gnome.org//browse/polari/tree/src/lib/polari-room.c#n354

For example if the current nick is "somenick__", self_nick will be "somenick".
Comment 15 justyn temme 2017-05-04 18:51:20 UTC
Created attachment 351073 [details] [review]
patch

Okay, everything is working. If you would rather me get the nick with nested function calls i can, however, I figured displaying each call would make it easier to read. Up to you, just let me know and I will change if needed.
Comment 16 Florian Müllner 2017-05-05 09:50:59 UTC
Review of attachment 351073 [details] [review]:

::: src/lib/polari-room.c
@@ +300,3 @@
   room->priv->ignore_identify = TRUE;
 
+  TpConnection *current_connection = tp_channel_get_connection(priv->channel);

Coding style: declarations after statements

@@ +302,3 @@
+  TpConnection *current_connection = tp_channel_get_connection(priv->channel);
+  TpContact *current_contact = tp_connection_get_self_contact(current_connection);
+  char *current_alias = tp_contact_get_alias(current_contact);

const char *
Comment 17 Florian Müllner 2017-05-05 11:25:21 UTC
Created attachment 351186 [details]
Userserv error

Sigh, I found a bot that requires the username ... :-(
Comment 18 Florian Müllner 2017-05-06 14:08:14 UTC
(In reply to Florian Müllner from comment #17)
> Sigh, I found a bot that requires the username ... :-(

OK, so I think we can support this case as well:

 - when the user identifies herself, also store whether
   the username was included in addition to botname, command,
   username and password

 - then include the username if it was provided originally or
   the currently active one doesn't match the stored one

Now, the settings are handled in the JS code, so we'll need to somehow pass to send_identify() that the username should be included unconditionally - a boolean force_username or similar would do the job, but "magic" booleans generally make for pretty bad API.

So what do you think of the following - split the patch in two, so that:

 1. the username parameter to send_identify() is made optional, and only
    send "<command> <password>" if it's not provided

 2. implement the "currentAlias == savedNickname" logic in the calling JS code

With that, I can easily add a 3rd patch on top to implement the above setting. (Or if you are interested in looking into that last part as well, just tell me and I'll be happy to assist you with that)
Comment 19 justyn temme 2017-05-06 16:19:48 UTC
well i think the best place to begin is adding the variable use-username
then as you said when it's grabbed simply document the number of args and determine if we need to send username as well.

if we could somehow use method overloading that would avoid the "magic" boolean. however both C and js lack those abilities. C11 has something of the sort with generic functions. not sure if that's the route we need to take

i will get started on the documenting if username was used but would like your input on how to proceed after that.
Comment 20 Florian Müllner 2017-05-06 16:57:03 UTC
(In reply to justyn temme from comment #19)
> if we could somehow use method overloading that would avoid the "magic"
> boolean. however both C and js lack those abilities.

Well, my idea would be to pass a username of %NULL if it shouldn't be sent, avoiding the magic boolean :-)
Comment 21 justyn temme 2017-05-08 15:35:05 UTC
okay before i get started changing code just wanted to make sure my goals aligned with yours. gameplan

js code
when does the username gets stored count number of args


if args = 3

use_username=0

C Code
change C function args to include use_username, 

depending on use username send username or not
Comment 22 Florian Müllner 2017-05-08 17:18:49 UTC
(In reply to justyn temme from comment #21)
> js code
> when does the username gets stored count number of args

You don't need to count the number of arguments, if a username was entered, it will be passed on the the JS code, otherwise it will be null:

https://git.gnome.org/browse/polari/tree/src/telepathyClient.js#n552

So

alwaysIncludeUsername = (username != null)


> C Code
> change C function args to include use_username,

That's possible, but I don't like a boolean like that. I prefer allowing %NULL for the username parameter, then have the JS code deal with the logic of whether or not it should be included. Something like:

let savedUsername = settings.get_string('identify-username');
let alwaysIncludeUsername = settings.get_boolean('identify-include-username');

this._requestChannel(() => {
    let includeUsername = alwaysIncludeUsername ||
                          channel.connection.self_contact.alias != username;
    room.send_identify_message_async(command, includeUsername ? username : null, password);
}


As far as history is concerned, I imagine at least three commits:

 - change the C function to accept %NULL
 - omit the username when it matches the currently used one
   (what your current patch does, but moved to JS)
 - add the setting and use it as well, to not regress for bots that
   require the username
Comment 23 justyn temme 2017-05-09 20:26:57 UTC
Created attachment 351481 [details] [review]
Patches

After applying as you had suggested javascript is alerting me the username param may NOT be null. I have cleared up the issue in the C code but the JS error still remains. Is this do to something in javascript or just my ingorance?
Comment 24 Florian Müllner 2017-05-09 21:19:10 UTC
You need to add the (nullable) annotation to mark the parameter as optional, see https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#GObject-Introspection_annotations.
Comment 25 justyn temme 2017-05-09 22:11:40 UTC
identify (null) ******** 

is the message it sends when i have added the proper g-introspection comment. it seems i'm going to have to check if the value is null and replace with an empty string, would a better option be in the js code passing "" as the username?
Comment 26 Florian Müllner 2017-05-09 22:55:16 UTC
(In reply to justyn temme from comment #25)
> identify (null) ******** 

Yes, you still have to do the "%s %s" vs. "%s %s %s" differentiation from the previous iteration.
Comment 27 justyn temme 2017-05-10 11:56:20 UTC
Created attachment 351538 [details] [review]
First set of patches for proposed fix

Okay, all that is left to do is to add the setting to check the arguments of the initial nickserv ident. i can add that fairly easy should have a patch uploaded here soon.
Comment 28 Florian Müllner 2017-05-10 20:39:49 UTC
Review of attachment 351538 [details] [review]:

(Note: splinter doesn't deal well with more than one patch per attachment, so separate attachments would be appreciated)

In addition to the comments below, both commit messages need work:
 - wrap lines
 - don't reword *what* the code is doing, describe *why* something is done
 - style: *never* start a message with "This commit does ..."
   https://chris.beams.io/posts/git-commit/ has good advice

::: src/telepathyClient.js
@@ +311,2 @@
                 let room = this._roomManager.lookupRoomByChannel(channel);
+                let active_username = room.channel.connection.self_contact.alias;

Style: camelCase

@@ +311,3 @@
                 let room = this._roomManager.lookupRoomByChannel(channel);
+                let active_username = room.channel.connection.self_contact.alias;
+                if (active_username == username) username = null;

Style: separate lines

Also the code isn't immediately obvious, so a small comment would be good

::: src/lib/polari-room.c
@@ +271,3 @@
+/**
+ * polari_room_send_identify_message_async:
+ *  @username: (nullable): Allows username to be passed as NULL

Either skip the doc part, or provide a proper documentation string

@@ +306,3 @@
 
+  if (username == NULL)
+    text = g_strdup_printf ("%s %s", command,password);

Nit: missing space
Comment 29 Florian Müllner 2017-05-11 11:11:36 UTC
Oh, and one more nit:
The patches are in the wrong order, you currently pass null to the function before the patch that makes this a valid value.
Comment 30 justyn temme 2017-05-11 17:24:50 UTC
It would seem we need to add the variable, use_username to overide as you suggested. My thoughts would be to add a key to org.gnome.Polari.gschema.xml. Are these added manually then edited by the code or is there a setter function for adding these variables i'm not aware of?
Comment 31 justyn temme 2017-05-30 17:17:14 UTC
Hey Florian life is busy so i do not want to press you. I would like to help the project and need a little more info on the idiomatic way to add variables to org.gnome.polari.gschema.xml. When you get time if you could point me in the direction of the right documentation, as i can't seem to find it, i would greatly appreciate it. I owe you a beer
Comment 32 Florian Müllner 2017-05-31 14:59:24 UTC
GSettings require every setting to be backed by a schema, so yes, you'll have to add any new one to the xml file. (We should also come up with something better than 'use-username' as well, as a value of false doesn't mean that we don't send it)
Comment 33 Florian Müllner 2017-06-21 16:41:33 UTC
Created attachment 354174 [details] [review]
room: Make username parameter to send_identify() optional

Not all NickServ bots understand the username parameter, so the
identify command we send doesn't work at all on those networks.
We will address this by not sending the username unconditionally,
so as a first step make the parameter optional.

(Fixed up patch according to review)
Comment 34 Florian Müllner 2017-06-21 16:41:40 UTC
Created attachment 354175 [details] [review]
telepathyClient: Only identify with nickname when necessary

Many NickServ bots only take a password parameter, while we currently
send the username along unconditionally to make sure that identification
is still possible when connecting with a nickname that doesn't match
the registered one.
In order to work both with bots that support an optional username
parameter and those that don't understand the parameter at all,
omit the username when it already matches the currently used nick.
Comment 35 Florian Müllner 2017-06-21 16:41:50 UTC
Created attachment 354176 [details] [review]
telepathyClient: Always include username when it's known to work

In addition to NickServ bots that don't support the username parameter
and those that optionally support it, there are also bots that require
it. To support those as well, store whether the user included the
username in the identify command - if it was, we know the parameter
is supported and we can always send it regardless of the currently
used nick.
Comment 36 Florian Müllner 2017-06-21 16:43:07 UTC
Attachment 354174 [details] pushed as dc9e903 - room: Make username parameter to send_identify() optional
Attachment 354175 [details] pushed as 03eef02 - telepathyClient: Only identify with nickname when necessary
Attachment 354176 [details] pushed as 87b377a - telepathyClient: Always include username when it's known to work
Comment 37 Florian Müllner 2017-06-26 14:25:35 UTC
*** Bug 784217 has been marked as a duplicate of this bug. ***