[Bug 278465] net/vnstat will not start after a reboot because of wrong ownership of db

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 19 Apr 2024 15:55:12 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278465

            Bug ID: 278465
           Summary: net/vnstat will not start after a reboot because of
                    wrong ownership of db
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: sunpoet@FreeBSD.org
          Reporter: void@f-m.fm
             Flags: maintainer-feedback?(sunpoet@FreeBSD.org)
          Assignee: sunpoet@FreeBSD.org

Hi,

net/vnstat once installed and configured runs under the U/GID of vnstat.
This is with vnstat_enable="YES" in /etc/rc.conf

In order to get it working, one has to change the ownership of /var/db/vnstat
and /var/db/vnstat/* and /var/run/vnstat from root:wheel to vnstat:vnstat and
then 'service vnstat (re)start' every time the machine boots.

###
root:~ # cd /var/run/vnstat
root:/var/run/vnstat # ls -lah
total 12
drwxr-xr-x   2 root wheel  512B Apr 19 13:09 .
drwxr-xr-x  13 root wheel  1.0K Apr 19 13:11 ..
-rw-r--r--   1 root wheel    6B Apr 19 13:11 vnstat.pid
root:/var/run/vnstat # service vnstat restart
Stopping vnstat.
kill: 47758: No such process
vnstat already running?  (pid=47758).
root:/var/run/vnstat # chown -R vnstat:vnstat /var/run/vnstat
root:/var/run/vnstat # service vnstat restart
Stopping vnstat.
kill: 47758: No such process
vnstat already running?  (pid=47758).
root:/var/run/vnstat # ls -lah
total 12
drwxr-xr-x   2 vnstat vnstat  512B Apr 19 13:09 .
drwxr-xr-x  13 root   wheel   1.0K Apr 19 13:11 ..
-rw-r--r--   1 vnstat vnstat    6B Apr 19 13:11 vnstat.pid
root:/var/run/vnstat # cat vnstat.pid
47758
root:/var/run/vnstat # rm vnstat.pid
root:/var/run/vnstat # service vnstat start
Starting vnstat.
Error: Exec step failed (8: attempt to write a readonly database): "update info
set value='2.12' where name='vnstatversion'"
Error: Failed to open database "/var/db/vnstat/vnstat.db" in read/write mode.
Exiting...
/usr/local/etc/rc.d/vnstat: WARNING: failed to start vnstat
root:/var/run/vnstat # chown -R vnstat:vnstat /var/db/vnstat
root:/var/run/vnstat # service vnstat start
Starting vnstat.
root:/var/run/vnstat # 
root:/var/run/vnstat # ls -lah
total 12
drwxr-xr-x   2 vnstat vnstat  512B Apr 19 16:48 .
drwxr-xr-x  13 root   wheel   1.0K Apr 19 13:11 ..
-rw-r--r--   1 vnstat vnstat    5B Apr 19 16:48 vnstat.pid
root:/var/run/vnstat # 

On reboot, the situation reverts. Below output from the console:

Starting vnstat.
Error: Exec step failed (8: attempt to write a readonly database): "update info
set value='2.12' where name='vnstatversion'"
Error: Failed to open database "/var/db/vnstat/vnstat.db" in read/write mode.
Exiting...
/etc/rc: WARNING: failed to start vnstat

-- 
You are receiving this mail because:
You are the assignee for the bug.