1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00
Commit Graph

3960 Commits

Author SHA1 Message Date
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
0410802753 Free omemo_ctx.device_list_handler 2019-07-04 10:47:50 +02:00
Michael Vetter
d0047c8376 Dont initialize omemo autocompleter twice
We already do this in omemo_init() no need to do it again in
omemo_on_connect().
2019-07-04 10:38:24 +02:00
Michael Vetter
199162b11a Add omemo_close function
We call omemo_init() when starting profanity and should have an
omemo_close() at exit.

For now we free the fingerprint autocompleter in there.

Fixes valgrind:
```
==13226== 24 bytes in 1 blocks are definitely lost in loss record 2,855
of 6,958
==13226==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==13226==    by 0x48AD39: autocomplete_new (autocomplete.c:57)
==13226==    by 0x4AB89F: omemo_init (omemo.c:127)
==13226==    by 0x42C283: _init (profanity.c:206)
==13226==    by 0x42BFF3: prof_run (profanity.c:98)
==13226==    by 0x4B25E6: main (main.c:172)
```

Regards https://github.com/profanity-im/profanity/issues/1131
2019-07-04 10:30:56 +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
Michael Vetter
ad9263520e Show MUC history on intentional reconnect
Small bug caused by 13675fb and ce5a4ed.
Fix https://github.com/profanity-im/profanity/issues/1142
2019-07-03 09:19:24 +02:00
Paul Fariello
f081766913 Mark messages received from a session as trusted 2019-06-25 18:43:15 +02:00
Paul Fariello
45e8467231 Fix a segfault when carbon has no body 2019-06-21 16:49:52 +02:00
Paul Fariello
db8f32c049 Fix handling of encrypted carbons 2019-06-21 15:52:24 +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
9482ce6168 Set foreground color for untrusted messages 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
Paul Fariello
2604786cb6 Decrypt all incoming OMEMO msg
Trust all key as long as it's for reading. This code isn't multithread
safe.
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
29e2d16e14 Free contacts in omemo_start_sessions() 2019-06-19 23:18:45 +02:00
Michael Vetter
0d698d4898 Free OMEMO session store upon disconnect 2019-06-19 23:15:24 +02:00
Michael Vetter
184f01c4ac Fix prefs_get_string mem leaks in statusbar 2019-06-19 16:45:18 +02:00
Michael Vetter
20e94beca2 Free last_msg_timestamp
Fix memory leak.
2019-06-19 12:30:57 +02:00
Michael Vetter
ae1e60a9f9 Add option to set all window related time formats
Implements feature requested at: https://github.com/profanity-im/profanity/issues/632

So instead of:

/time console set <format>
/time chat set <format>
/time muc set <format>
/time mucconfig set <format>
/time private set <format>
/time xml set <format>

As a short cut the user can do:

/time all set <format>

