evilsocket / opensnitch

OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch.
GNU General Public License v3.0
9.92k stars 490 forks source link

Firewall's UI crashes because of notifications #785

Closed Danny3 closed 1 year ago

Danny3 commented 1 year ago

Hello!

Describe the bug Firewall's UI crashes because of notifications

Include the following information:

Steps to reproduce the behavior:

  1. Go to firewall's UI
  2. Click on the Settings icon, the one that looks like Plasma's "System Settings"
  3. When the settings window opens click on the "UI" tab
  4. Then click fast a few times on the "Test" button and see how the UI disappears.

Expected behavior (optional) I expected that it would not crash no matter how fast I would press the "Test" button. It seems that even if you don't press it that fast it can still crash.

I know this is stupid and probably not many people would play with this button the way I did, but finding this option to manually trigger notifications in KDE made me wonder how many I could create before they disappear and how fast they can be displayed.

If KDE had a way to do this and get over this curiosity, I wouldn't have tried it here too, but I did and I didn't expect that the UI would crash.

Maybe the UI could crash if the firewall has to emit many notifications other than this case.

Additional context BTW, the "Use Qt notifications" being the chosen option and clicking the "Test" button, no matter how fast, doesn't make it crash. But also it doesn't show any notifications. I never saw this option to work. Even though being on KDE Plasma I expected it to work.

And another thing, when a notification from OpenSnitch is coming about some program, like the following for not choosing any option when VLC tries to connect the internet: /usr/bin/vlc deny action applied Command line: /usr/bin/vlc --started-from-file

Could you display that program's icon on the right side of the notification instead of OpenSnitch's icon, which is already displayed in the notification's title bar?

I mean it's clear that OpenSnitch has the icon for the program, VLC in this case as I saw it being correctly obtained in the pop-up windows and it's clear from who the notification is coming from as the notification's title bar has both the icon and the name of which program sent it. BTW the name of the program who sent it in this case is "opensnitch". Maybe you can change it to "OpenSnitch" if it's not a KDE limitation.

If you can send the icon of the program, the rule is about, to the notification content along with the other text, it would be great!

Thank you!

gustavo-iniguez-goya commented 1 year ago

hey @Danny3 ,

Could launch the GUI from the terminal and make it crash? It seems that I'm not fast enough to make it crash (at least on Cinnamon).

Danny3 commented 1 year ago

Hi @gustavo-iniguez-goya ,

I did it like this:

  1. Right-clicked on its icon in systray
  2. Then chose Close. I assumed that this will close just the UI and not also the back-end.
  3. From the terminal I ran the "opensnitch-ui" command. I assumed that this is the command to start the UI based on the install files names.

I think I was right as I got this output, including the things that happened after I made it crash.

BTW, just before it crashed and the its both windows disappear the settings window sometimes becomes a bit washed out or white, which I think it's a normal behavior on KDE when a program becomes unresponsive.

Here's the output: ` Themes not available. Install qt-material if you want to change GUI's appearance: pip3 install qt-material. Loading translations: /usr/lib/python3/dist-packages/opensnitch/i18n locale: en_US Using server address: unix:///tmp/osui.sock is new file, or IN MEMORY, setting initial schema version setting schema version to: 2 setting schema version to: 2 schema version: 2 db schema is up to date using IPASN DB: /usr/lib/python3/dist-packages/data/ipasn_20140513_v12.dat.gz new node connected, listening for client responses... /tmp/osui.sock [notifications] show() exception: org.freedesktop.Notifications.Error.ExcessNotificationGeneration: Created too many similar notifications in quick succession Traceback (most recent call last): File "/usr/lib/python3/dist-packages/opensnitch/notifications.py", line 104, in show ntf.show() File "/usr/lib/python3/dist-packages/notify2.py", line 181, in show nid = dbus_iface.Notify(appname, # app_name (spec names) File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 141, in call return self._connection.call_blocking(self._named_service, File "/usr/lib/python3/dist-packages/dbus/connection.py", line 634, in call_blocking reply_message = self.send_message_with_reply_and_block( dbus.exceptions.DBusException: org.freedesktop.Notifications.Error.ExcessNotificationGeneration: Created too many similar notifications in quick succession

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/opensnitch/dialogs/preferences.py", line 587, in _cb_test_notifs_clicked self._desktop_notifications.show("title", "body") File "/usr/lib/python3/dist-packages/opensnitch/notifications.py", line 107, in show raise Exception("[notifications] show() exception:", e) Exception: ('[notifications] show() exception:', DBusException('Created too many similar notifications in quick succession')) Aborted (core dumped)

`

Sorry for these types of quotes: `, they are from Github, not part of the output, I don't know how to paste the out here without any weird formatting so I tried the "Add code" button from the toolbar and pasted the output inside those quotes added by that button.

Hope that's helpful!

Funny that it even says that there are too many notifications, but it also says that they are similar. Maybe you can add some counter to them like Test notification 1,2,3 and so on, if them being similar trigggers some protection in KDE.

Thanks!

gustavo-iniguez-goya commented 1 year ago

Thank you @Danny3 ! This error should be fixed now. It was caused by a non controlled exception:

File "/usr/lib/python3/dist-packages/opensnitch/notifications.py", line 107, in show
raise Exception("[notifications] show() exception:", e)
Danny3 commented 1 year ago

Thank you very much @gustavo-iniguez-goya!

I'll wait for the next release.

BTW, do you have any idea why the Qt notifications doesn't work, even though I'm testing it on KDE?

Could it be that it's missing some package that I can install?

gustavo-iniguez-goya commented 1 year ago

mm, no idea. Do you mean testing it from the Preferences dialog, or that you select [x] Use Qt notifications and it doesn't show notifications?

The field type should be 1 for Qt notifications in ~/.config/settings.conf:

[notifications]
enabled=true
type=1
Danny3 commented 1 year ago

mm, no idea. Do you mean testing it from the Preferences dialog, or that you select [x] Use Qt notifications and it doesn't show notifications?

Yes.

As for that file, now with the latest version (1.6.0rc-4) it doesn't exits in ~/.config. I have created it and tried

As for the normal "Use system notifications" I tested it again and it doesn't crash anymore, so great work!

Though I find it a bit strange that if you try to press it more times, a bit faster like I did before now it becomes disable and it's not re-enable if you switch the radio button to "Use Qt notifications" so you cannot test those too after it has been disabled.

And even if you then click Apply or Save, which closes the settings window and then you open the settings window, the button is still disabled.

Closing the UI, then reopening and reopening the setting window also doesn't help, the button is still disabled so you cannot test anymore no matter what you do.

The only way to re-enable it, is to close it from the systray contextual menu and then reopen the UI from the start menu.

I think it might be a bit too much.

Maybe after too many clicks on the button and disabling it, a cooldown of a few seconds would be better and then re-enable it.

gustavo-iniguez-goya commented 1 year ago

That was a problem that shoud be fixed now. Thank you!