1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-30 21:55:24 +00:00
Commit Graph

926 Commits

Author SHA1 Message Date
Michael Vetter
f692d6d0e0 xep-0084: Make it work multiple times 2019-12-18 13:14:17 +01:00
Michael Vetter
c2aa585615 xep-0084: Download avatars
Proof of concept.
Needs error checking, a nice interface, general cleanup..
2019-12-18 12:50:09 +01:00
Michael Vetter
e3538cf739 xep-0084: Look for specific user and print ID
Add a `/avatar` command.
2019-12-18 11:24:50 +01:00
Michael Vetter
771dfab123 Start implementing XEP-0084
So far we just subscribe and get the IDs.
2019-12-18 10:17:10 +01:00
Michael Vetter
548b64f6c5 Fix stanza_get_child_by_name_and_from() strcmp
Fix https://github.com/profanity-im/profanity/issues/1227
2019-11-14 19:22:06 +01:00
Michael Vetter
46fd7150e5 Add vim modeline 2019-11-13 12:11:05 +01:00
Michael Vetter
61f66966dd Check for correct delay tag for muc timestamps
https://github.com/profanity-im/profanity/issues/1190 had another issue:
Sometimes servers send multiple </delay> and we just checked the first
one we got and only used it if the 'from' attribute was fitting.
However it could be that we actually wanted the second </delay> element
and there the 'from' would have been right.

So we need to loop through them until we get the one with the fitting
'from'.

Fix https://github.com/profanity-im/profanity/issues/1190
2019-11-13 09:41:19 +01:00
Michael Vetter
196e029b47 Fix stanza_get_child_by_name_and_ns() if no name
Fix bug introduced in 68af0aad65.
2019-11-12 16:18:28 +01:00
Michael Vetter
68af0aad65 _handle_groupchat(): get correct origin-id stanza
The problem is that in _handle_groupchat() we look for
STANZA_NS_STABLE_ID which will result in origin-id or stanza-id.
It seems like prosody servers send origin-id first, so this worked in
all my tests. But actually we cannot be sure of the order.
So far we stopped after the first element was found.

I only found xmpp_stanza_get_child_by_ns() and
xmpp_stanza_get_child_by_name() in libstrophe. But we need a combination
of both.

So I created stanza_get_child_by_name_and_ns() for Profanity. I need to
remember to upstream this to libstrophe later (if they really don't have
such a function).

Fix https://github.com/profanity-im/profanity/issues/1223
2019-11-08 15:05:49 +01:00
Michael Vetter
f71de61b9d Don't override ProfMessage Id with origin-id
Profanity sends the same value for both. Other clients might not.
Safe both since we could need them later.

Once we implement Last Message Correction we will need the regular id.
If we override it with origin-id and another client chooses to not use
the same value for id and origin-id then we can't interpret the id sent
with the LMC request correctly.
2019-10-31 13:45:44 +01:00
aszlig
b1e960cfae
omemo: Check stanza names when iterating nodes
Some clients (eg. PSI) are sending the stanzas delimited by whitespace
text nodes, which will fail while looping through the <prekeys/>
children and also print weird errors when iterating through the <list/>
of devices.

When debugging this, I was looking at the XML of Gajim and PSI and first
was somehow confused why Profanity printed "OMEMO: received device
without ID" while the XML looked identical (minus the actual IDs and the
JIDs of course).

However, Gajim was sending the XML without whitespace nodes in between
and PSI did not, so for example the following (with the relevant
whitespace nodes marked with X):

  <message type="headline" to="..." from="...">
    <event xmlns="http://jabber.org/protocol/pubsub#event">
      <items type="headline" node="eu.siacs.conversations.axolotl.devicelist">
        <item id="...">
          <list xmlns="eu.siacs.conversations.axolotl">
          X <device id="..."/>
          X <device id="..."/> X
          </list>
        </item>
      </items>
    </event>
    <delay xmlns="urn:xmpp:delay" stamp="..." from="..."/>
  </message>

... would result in three times the "OMEMO: received device without ID"
error, because we actually have three XML text nodes here that obviously
don't have an "id" attribute.

Now since the <list/> children above aren't really a problem and only
annoying, text nodes in the <prekeys/> stanza actually cause
omemo_start_device_session_handle_bundle to return failure.

I've fixed this by explicitly matching the stanza names we are
interested in, skipping everything else.

Signed-off-by: aszlig <aszlig@nix.build>
Reported-by: @devhell
2019-10-29 23:10:07 +01:00
Michael Vetter
7dd747b58d Set mucuser in carbon case
Also we initialize mucuser properly.

