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

51 Commits

Author SHA1 Message Date
Steffen Jaeckel
9cf78e59d5 auto-format
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2022-02-01 15:01:28 +01:00
Michael Vetter
d4c9a98d71 omemo: log when no pubsub
Closes https://github.com/profanity-im/profanity/issues/1621
2021-12-13 17:11:30 +01:00
Michael Vetter
f21595597f Format code correctly 2021-10-05 10:01:27 +02:00
Paul Fariello
314d0034ed Fix memleak 2021-08-20 15:33:31 +02:00
Paul Fariello
35814d8bd0 Log error received while publishing OMEMO device list 2021-08-20 15:32:00 +02:00
Paul Fariello
4d93df4aba OMEMO: Fix precondition-not-met handling 2021-08-19 10:02:07 +02:00
Paul Fariello
d8cee98cc7 Create devicelist if it doesn't exists 2021-08-19 10:02:07 +02:00
Paul Fariello
0b6cf20183 OMEMO: try device list creation and reconfigure on precondition-not-met 2021-08-19 10:02:07 +02:00
Paul Fariello
46fe69de9b Ensure devicelist access model is configured before updating it 2021-08-19 10:02:06 +02:00
DebXWoody
41913a0aea OMEMO - Unable to publish own device list
If we are not able to publish our own device list, we just ignored it.
This commit will show at least an error message and informs the user that this
device is currently not in the list of devices.

See Issue: #1538

Next task will be to handle the <precondition-not-met/> conflict properly.
2021-06-01 09:44:48 +02:00
DebXWoody
de06cd395b
Improved OMEMO logging
The most loggings has been set to debug. Just in case of error / problem the
logging should be done with log-level ERROR or WARNING.

We will see later, which loggings should be switched to log-level INFO.

This improvement has been done to find OMEMO bugs.

See also: #1070 #1530 #1538
2021-05-28 17:45:15 +02:00
Michael Vetter
057c9ad776 Add config.h in files were it was missing
Related to https://github.com/profanity-im/profanity/issues/1512
2021-03-26 19:54:22 +01:00
Maximilian Wuttke
2b1ada7722 [OMEMO]: Fix bundle publishing
Use the following options in `omemo_bundle_publish()`:

- "pubsub#persist_items" = "true"
- "pubsub#access_model" = "open"

The same options are also used in Gajim.

I've tested this on two different servers. The bundle was successfully
added as a new PEP node. Test cases:

1. Normal use on my main account
2. Log in into a fresh tesst account on a different server
3. `/omemo clear_device_list`. In this case, the client(s) may have to
   be restarted.

Note: In `_omemo_bundle_publish_result`, there's a route that is taken
when the bundle publish stanza failed. In this case, the node is
configured manually, i.e. the access_model is set to 'open'. I have
manually tested this case, but this case didn't naturally occur for me.

Note: The option "pubsub#max_items=max" is REQUIRED for the bundle
publication, as per XEP-0384. However, this is not done in other clients
(I've checked the source code of Gajim and Conversations), and it is
also not supported by Prosody. Cf. <https://github.com/xsf/xeps/pull/988>.
2021-03-09 17:48:29 +01:00
Maximilian Wuttke
68469149cd Logging [OMEMO]
Also "handle" some errors in `_omemo_bundle_publish_configure` if the
stanzas can't be found
2021-03-09 17:47:43 +01:00
Maximilian Wuttke
8481698705 Logging [OMEMO] 2021-03-09 17:47:27 +01:00
Michael Vetter
a2726b6a7d Apply coding style 2020-07-07 14:18:57 +02:00
Michael Vetter
a4cadf78fa Revert "Apply coding style"
This reverts commit 9b55f2dec0.

Sorting the includes creates some problems.
2020-07-07 13:53:30 +02:00
Michael Vetter
9b55f2dec0 Apply coding style
Regards https://github.com/profanity-im/profanity/issues/1396
2020-07-07 09:43:28 +02:00
DebXWoody
54667c022f Messages are not shown in ChatSecure
In 0.9.x we fixed an issue, because OMEMO devices should be defined in "item"
with id "current". This should work, but it won't work if there is no "current".
If there is no "current" we will just use the first item.

Issue #1384
2020-07-04 17:38:30 +02:00
Michael Vetter
24e8243a98 _omemo_receive_devicelist() use if/else 2020-05-29 10:28:41 +02:00
DebXWoody
b882fd495a
OMEMO - Request only "current" item
NOTE: as per XEP-0060 §12.20, it is RECOMMENDED for the publisher to specify an
ItemID of "current" to ensure that the publication of a new item will overwrite
the existing item.
https://xmpp.org/extensions/xep-0384.html#devices

Issue: 1329
2020-05-23 07:41:06 +02:00
Paul Fariello
c66cd17bbb Fix maybe uninitialized and don't guard g_free 2020-01-20 14:34:09 +01:00
Paul Fariello
0dfed1f4c7 Ignore invalid base64 in OMEMO stanzas
Fixes #1239
2020-01-20 14:34:09 +01:00
Sven Speckmaier
5ccd04c91b omemo: Check for 1 alongside true in an omemo encrypted message stanza
prekey is defined as `<xs:attribute name="prekey" type="xs:boolean"/>`
which allows both `true` and `1` as truthy values.
Not checking for `1` breaks omemo encryption when interacting with
clients which set prekey="1", example: psi+ 1.4.983
Regards https://github.com/profanity-im/profanity/issues/1247
2020-01-03 10:39:40 +01:00
Michael Vetter
46fd7150e5 Add vim modeline 2019-11-13 12:11:05 +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
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
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
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
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
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
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
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
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
d8f0bcef94 Add publish option to OMEMO device list and bundle 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
bf8b89c568 Randomly choose a prekey on session build 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
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
fdc5f25f2d Add devicelist and bundle publication 2019-04-10 16:03:50 +02:00