Excluding statusbar and lastactivity settings since they are not for main windows, but used slightly differently.
2019-06-17 14:23:33 +02:00
Michael Vetter
e4b007c9da Add copyright to omemo code 2019-06-17 10:47:56 +02:00
Michael Vetter
40b72ffe55 Add myself to copyright
Like discussed with James.
2019-06-17 10:44:08 +02:00
Michael Vetter
d66ffde91f Use profanity channel as example 2019-06-17 10:28:04 +02:00
Michael Vetter
5dd6ba73f4
Merge pull request #1110 from profanity-im/feature/704-ui-behaviour-reconnect
Feature/704 ui behaviour reconnect
2019-06-11 07:00:34 +02:00
Michael Vetter
47e55cc112 Safe last MUC message timestamp per MUC
After pasis review of my code he thinks it's better to safe the
timestamp per MUC so we can account for some problems that could occur
with timing.
2019-06-11 06:35:03 +02:00
Michael Vetter
ff6038fe32 Rejoin all MUCs on reconnect
Should fix https://github.com/profanity-im/profanity/issues/1120
2019-06-10 23:18:43 +02:00
Michael Vetter
c4fcc0c3cb
Merge pull request #1125 from profanity-im/fix/519-logrotate
Iterate logfiles until 100 are reached
2019-06-10 14:20:29 +02:00
Michael Vetter
60d8d7e93a
Merge pull request #1124 from paulfariello/feature/remove_session_when_untrusting_omemo_device
Remove OMEMO session when untrusting a fingerprint
2019-06-08 00:25:43 +02:00
Michael Vetter
bb4dd47a01 Iterate logfiles until 100 are reached
Fix https://github.com/profanity-im/profanity/issues/519
2019-06-07 23:48:44 +02:00
Paul Fariello
5731a7c472 Remove OMEMO session when untrusting a fingerprint
We have to store known_devices in a long term fashion otherwise we might
not be able to delete session if it is remove from device list server
side.
2019-06-07 23:43:40 +02:00
Michael Vetter
1f3d61e9f7
Merge pull request #1123 from profanity-im/fix/1093-already-started-message
Print omemo start related msgs into correct window
2019-06-07 22:16:33 +02:00
Michael Vetter
9516324248 Refactor cmd_omemo_start
Some code was duplicated/similar.
The parts about using a chatwin while being started from another window
(recipient provided) and being a chatwin were the same.

Like this it should be easier to read and less code.
2019-06-07 21:14:53 +02:00
Michael Vetter
2eb2bf3508 Print omemo start related msgs into correct window
Print them in the window of the contact. Not just the current window.
Fix https://github.com/profanity-im/profanity/issues/1093
2019-06-07 21:14:44 +02:00
Michael Vetter
1772236178
Merge pull request #1118 from profanity-im/fix/1117-omemo-autocompletion-crash
Only complete certain omemo commands if connected
2019-06-07 19:49:08 +02:00
Michael Vetter
bee7846ea0
Merge pull request #1121 from profanity-im/feature/notify-plugin-fail
Improve plugin load/install failure message
2019-06-07 12:17:56 +02:00
Michael Vetter
cc697de051 Improve plugin load/install failure message
In case Python or C plugins are disabled install/load failed silently.
Notify the user that we can't load them because profanity was built
without support for plugins.
2019-06-07 11:30:46 +02:00
Michael Vetter
1e723970de Only complete certain omemo commands if connected
Some of the omemo commands depend on the roster being present.
Several of those functions call `assert()` if that's not the case.

Modify omemo autocompletion in such a way that only things that don't
need the roster will be completed. Only works on first level.

When typing `/omemo` it will still complete to `/omemo start` but not
offer suggestions for that, but print a message that you need to be
connected.

Fix https://github.com/profanity-im/profanity/issues/1117
2019-06-06 16:01:19 +02:00
Michael Vetter
4e972f8aef Check for sane argument in autoconnect set
Check that user doesnt do `/autoconnect set   `.
Which would result in: `Account '(null)' does not exist`.
2019-06-05 14:41:09 +02:00
Michael Vetter
53ef209272 Check if valid account before setting autoconnect
Fixes https://github.com/profanity-im/profanity/issues/1112
2019-06-05 14:19:41 +02:00
Michael Vetter
c57d0b8c8e Add omemo.char theme option
Thanks to @kaffekanne for noticing this!
2019-06-05 11:01:08 +02:00
Michael Vetter
ce5a4ed77c Only show MUC subject on first connect
For #704 we don't show the room history upon reconnect.
Now we also don't show the room subject in the channel
upon re-established connection.
2019-06-05 10:05:12 +02:00
Michael Vetter
d53c477e4e Reduce timestamp call when saving last muc message
Let's test for mucwin earlier.
2019-06-05 09:56:00 +02:00
Michael Vetter
13675fbf06 Only print room history for new messages upon reconnect
If re-establish a connection don't print the room history again.
In case there there happened nothing at all since we got the room
history on the last connection.
And in case there were no new messages during the time we have been
disconnected.

Instead of printing the room history again we now print 'Re-established
Connection'.

