I'm repeatedly getting an error from nyx running under Ubuntu 18.04. It's fine on first run after a reboot. After a while, the terminal it's in shows a chaotic and frozen pattern. Quitting out and restarting, produces the error below, which ends in:

sqlite3.OperationalError: attempt to write a readonly database

The problem appears to be ~/.nyx/cache.sqlite, which is owned by root and which nyx is trying to write on startup/shutdown. I tried changing permissions from 644 to 664, and then even 666, but that didn't help. On the other hand, changing ownership to myself did help. Is this a security risk? Why didn't 666, which should have given everyone write permission, work?

Traceback (most recent call last): File "/usr/bin/nyx", line 11, in <module> load_entry_point('nyx==2.0.4', 'console_scripts', 'nyx')() File "/usr/lib/python3/dist-packages/nyx/__init__.py", line 176, in main nyx.starter.main() File "/usr/lib/python3/dist-packages/stem/util/conf.py", line 289, in wrapped return func(*args, config = config, **kwargs) File "/usr/lib/python3/dist-packages/nyx/starter.py", line 118, in main nyx.curses.start(nyx.draw_loop, acs_support = config.get('acs_support', True), transparent_background = True, cursor = False) File "/usr/lib/python3/dist-packages/nyx/curses.py", line 217, in start curses.wrapper(_wrapper) File "/usr/lib/python3.6/curses/__init__.py", line 94, in wrapper return func(stdscr, *args, **kwds) File "/usr/lib/python3/dist-packages/nyx/curses.py", line 215, in _wrapper function() File "/usr/lib/python3/dist-packages/nyx/__init__.py", line 194, in draw_loop interface = nyx_interface() File "/usr/lib/python3/dist-packages/nyx/__init__.py", line 256, in nyx_interface Interface() # constructor sets NYX_INTERFACE File "/usr/lib/python3/dist-packages/nyx/__init__.py", line 589, in __init__ self._header_panel = nyx.panel.header.HeaderPanel() File "/usr/lib/python3/dist-packages/nyx/panel/header.py", line 47, in __init__ self._vals = Sampling.create() File "/usr/lib/python3/dist-packages/nyx/panel/header.py", line 235, in create my_router_status_entry = nyx.tracker.get_consensus_tracker().my_router_status_entry() File "/usr/lib/python3/dist-packages/nyx/tracker.py", line 169, in get_consensus_tracker CONSENSUS_TRACKER = ConsensusTracker() File "/usr/lib/python3/dist-packages/nyx/tracker.py", line 831, in __init__ self._update(ns_response) File "/usr/lib/python3/dist-packages/nyx/tracker.py", line 853, in _update writer.record_relay(fingerprint, address, or_port, nickname) File "/usr/lib/python3/dist-packages/nyx/__init__.py", line 569, in record_relay self._cache._query('INSERT OR REPLACE INTO relays(fingerprint, address, or_port, nickname) VALUES (?,?,?,?)', fingerprint, address, or_port, nickname) File "/usr/lib/python3/dist-packages/nyx/__init__.py", line 541, in _query return self._conn.execute(query, param) sqlite3.OperationalError: attempt to write a readonly database


This is a bug which has been reported.

I do not know if my work-around was a security risk, but the solution that they offer on the bug tracker is:

Users should be able to work around this with the following... % echo "data_directory disabled" >> my_nyxrc % nyx --config my_nyxrc


Changing the owner of the config directory to the current user and group fixed the error for me:
sudo chown $(id -u):$(id -g) -R ~/.nyx

On the first run (on Ubuntu 18.04) I started nyx logged in as a regular user with sudo nyx. A notice was shown: Nyx is currently running with root permissions. This isn't a good idea, nor should it be necessary. While nyx ran normally, it created its config directory ~/.nyx (containing the SQLite database) owned by root:root. Later, I started nyx again as a regular user and it crashed with the error: sqlite3.OperationalError: attempt to write a readonly database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.