evilsocket / opensnitch

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

[Bug] Logrotate Brakes GUI Loging #1092

Closed zero77 closed 4 months ago

zero77 commented 4 months ago

Describe the bug After i enable logrotate to rotate opensnitch logs it breaks the gui each time it runs. I am left with a completely blank gui with no data under any of the tabs (Events, Nodes, RULES, HOSTS, etc) But, after i restart the gui it works again and starts to show new logs but does not include old logs.

This is the logrotate config i am using: config

Include the following information:

To Reproduce

Steps to reproduce the behavior:

  1. enable logrotate
  2. whate for logs to be rotated
  3. open gui and see missing data - I am not sure how quickly this happens as i only see the effects when i open the gui

4 restart gui and it all works as normal again with out old logs

Post error logs: I am not sure how to provide the logs as restarting the gui is the workaround i am using and won't show any errors

Expected behavior (optional)

Screenshots

Additional context

gustavo-iniguez-goya commented 4 months ago

hi @zero77 ,

mmh, could you launch the gui from a terminal? hopefully it'll output some error to stdout.

zero77 commented 4 months ago

Hi @gustavo-iniguez-goya I have added a link to the logs below, it looks like there are some db errors when it first starts. After that the nodes connect and i couldn't see any more errors.

https://pastebin.com/raw/0vitb6p2

gustavo-iniguez-goya commented 4 months ago

thank you @zero77 ! do you remember what GUI version did you have installed before upgrading to v1.6.4?

zero77 commented 4 months ago

@gustavo-iniguez-goya I use deb-get to update so, i think i have updated to each version as it came out.

gustavo-iniguez-goya commented 4 months ago

I can't reproduce this behaviour. It's quite strange anyways, the schema version is being set correctly, but somehow it's not being saved to disk.

Could you close the GUI and run these commands?

$ sqlite3 /path/to/file.db "PRAGMA integrity_check;" $ sqlite3 /path/to/file.db "PRAGMA user_version;"

This one should modify the schema version, so it shouldn't try to update it on GUI start: $ sqlite3 /path/to/file.db "PRAGMA user_version = 3;"

verify that the value is 3 with $ sqlite3 /path/to/file.db "PRAGMA user_version;"

And see if after this command the GUI works again.

gustavo-iniguez-goya commented 4 months ago

Mmh, where's the db file located? is it maybe being deleted by some background cleanup process?

zero77 commented 4 months ago

@gustavo-iniguez-goya I have added the sql queries below. For clarity should the log file be a db or log, i have been using log but have just changed it to db, both seem to work

sqlite3 /etc/opensnitchd/opensnitch.db "PRAGMA integrity_check;" ok

sqlite3 /etc/opensnitchd/opensnitch.db "PRAGMA user_version;" 0

sqlite3 /etc/opensnitchd/opensnitch.db "PRAGMA user_version = 3;" Error: stepping, attempt to write a readonly database (8)

sudo sqlite3 /etc/opensnitchd/opensnitch.db "PRAGMA user_version = 3;" nothing returned

sqlite3 /etc/opensnitchd/opensnitch.db "PRAGMA user_version;" 3

gustavo-iniguez-goya commented 4 months ago

thank you @zero77 , the log file should be a regular plain text file. It's configured in /etc/opensnitchd/default-config.json (https://github.com/evilsocket/opensnitch/blob/master/daemon/default-config.json) and by default it points to /var/log/opensnitchd.log

On the other hand, the .db path is configured by the GUI and saved under $HOME/.config/opensnitchd/settings.conf (the user's home who opened the GUI). The GUI must have write access to the DB, so if you save it under /etc/opensnitchd/ be sure that your user can write to the .db

zero77 commented 4 months ago

Thanks for your help with this, i think i have misconfigured the log and db