This adds a bit of overhead since we save the timestamp upon every MUC
message.

See: https://github.com/profanity-im/profanity/issues/704
2019-06-05 09:49:50 +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
2d00444702 statusbar: reduce duplicate code
status_bar_new() and status_bar_active() are almost identical.
Let's use one helper function to not duplicate code.

I thought about renaming both functions into one and adding another
parameter but didn't come up with a good name for the function that
clearly describes what it does. So staying with current names + helper
functions.
2019-06-04 14:50:25 +02:00
Michael Vetter
ea62c3f293 Determine chat window names beforehand
Save the name for displaying the windows in the statusbar inside the tab
object.
So far we calculated them repeatedly and this created issues when we
lost the connection.

Regards https://github.com/profanity-im/profanity/issues/1083
2019-06-04 12:33:57 +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
bfa4a2ef1f Close windows on connection loss not general disc.
Call `ui_close_all_wins();` only if we disconnect on purpose not when
connection is lost.

Otherwise users might miss messages.

This partly reverts 6ac73db876.
Regards https://github.com/profanity-im/profanity/issues/1083
2019-05-27 12:52:04 +02:00
Michael Vetter
eb16c674ae
Merge pull request #1092 from frnky/remove_mblen
Don't call mblen() to not depend on locale
2019-05-23 21:18:46 +02:00
Paul Fariello
04cd1b4409 Correctly handle malformed OMEMO messages
Fix #1101
2019-05-23 13:12:02 +02:00
Frank Zschockelt
56e925ed03 Don't call mblen() to not depend on locale
mblen will fail with return code -1 if the locale used by the unit tests
isn't available on the machine. This will lead to an off by one error in some
tests where the needle is at the end of the haystack.

Since prof_occurrences expect null-terminated strings, the character after
the needle can simply be found by incrementing the address of the found needle
with strlen(needle).
2019-05-22 19:57:52 +02:00
Michael Vetter
91d17edcb4
Merge pull request #1098 from optmzr/fix-omemo-gen-message
Force UI update before generating OMEMO crypto materials

The message wouldn't show up before the generation of OMEMO crypto materials started.
2019-05-22 09:52:29 +02:00
William Wennerström
e07a06d1a2
Force UI update before generating OMEMO crypto materials 2019-05-21 22:32:06 +02:00
Michael Vetter
883dbe1911 Create seperate function for disconnect cleanup
Duplicate code in client_events.c and server_events.c. Let's have
events/common.c and a function containing that code.
2019-05-19 22:57:51 +02:00
Michael Vetter
c94f3d0b4a Fix ifdef guard (should have been OMEMO) 2019-05-06 16:11:22 +02:00
Michael Vetter
9ecc14c95d
Merge pull request #1090 from jubalh/fix/connection-loss-1089
Reset things on connection loss
2019-05-06 16:06:41 +02:00
Michael Vetter
6ac73db876 Reset things on connection loss
Remove the windows, clear tls certs, clean omemo.
Regards https://github.com/profanity-im/profanity/issues/1089
2019-05-06 12:30:33 +02:00
Michael Vetter
4a165b81e6
Merge pull request #1084 from jubalh/occupants-char
Add occupants char
2019-05-03 11:11:40 +02: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
9288621320 Update profanity URL in /tiny example
Regards https://github.com/profanity-im/profanity/issues/1085
2019-05-03 10:33:52 +02:00
Michael Vetter
1446ac15cb Check for new profanity version using new URL
Regards https://github.com/profanity-im/profanity/issues/1085
2019-05-03 10:33:46 +02:00
Michael Vetter
f082563bf2 Add occupants char
`/occupants char` now sets a character that is displayed before the nick
in MUCs. Similar like `/roster char` is displaying a char for the roster.

Regards #690
2019-05-02 17:01:55 +02:00
Michael Vetter
722cb5fdc3 OMEMO: Initialize result in omemo_automatic_start
This is actually not needed because result will always be set.