Now in case of a carbon of a MUC PM we sv_ev_incoming_carbon() which
calls _sv_ev_incoming_plain() and then we log it via chat_log_msg_in()
in there.
But we also get the sv_ev_incoming_private_message() and call
chat_log_msg_in() in there too. So the incoming message get's logged
twice.
2019-10-29 10:41:07 +01:00
Michael Vetter
22bf281399 Make prof_identifier const 2019-10-22 12:47:32 +02:00
Michael Vetter
6b75848f96 Display ownership of connection_get_profanity_identifier 2019-10-22 12:04:16 +02:00
Michael Vetter
ba18752405 Use UUID in origin-id and id
Let's use UUID to have a more random string then just 10 alphanumeric
values.
2019-10-22 11:10:37 +02:00
Michael Vetter
ef19b45e64 Remove old comment
It's not up to date.
Some time ago we changed from individual handlers to general ones.
2019-10-21 10:28:29 +02:00
Michael Vetter
963ab841b4 Set prof_ident to NULL after free
This caused the bug mentioned in the PR comment:

```
It seems with the changes done here we get a crash in: src/xmpp/message.c message_handlers_init() when looking up handlers: ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, curr->data);.

Steps to reproduce:

    open Profanity and connect
    /autoping set 10
    /autoping timeout 10
    stop WiFi/connection
    wait for Lost connection
    restart wifi
    /connect
```
2019-10-21 09:50:13 +02:00
Michael Vetter
8a5932b251 Rename _calculate_identifier to _compute_identifier 2019-10-20 00:01:19 +02:00
Michael Vetter
db4b55eee0 Rename random_bytes to profanity_instance_id 2019-10-19 23:27:19 +02:00
Michael Vetter
2a4d1b8410 Free hmac and msgid 2019-10-19 08:18:37 +02:00
Michael Vetter
f190d2c5f2 Free prof_identifier in case of reconnect
Bedore we assign it new.
2019-10-19 07:40:59 +02:00
Michael Vetter
c3912df05b Move ProfMessage and message_is_sent_by_us to xmpp
Not meant for internal usage only.
2019-10-19 06:36:47 +02:00
Michael Vetter
4d7a496ae2 Change origin-id/id algo
Hash twice.
Use HMAC SHA256 from glib.
2019-10-18 16:12:26 +02:00
Michael Vetter
06f300a42c Move message sent by us logic in own function 2019-10-18 14:50:25 +02:00
Michael Vetter
5c6f5ba0f7 Add connection_get_profanity_identifier stub
And move defintion to xmpp.h
2019-10-18 11:23:30 +02:00
Michael Vetter
33083662d1 Add XEP-0359 to capabilities
We implement </origin-id> from [XEP-0359](https://xmpp.org/extensions/xep-0359.html).
We already had this implemented for OMEMO. And now use it to check
whether MUC messages were sent from us
(https://github.com/profanity-im/profanity/issues/1201).

We don't implement </stanza-id> yet, but probably need to do so for MAM.

Anyways let's flag this as implementing the XEP.

Fix https://github.com/profanity-im/profanity/issues/1207
2019-10-18 10:46:06 +02:00
Michael Vetter
430b2eaa0d Log incoming MUC messages if origin-id sais they dont come from us
Regards https://github.com/profanity-im/profanity/issues/1201
2019-10-18 10:40:24 +02:00
Michael Vetter
53640f6e97 Remove prefix from stanza id
We sent `prof_prefix_uuid` as id. Where the prefix was also optional.
We don't need this at all.
2019-10-17 15:40:40 +02:00
Michael Vetter
827af999b7 Change algo for connection_create_stanza_id() 2019-10-17 15:32:46 +02:00
Michael Vetter
8f5d1751b2 Change connection_create_stanza_id()
To return identifier and uuid together.
We can remove the prefix later on.
2019-10-17 09:23:11 +02:00
Michael Vetter
708bc83870 Calculate identifier upon connect
This will be needed so that we can later detect if messages (origin-in)
was sent by us.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 15:53:28 +02:00
Michael Vetter
ee0541a262 Rename identification file 2019-10-16 10:54:05 +02:00
Michael Vetter
46f0304f89 Use random string for random-bytes identifier
And rename `instance` to `identifier`.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 10:45:41 +02:00
Michael Vetter
f9eb302a59 Move code from jid_random_resource() into own function
Move the code that creates a random string into it's own function
+get_random_string().
2019-10-16 10:39:35 +02:00
Michael Vetter
1e09a055ca Create random-bytes file
So far only with dummy value.
We will need an identifier that we can hash together with a message ID
and put in as the origin-id.
So when we receive message we can unsplit it and see if it was sent from
this client.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 10:17:34 +02:00
Michael Vetter
b3ed213668 Improve MUC 1:1 logging
If we get a private message from a user in a MUC profanity shows this
like:
`profanity@roomsASDF.dismail.de/Martin: Hi`

This was so far logged at:
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de/2019_09_04.log` as:

```
10:48:13 - profanity@rooms.dismail.de: Hi
```

So the nickname was not saved anywhere. This is due to us not knowing
whether we got a regular message from user@server.org/resource or a MUC
PM from room@server.org/user.

We now check for `<x xmlns='http://jabber.org/protocol/muc#user' />` and
add the resourcepart to the logging if we get it.

The file will be created at
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de_nick` and look like:

```
23:59:43 - nick: Hi
```

Fix https://github.com/profanity-im/profanity/issues/1184
2019-10-07 00:05:37 +02:00
Michael Vetter
f1d31e024c Fix typo handel -> handle 2019-10-06 23:00:08 +02:00
Michael Vetter
94b401ab96 Fix invalid read in muc code
We didn't set the variables to NULL, but the rest of the code depends on
this check.
```
==22201== Invalid read of size 8
==22201==    at 0x44E560: autocomplete_clear (autocomplete.c:69)
==22201==    by 0x427B2C: muc_invites_clear (muc.c:190)
==22201==    by 0x461328: ev_disconnect_cleanup (common.c:59)
==22201==    by 0x463FB5: cl_ev_disconnect (client_events.c:91)
==22201==    by 0x431252: cmd_disconnect (cmd_funcs.c:1234)
==22201==    by 0x47E883: clears_chat_sessions
(test_cmd_disconnect.c:28)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
==22201==  Address 0x814b690 is 0 bytes inside a block of size 24 free'd
==22201==    at 0x48379AB: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22201==    by 0x44E5F7: autocomplete_free (autocomplete.c:90)
==22201==    by 0x4278A0: muc_close (muc.c:97)
==22201==    by 0x47DBAA: cmd_join_uses_password_when_supplied
(test_cmd_join.c:169)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
==22201==  Block was alloc'd at
==22201==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22201==    by 0x44E51B: autocomplete_new (autocomplete.c:57)
==22201==    by 0x427837: muc_init (muc.c:88)
==22201==    by 0x47DA77: cmd_join_uses_password_when_supplied
(test_cmd_join.c:154)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
```
2019-10-06 19:00:46 +02:00
Michael Vetter
6ab6fe8649 Detect MUC history correctly with some Prosody versions
Some versions of prosody send the domainpart.
See https://issues.prosody.im/1416

Workaround to handle those cases.
Thanks to Holger Weiss for helping with this!

Fix https://github.com/profanity-im/profanity/issues/1190
2019-09-30 10:01:19 +02:00
Michael Vetter
6cf06dc516 Log alleged roster push to file
https://gultsch.de/dino_multiple.html mentions CVE-2019-16235, CVE-2019-16236 and CVE-2019-16237.

CVE-2019-16235: Is checking the from in carbon messages. We do that.
CVE-2019-16236: Is checking the from in roster pushes. We do that but
didn't log it yet.
CVE-2019-16237: Is checking the form in MAM messages. We don't support
them yet.
2019-09-12 20:55:16 +02:00
Michael Vetter
09c5f38f11 Set message->plain in carbon case
message->plain should always contain something. In the case of the
carbons we forgot to set if rom the body in case it's empy.
2019-09-04 10:27:03 +02:00
Michael Vetter
dacbe25d93 Remove duplicate code in roster_update
Part of what `roster_update()` does manually is actually done in
`roster_change_name()`.
2019-08-23 09:50:53 +02:00
Holger Weiß
3228ab47d3 Don't render (all) delayed messages as MUC history
Double-check that a <delay/> tag on a groupchat message was actually
added by the MUC service (rather than the sending client) before
assuming it was received from the MUC history.

Fixes #1173.
2019-08-20 17:51:26 +02:00
Paul Fariello
b3e59e1fb6 Fix memleak in /cmd exec 2019-07-30 13:35:08 +02:00
Paul Fariello
5e61bc08dd Fix command form submit
Command form userdata were freed by iq_id_handler.
We should now free the command ourself.
2019-07-30 10:22:57 +02:00
Michael Vetter
41bf7f4b22
Merge pull request #1160 from profanity-im/fix/1159-groupaddsegfault
Fix segfault in group add/remove command
2019-07-22 20:16:27 +02:00
Michael Vetter
9f0a40819f Fix memleak in roster_change_name() 2019-07-22 15:37:41 +02:00
Michael Vetter
46ddf2c2f4 Fix memleak in roster_remove
strdup() is not needed here but will actually lead to a memleak.
2019-07-22 14:47:45 +02:00
Michael Vetter
41267ae1c5 Fix memory leak in roster_update()
current_name should not be const and should be freed.
2019-07-22 14:42:43 +02:00
Michael Vetter
fa27ab9561 Fix segfault in group add/remove command
Also regarding destructor.
Fix https://github.com/profanity-im/profanity/issues/1159
2019-07-22 11:54:05 +02:00
Michael Vetter
d3828cf24e Fix segfault in block command
Another case of double free() due to new destructor.

Fixes https://github.com/profanity-im/profanity/issues/1156
2019-07-19 12:38:33 +02:00
Michael Vetter
c07d533ec1 Fixup for last commit 2019-07-12 11:11:45 +02:00
Michael Vetter
68b6deefbf Fix segfault in iq_{submit,cancel}_command_config
Taken care of by the destructor.
2019-07-12 10:57:07 +02:00
Michael Vetter
ad41959cc6
Merge pull request #1150 from paulfariello/hotfix/omemo-memleaks
Hotfix/omemo memleaks

Regards https://github.com/profanity-im/profanity/issues/1131
2019-07-11 16:19:31 +02:00
Michael Vetter
f32827d70d Fix some more potential double frees
Regards https://github.com/profanity-im/profanity/issues/1148
2019-07-11 16:15:57 +02:00
Paul Fariello
b110da9a92 Fix various OMEMO memleaks 2019-07-10 17:32:23 +02:00
Michael Vetter
6c8e567328 Reduce codelines in form.c
Let's use calloc instead of malloc and then setting almost all fields to
NULL.
2019-07-10 12:53:45 +02:00
Michael Vetter
a8b3de7016 Fix double free in roster_process_pending_presence
This is taken care of now in the destructor _pendingPresence_free().
2019-07-10 12:08:09 +02:00
Michael Vetter
38edc1c325 Add destructor for roster_pending_presence
Fix:
```
==18682== 408 bytes in 17 blocks are definitely lost in loss record
3,279 of 3,632
==18682==    at 0x483677F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==18682==    by 0x42F602: roster_update_presence (roster_list.c:129)
==18682==    by 0x448AA3: sv_ev_contact_online (server_events.c:906)
==18682==    by 0x43D2BA: _available_handler (presence.c:674)
==18682==    by 0x43C81B: _presence_handler (presence.c:398)
==18682==    by 0x5AF118E: handler_fire_stanza (handler.c:124)
==18682==    by 0x5AEDBDA: _handle_stream_stanza (conn.c:1253)
==18682==    by 0x5AFA43E: _end_element (parser_expat.c:190)
==18682==    by 0x6818AA4: doContent (xmlparse.c:2977)
==18682==    by 0x681A3AB: contentProcessor (xmlparse.c:2552)
==18682==    by 0x681D7EB: XML_ParseBuffer (xmlparse.c:1988)
==18682==    by 0x681D7EB: XML_ParseBuffer (xmlparse.c:1957)
==18682==    by 0x5AF0A63: xmpp_run_once (event.c:255)
==18682==    by 0x432E5D: connection_check_events (connection.c:104)
==18682==    by 0x4323B3: session_process_events (session.c:255)
==18682==    by 0x42C097: prof_run (profanity.c:128)
==18682==    by 0x4B25B9: main (main.c:172)
```
2019-07-09 16:04:27 +02:00
Michael Vetter
89d8fc846e Fix double free in room id handler
Free is done in destructor now.
Regards https://github.com/profanity-im/profanity/issues/1148
2019-07-09 09:47:35 +02:00
Michael Vetter
7af85d0fe0 Fix double free in omemo_start_device_session_handle_bundle()
omemo_key_free() was called to free the key.
It free the key->data too. But in same cases this was not set  yet. So
we need to set the data to NULL (or use calloc) at initialization so
that omemo_key_free() only frees it if it was actually allocated.

Regards https://github.com/profanity-im/profanity/issues/1148
2019-07-08 16:36:05 +02:00
Michael Vetter
b3bb62dcbd Fix double free regarding iq handlers 2019-07-08 15:58:40 +02:00
Michael Vetter
6355272091
Merge pull request #1146 from profanity-im/fix/omemoleaks-autocompl
Fix several OMEMO related leaks
2019-07-04 18:01:59 +02:00
Michael Vetter
9aad2aa487 Free iq_id_handlers correctly
so far only the key part was freed. We also need to free the actual
handler.

Fix:
```
==21171== 1,128 bytes in 47 blocks are definitely lost in loss record
3,476 of 3,670
==21171==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21171==    by 0x434248: iq_id_handler_add (iq.c:265)
==21171==    by 0x4B122E: omemo_devicelist_request (omemo.c:46)
==21171==    by 0x4AC411: omemo_start_session (omemo.c:409)
==21171==    by 0x4AC37C: omemo_start_sessions (omemo.c:396)
==21171==    by 0x447881: sv_ev_roster_received (server_events.c:189)
==21171==    by 0x444019: roster_result_handler (roster.c:312)
==21171==    by 0x433FC2: _iq_handler (iq.c:202)
==21171==    by 0x5AF118E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x5AEDBDA: ??? (in /usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x5AFA43E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x6818AA4: ??? (in /usr/lib64/libexpat.so.1.6.8)
==21171==    by 0x681A3AB: ??? (in /usr/lib64/libexpat.so.1.6.8)
==21171==    by 0x681D7EB: XML_ParseBuffer (in
/usr/lib64/libexpat.so.1.6.8)
==21171==    by 0x5AF0A63: xmpp_run_once (in
/usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x432E5D: connection_check_events (connection.c:104)
==21171==    by 0x4323B3: session_process_events (session.c:255)
==21171==    by 0x42C097: prof_run (profanity.c:128)
==21171==    by 0x4B2627: main (main.c:172)
```
2019-07-04 14:25:53 +02:00
Paul Fariello
c0e8f72276 Fix plaintext private message handling 2019-07-04 14:02:42 +02:00
Michael Vetter
482138feff Free key on error in omemo_start_device_session_handle_bundle()
Fix:
```
==20561== 32 bytes in 1 blocks are definitely lost in loss record 1,467
of 3,678
==20561==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20561==    by 0x4B16C9: omemo_start_device_session_handle_bundle
(omemo.c:167)
==20561==    by 0x43405E: _iq_handler (iq.c:214)
==20561==    by 0x5AF118E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x5AEDBDA: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x5AFA43E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x6818AA4: ??? (in /usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x681A3AB: ??? (in /usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x681D7EB: XML_ParseBuffer (in
/usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x5AF0A63: xmpp_run_once (in
/usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x432E5D: connection_check_events (connection.c:104)
==20561==    by 0x4323B3: session_process_events (session.c:255)
==20561==    by 0x42C097: prof_run (profanity.c:128)
==20561==    by 0x4B260D: main (main.c:172)
```
2019-07-04 11:55:53 +02:00
Michael Vetter
e3443f5c9a Rework omemo_start_device_session_handle_bundle exit
In some conditions we just returned without freeing allocated variables.

Should fix following valgrind reported leak:

```
==17941== 19 bytes in 1 blocks are definitely lost in loss record 613 of
3,674
==17941==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17941==    by 0x5BB0DAA: strdup (strdup.c:42)
==17941==    by 0x4B1592: omemo_start_device_session_handle_bundle
(omemo.c:126)
==17941==    by 0x43405E: _iq_handler (iq.c:214)
==17941==    by 0x5AF118E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x5AEDBDA: ??? (in /usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x5AFA43E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x6818AA4: ??? (in /usr/lib64/libexpat.so.1.6.8)
==17941==    by 0x681A3AB: ??? (in /usr/lib64/libexpat.so.1.6.8)
==17941==    by 0x681D7EB: XML_ParseBuffer (in
/usr/lib64/libexpat.so.1.6.8)
==17941==    by 0x5AF0A63: xmpp_run_once (in
/usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x432E5D: connection_check_events (connection.c:104)
==17941==    by 0x4323B3: session_process_events (session.c:255)
==17941==    by 0x42C097: prof_run (profanity.c:128)
==17941==    by 0x4B2610: main (main.c:172)
```
2019-07-04 11:46:32 +02:00
Michael Vetter
4a6b1665f3 Use correct jid variable 2019-07-03 15:28:46 +02:00
Michael Vetter
f504a02167 Define goto out in _private_chat_handler() 2019-07-03 15:27:31 +02:00
Michael Vetter
19902e8e21 Set plain message in _private_chat_handler
In case that plain is NULL we need to copy over from body.

Fix https://github.com/profanity-im/profanity/issues/1144
2019-07-03 15:16:19 +02:00
Paul Fariello
45e8467231 Fix a segfault when carbon has no body 2019-06-21 16:49:52 +02:00
Paul Fariello
498b75afa9 Don't highlight cleartext message as untrusted 2019-06-21 15:50:41 +02:00
Paul Fariello
ac96a6951d Fix segfault when receiving messages without ID 2019-06-21 12:03:08 +02:00
Paul Fariello
a444137e66 Fix NULL pointer when handling non encrypted message in MUC 2019-06-21 11:34:36 +02:00
Paul Fariello
f831f65737 Rename prof_message_t into ProfMessage 2019-06-20 14:30:45 +02:00
Paul Fariello
44d16e9141 Add prof_message_t to wrap all message attributes
Probably missing copy of body to plain in carbon and privmessage.
Only covers the incoming message path because goal is OMEMO decryption
of untrusted message.
Cover some of the log functions but not all.
2019-06-20 14:30:42 +02:00
Paul Fariello
3bb3cc625d Use flags in xmmp/message.c for encryption and trust 2019-06-20 14:30:37 +02:00
Paul Fariello
a650ecc67d Add trusted state after OMEMO decryption
Use it to print message on red background if not trusted.
2019-06-20 14:29:55 +02:00
Michael Vetter
7ca8ec3e6b _bookmark_destroy: follow normal logic 2019-06-20 12:37:32 +02:00
Michael Vetter
b8c8059402 Call message_handlers_clear() upon disconnect
Free pubsub_event_handlers. Fix memory leaks.
2019-06-20 12:37:32 +02:00
Michael Vetter
11b8204d14 Call iq_handlers_clear() upon disconnect
Free id_handlers. Fix memory leaks.
2019-06-20 12:37:32 +02:00
Michael Vetter
b210fb3603 statusbar: check if roster exists
We destory the roster in ev_disconnect_cleanup().
Adding a function to test if the roster has been destroyed and testing
for it in the statusbar.

So now when the connection is lost 'Lost connection' is printed in all
open windows.
We can then reconnect with `/connect accountname`.

Should fix https://github.com/profanity-im/profanity/issues/1083
2019-06-04 16:19:04 +02:00
Michael Vetter
48013f8d43
Merge pull request #1106 from profanity-im/saved-account
Don't clear saved account data in session_disconnect()
2019-06-03 14:11:00 +02:00
Dmitry Podgorny
6138a5f79b Cancel autoping timer on disconnect or connection loss
If Profanity is disconnected in any way before ping response is
received, the autoping timer will expire after the next connection
is established. As result, user will be disconnected immediately.

Cancel autoping timer in ev_disconnect_cleanup(), so it is done
for all kind of disconnections.
2019-06-03 13:28:00 +03:00
Dmitry Podgorny
4344ee2a5a Don't clear saved account data in session_disconnect()
If connection loss occurs, it calls session_disconnect() eventually.
This function clears saved account data which is required for
reconnection. Therefore, when reconnect timer expires, we get errors:

02/06/2019 04:53:42: stderr: ERR: (profanity:17115): GLib-CRITICAL **:
                     04:53:42.305: g_key_file_has_group: assertion
                     'group_name != NULL' failed
02/06/2019 04:53:43: prof: ERR: Unable to reconnect, account no longer
                     exists: (null)

To solve it, don't clear the saved data in session_disconnect(). It will
be cleared properly on connection loss if reconnect timer is not
configured. But won't be cleared with /disconnect command.
So, after /disconnect the data will live in memory until the next
/connect.

Also, remove some copy-paste in connection loss path.
2019-06-03 13:21:52 +03:00
Dmitry Podgorny
c2d3c3e416 xmpp/connection: fix #1103
When connection is lost, profanity tries to disconnect what leads
to an infinite loop. The loop occurs, because connection_disconnet()
runs xmpp_run_once() separately and waits for XMPP_CONN_DISCONNECT
event. But it doesn't happen, because the connection object is
disconnected.

As solution, don't disconnect after XMPP_CONN_DISCONNECT is received.
Also, don't free libstrophe objects while the event loops executes,
because the event loop continues using objects after callbacks quit.
2019-06-01 20:21:46 +03:00
Michael Vetter
a28f0d9e74 Update tests with new URL
https://github.com/profanity-im/profanity/issues/1085
2019-05-03 10:46:41 +02:00
Michael Vetter
ebbacec667 Update profanity URL in entity capabilities stanza
Regards https://github.com/profanity-im/profanity/issues/1085
2019-05-03 10:36:26 +02:00
Michael Vetter
a794dadfa9 OMEMO: Check if ID is present before using it
Fixes https://github.com/boothj5/profanity/issues/1079
2019-04-24 15:20:54 +02:00
Paul Fariello
973a05d15a Handle presence received before roster
Presence of contact not found in roster are filtered out.
But sometimes roster is received after a first few presences.

We choose to store presences until we receive roster and then process
this presences.

Fixes #1050
2019-04-17 14:19:31 +02:00
Paul Fariello
21ae946896 Handle MUC anonymous state when auto starting OMEMO
When auto joining a MUC we don't have access to required information so
we just don't start OMEMO at this time.

Once we receive disco info we then try to start OMEMO.
2019-04-17 14:03:14 +02:00
Paul Fariello
8c71a74afe Ensure MUC is Non-Anonymous before starting OMEMO
Store MUC anonymous type in mucwin for that purpose.

Fixes #1065
2019-04-17 13:56:27 +02:00
Paul Fariello
9714d1d867 Add random string at the end of the default resource
When connecting for the first time or when creating a new account don't
use only 'profanity' as default resource.

Some server don't support having 2 connection with same resource. Using
profanity as default lead to deconnections.
2019-04-12 15:49:54 +02:00
Paul Fariello
381d85bcca Fix build on travis 2019-04-10 17:24:56 +02:00
Paul Fariello
4ad6904216 Wait for discovery end to publish omemo devicelist and bundle
Add sv_ev_connection_features_received for that purpose
2019-04-10 17:23:46 +02:00
Paul Fariello
e69f947547 Rework MUC reflected message filtering
Reflected messages can't be filtered by nick only otherwise you might
ignore messages comming from you on another devices.

Consequently we maintain a list of sent messages id in mucwin.
To be sure the id will be correctly reflected we use the origin-id
stanza.
2019-04-10 17:23:46 +02:00
Paul Fariello
65b3f82c5f Fix devicelist notification handler
devicelist handler should be kept after trigger
2019-04-10 17:23:46 +02:00
Paul Fariello
0d0e2b246a Add support for missing from in bundle iq 2019-04-10 17:23:45 +02:00
Paul Fariello
562302846a Handle bundle publication error on publish-options
We try to reconfigure node and publish again.
If it fails again then we give up.
2019-04-10 17:23:45 +02:00
Paul Fariello
2015ba201d Ensure encrypted carbon of own message are marked as encrypted 2019-04-10 17:23:45 +02:00
Paul Fariello
bc16ba1669 Temporarly disable check for publish-options support 2019-04-10 17:12:31 +02:00
Paul Fariello
2fd2ca208c Use connection_support to check for publish-options support 2019-04-10 17:12:31 +02:00
Paul Fariello
91ee289c77 Add support for disconnect in OMEMO 2019-04-10 17:12:31 +02:00
Paul Fariello
70109953ec Revert "Ensure room isn't anonymous"
This reverts commit 733e1a24c7e08dde6aa2c15ec4528220aa360845.
2019-04-10 17:12:31 +02:00
Paul Fariello
d8f0bcef94 Add publish option to OMEMO device list and bundle 2019-04-10 17:12:31 +02:00
Paul Fariello
9044e3732c Ensure room isn't anonymous 2019-04-10 17:12:31 +02:00
Paul Fariello
4e1ffa6bdb Log and print outgoing encrypted message 2019-04-10 17:12:31 +02:00
Paul Fariello
a9d55dec92 Add support for sending encrypted message in MUC 2019-04-10 17:12:31 +02:00
Paul Fariello
f7ce1607f9 Ensure saved_account is set before calling sv_ev_login_account_success 2019-04-10 17:12:31 +02:00
Paul Fariello
a3897abba1 Add MUC message decryption 2019-04-10 17:12:31 +02:00
Paul Fariello
0dd5441f92 device_list iq should be from barejid or none
Ensure we request device_list and remove non conforming handling of
responses.

Move initialisation of iq_handlers before call to sv_ev_login_account_success
2019-04-10 17:12:31 +02:00
Paul Fariello
36ce21fc6d Add store hints for OMEMO encrypted messages
Store hints are required has some server might discard messages without
body. Here we ensure OMEMO messages are stored on server and delivered
to client when they connect back.

It's really important since it avoid libsignal to desynchronize
counters.
2019-04-10 17:12:31 +02:00
Paul Fariello
97c661271b Add support for libsignal-protocol-c 2.3.2 2019-04-10 17:12:31 +02:00
Paul Fariello
bf8b89c568 Randomly choose a prekey on session build 2019-04-10 16:31:45 +02:00
Paul Fariello
695694051e Remove hints preventing carbons to work properly 2019-04-10 16:31:45 +02:00
Paul Fariello
bcd582be42 Don't explicitely disable carbons for OMEMO messages 2019-04-10 16:31:45 +02:00
Paul Fariello
9b8c1d7d2c Add support for encrypted carbon
Fix {signed,}_pre_key store
2019-04-10 16:31:45 +02:00
Paul Fariello
810ea32223 Follow normal workflow for OMEMO message reception
We try to decrypt all messages, if it's successful we use
sv_ev_incoming_message even for OMEMO messages. We pass an OMEMO
boolean to let UI be aware that message were encrypted.
2019-04-10 16:03:50 +02:00
Paul Fariello
d871efdcf9 Add chat session state to OMEMO message stanza 2019-04-10 16:03:50 +02:00
Paul Fariello
904904d74e Add default body on OMEMO message 2019-04-10 16:03:50 +02:00
Paul Fariello
0fb27dc496 Add OMEMO message encryption and decryption 2019-04-10 16:03:50 +02:00
Paul Fariello
b1ae220aa4 Create signal session 2019-04-10 16:03:50 +02:00
Paul Fariello
f9216fddb1 Add signal store backend and OMEMO start command 2019-04-10 16:03:50 +02:00
Paul Fariello
1f9d46037c Request for device list when OMEMO is ready 2019-04-10 16:03:50 +02:00
Paul Fariello
756fefb09a Fix devicelist subscription and handle pubsub event
Devicelist subscription can be done directly with caps_add feature.
2019-04-10 16:03:50 +02:00
Paul Fariello
1ae5d9f1f8 Add pubsub event callback
Also add generic message callback struct
2019-04-10 16:03:50 +02:00
Paul Fariello
2d28725c85 Rename ProfIdCallback into ProfIqCallback
Goal is to create other kind of callback no based on id cmp
2019-04-10 16:03:50 +02:00
Paul Fariello
fdc5f25f2d Add devicelist and bundle publication 2019-04-10 16:03:50 +02:00
Paul Fariello
bce1981128 Add devicelist subscription 2019-04-10 15:37:22 +02:00
Michael Vetter
4792984f1e XEP-0027: Mention XEP in message body
With all the different kinds of encryption (OMEMO, OTR3 OTR4, PGP in XEP-0027 and XEP-0373) it might be helpful to know which kind of encryption is used.
2019-02-20 10:48:28 +01:00
Michael Vetter
706af9a900 Update copyright to include 2019 2019-01-22 11:31:45 +01:00
Paul Fariello
ac2d1c07fa Fix optionnal sessionid in xep 0050 2019-01-21 15:02:54 +01:00
Dmitry Podgorny
7f65aaa9a2 Add option to trust server's certificate
New tls policy "trust" added to /connect and /account. With the policy
TLS connection is established even with invalid certificate. Note, that
trust policy forces TLS connection and it fails when server doesn't
support TLS.

Examples:
 /connect <jid> tls trust
 /account <name> set tls trust
2018-11-06 14:09:02 +02:00
Michael Vetter
47f90d7a39
Merge pull request #991 from paulfariello/feature/xep-0050
Add support for xep 0050 ad-hoc commands, without multi-step
2018-09-27 17:27:37 +02:00
Paul Fariello
2e0bc27bf0 Make _get_groups_from_item and roster _compare_* public
In order to avoid duplication with xep 0133 support in command execution
2018-09-26 14:34:52 +02:00
Paul Fariello
01428eb858 Add special handling for xep-0133 get-user-roster 2018-09-10 13:09:23 +02:00
Paul Fariello
6de60e7efc Add support for ad-hoc response with forms 2018-09-10 12:28:28 +02:00
Paul Fariello
b7556b4e41 Add missing command name for completion log 2018-09-10 11:30:46 +02:00
Michael Vetter
82f8083b85 Move p_sha1_hash() to stanza.c
Move `p_sha1_hash()` from `common.c` to	`xmpp/stanza.c` as it is only
used in this file and now depends on libstrophe so xmpp is a better
namespace folder.
Renaming it as `_stanza_create_sha1_hash()`. And making static since
only used here.

The function cannot be tested in the unit tests anymore.
Once functional tests are working again we should write a test for the
sha1 functionality.
2018-09-06 20:40:09 +02:00
Paul Fariello
ec5fc3612f Allow to use cmd without being in a window 2018-09-05 13:52:20 +02:00
Paul Fariello
233e076be9 Add support for command config execution 2018-09-05 13:52:19 +02:00
Paul Fariello
b11d3a79df Add conf win callback 2018-09-05 13:51:00 +02:00
Paul Fariello
a952776b89 Rename mucconf wins into conf wins
Configuration windows are now being used by both muc and cmd.
2018-09-05 13:51:00 +02:00
Paul Fariello
7123e94e82 Add support for form edition in command execution
Also change wins_get_by_string prototype in order to handle const str.
2018-09-05 13:51:00 +02:00
Paul Fariello
40eee1caab Add command exec error handling 2018-09-05 13:51:00 +02:00
Paul Fariello
925cd488c1 Handle simple execution
Tested with ping from biboumi
2018-09-05 13:50:59 +02:00
Paul Fariello
c9f6a78f57 Add command subcommands: list and exec
Also handle list result
2018-09-05 13:49:40 +02:00
Paul Fariello
ca022ec75e Add command command
Initial commit to test commands API
2018-09-05 13:42:28 +02:00
Michael Vetter
6d80700329 Move ID generation to xmpp folder
create_unique_id() was changed to use UUIDs instead of a counter in the
last commit. Since now it depends on connection_create_uuid() which is
in the xmpp subfolder the function should also be moved there.

Renamed it to connection_create_stanza_id() and moved it to
src/xmpp/connection.c.

Discussion happened in https://github.com/boothj5/profanity/pull/1010
2018-08-30 11:17:04 +02:00
Dominik Heidler
86a9ef7b5c Use correct macro
XMPP_FEATURE_PING insted of STANZA_NS_PING
2018-07-30 11:04:54 +02:00