evilsocket / opensnitch

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

File named `file::memory:?cache=shared` is created in the home directory on GUI launch #857

Closed staticssleever668 closed 1 year ago

staticssleever668 commented 1 year ago

Describe the bug

A file named file::memory:?cache=shared is created in the home directory when the GUI is launched.

To Reproduce 1) Make sure OpenSnitch GUI is not running 1) Check existence of ~/file::memory:?cache=shared, if it exists - delete it 1) Launch the GUI back 1) See that the file has been created

Post error logs: -

Expected behavior (optional) If I understand correctly, this is supposed to create the file in-memory or in a temporary directory (#844).

Screenshots -

Additional context Looks like a regression introduced in 5b5e2714aef9eb6752d15f41c23a69b013764f1e.

gustavo-iniguez-goya commented 1 year ago

I don't have that file on my home, and the URI is specified here: https://www.sqlite.org/inmemorydb.html

Can you post the items of the entry [database] of your ~/.config/opensnitch/settings.conf ?

gustavo-iniguez-goya commented 1 year ago

I do have that file on Manjaro though.. hmm, I'll investigate it.

gustavo-iniguez-goya commented 1 year ago

removing file: from the URI doesn't create the file on disk. I'll validate if it keeps the behaviour that I tried to solve.

staticssleever668 commented 1 year ago

Can you post the items of the entry [database] of your ~/.config/opensnitch/settings.conf ?

[database]
file=:memory:
max_days=1
purge_interval=5
purge_oldest=false
type=0

Seems like the value of the file key was from an older version, so I tried removing the whole section, but the file still appears in the home directory. This is how the section started looking after a restart of opensnitch-ui:

[database]
file="file::memory:?cache=shared"
type=0
gustavo-iniguez-goya commented 1 year ago

According to the documentation, using a in-memory db with a shared cache, always writes a file to disk:

in order for the special ":memory:" name to apply and to create a pure in-memory database, there must be no additional text in the filename and In-memory databases are allowed to use [shared cache](https://www.sqlite.org/sharedcache.html) if they are opened using a [URI filename](https://www.sqlite.org/uri.html).

The only db name that it doesn't write a file to disk is :memory. I haven't found a way of placing this temporary file in another location.

So I'll think another way of doing this.

gustavo-iniguez-goya commented 1 year ago

Note: this behaviour does not occur on ubuntu 20.04 (libsqlite 3.31.1-4, libqt5sql5 5.12.18, libqt5sql5-sqlite 5.12.18)

gustavo-iniguez-goya commented 1 year ago

I've reverted this change, because it was behaving as if you were using a DB from disk.

So if users want to delete old events, now they'll have to save events to disk.