hartmann had problems building profanity on OpenBSD and he proposed this
patch.

Let's use it to make the compiler happy there.
2019-04-29 11:32:22 +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
Michael Vetter
1d2c0ddc69 Fix statusbar number in theme
There is a typo here. So this actually never worked ;-)
2019-04-24 14:48:24 +02:00
Michael Vetter
a666f0deae Fix formatting for privileges on
`/privileges on` lists `Moderator`, `Visitor` etc. Formatting was wrong
here. Printing privilige followed by nickaname in the same line.
2019-04-24 10:28:27 +02:00
Michael Vetter
30f9de61d0 Occupantswin: handle newline correctly 2019-04-24 09:49:14 +02:00
Michael Vetter
98f768bdc2 Add occupants wrap to help 2019-04-24 09:49:14 +02:00
Michael Vetter
259c5801cf Fix occupants header char message 2019-04-24 09:49:14 +02:00
Michael Vetter
125ca2f0d2 Add occupants wrap option
Wrapping for the occupants panel like already exists for the roster
panel. See `/occupants wrap on`.

Regards https://github.com/boothj5/profanity/issues/690
2019-04-24 09:49:14 +02:00
kaffeekanne
f8640019f3 Update copyright years 2019-04-24 01:08:38 +02:00
Michael Vetter
028839e35a Put occupants update into own function 2019-04-23 14:13:08 +02:00
Michael Vetter
566022786d Add occupants header char
`/occupants header char` now sets a character that is displayed before
the role (moderator, visitor..) in a room. Similar to `/roster header
char` is displaying a char for the roster.

Regards https://github.com/boothj5/profanity/issues/690
2019-04-23 14:13:03 +02:00
kaffeekanne
49e2838a98 Fix indentation for time config 2019-04-23 12:39:05 +02:00
Michael Vetter
d520667935 Adjust jid for occupants indent
Indent the jid one more space than nick.
2019-04-20 20:35:45 +02:00
Michael Vetter
2b0e75ce35 Add occupants indent autocompletion 2019-04-20 20:35:45 +02:00
Michael Vetter
62c23233f7 Allow setting occupants indent outside of MUC
And when not connected.
2019-04-20 20:35:37 +02:00
Michael Vetter
0c248a0b16 Add /occupants indent command
Roster has a `/roster contact indent` option.
Now we have the same for occupants. So contacts in roster and in MUC can
have configurable indentation.

Regards https://github.com/boothj5/profanity/issues/690
2019-04-18 20:53:02 +02:00
Michael Vetter
7e4e9e6688 Fix typo in /help roster 2019-04-18 17:05:10 +02:00
Michael Vetter
199e8752ca
Merge pull request #1063 from paulfariello/hotfix/presence-before-roster
Handle presence received before roster
2019-04-17 20:47:54 +02:00
Michael Vetter
2f6387f3fa Set correct year in copyright display
Fixes https://github.com/boothj5/profanity/issues/1069
2019-04-17 20:44:39 +02:00
Paul Fariello
db55e01dce Follow OMEMO policy even when opening window on message and carbon reception
This should close #1052
2019-04-17 15:54:15 +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
a6eb0d2c43 Handle missing real jid in OMEMO encrypted MUC
This should never happens since we should ensure MUC is Non-Anonymous
before enabling OMEMO.

But we should neither segfault if this happens.
2019-04-17 14:03:14 +02:00
Paul Fariello
5f015e32b2 Add OMEMO policy
There is 3 policy:

- manual: OMEMO session are only started manually
- automatic: OMEMO session are only started if they have been started
  manually before
- always: OMEMO session are always started unless they have been ended
  manually before

Closes #1040 and fixes #1052
2019-04-17 14:03:14 +02:00
Michael Vetter
9574127177
Merge pull request #1066 from paulfariello/hotfix/OMEMO-ensure-muc-is-nonanonymous
Ensure MUC is Non-Anonymous before starting OMEMO
2019-04-17 13:58:45 +02:00