Bug 13983 - Wrong ownership for "/var/lib/knot-resolver"
Summary: Wrong ownership for "/var/lib/knot-resolver"
Status: CLOSED FIXED
Alias: None
Product: IPFire
Classification: Unclassified
Component: --- (show other bugs)
Version: 2
Hardware: unspecified Unspecified
: - Unknown - - Unknown -
Assignee: Assigned to nobody - feel free to grab it and work on it
QA Contact:
URL:
Keywords:
Depends on:
Blocks: KRESD
  Show dependency treegraph
 
Reported: 2026-05-23 13:08 UTC by Stefan Schantl
Modified: 2026-07-20 16:14 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Schantl 2026-05-23 13:08:03 UTC
The latest (and firest) testing images contains a "/var/lib/knot-resolver" directory with a wrong ownership.

This should be "knot-resolver:knot-resolver" instead of "root:root".
Comment 2 Adam Gibbons 2026-05-28 14:03:44 UTC
Tested on current nightly build.

Initial state after install/boot:

  /var/lib/knot-resolver              root:root 755
  /var/lib/knot-resolver/leases.db    root:root 644
  /var/lib/knot-resolver/zones        missing

Knot Resolver was running, but DHCP lease lookups produced repeated log errors:

  /usr/lib/knot-resolver/kres_modules/leases.lua:76:
    attempt to index upvalue 'sql_fwd' (a nil value)

  /usr/lib/knot-resolver/kres_modules/leases.lua:102:
    attempt to index upvalue 'sql_rev' (a nil value)

The DB schema existed, but accessing it as the knot-resolver user failed before correcting ownership:

  setpriv --reuid=knot-resolver --init-groups \
    sqlite3 /var/lib/knot-resolver/leases.db 'select count(*) from leases;'

  -> attempt to write a readonly database

Manual workaround applied:

  /etc/init.d/knot-resolver stop

  install -o knot-resolver -g knot-resolver -m 0755 -d \
    /var/lib/knot-resolver \
    /var/lib/knot-resolver/zones

  chown knot-resolver:knot-resolver \
    /var/lib/knot-resolver \
    /var/lib/knot-resolver/leases.db

  chmod 0755 /var/lib/knot-resolver
  chmod 0644 /var/lib/knot-resolver/leases.db
  chmod 0755 /var/lib/knot-resolver/zones

  /etc/init.d/knot-resolver start

After this, read-only DB access as knot-resolver worked:

  setpriv --reuid=knot-resolver --init-groups \
    sqlite3 'file:/var/lib/knot-resolver/leases.db?mode=ro' \
    'select count(*) from leases;'

  -> 0 initially, then 1 after adding a test lease.

DHCP lease test:

  /usr/sbin/dhcp-lease commit \
    ADDRESS=192.168.0.250 \
    HOSTNAME=kres-test \
    DOMAINNAME=home.home

  kdig @127.0.0.1 kres-test.home.home. A +short
  -> 192.168.0.250

  kdig @127.0.0.1 -x 192.168.0.250 +short
  -> kres-test.forest.home.

After reboot, ownership persisted:

  /var/lib/knot-resolver              knot-resolver:knot-resolver 755
  /var/lib/knot-resolver/leases.db    knot-resolver:knot-resolver 644
  /var/lib/knot-resolver/zones        knot-resolver:knot-resolver 755

After reboot, DHCP lease A and PTR lookups still worked and no fresh
sql_fwd/sql_rev nil errors appeared.
Comment 3 Michael Tremer 2026-05-28 14:15:03 UTC
Please don't use any AI for posts like this. This is super long and I have no idea what you want to tell me.
Comment 4 Adam Gibbons 2026-05-28 14:21:36 UTC
Sorry, let me rephrase more clearly.

The problem seems to be file ownership.

On my system after install of the latest nightly:

  /var/lib/knot-resolver              root:root 755
  /var/lib/knot-resolver/leases.db    root:root 644
  /var/lib/knot-resolver/zones        missing

With that state, DHCP lease lookups caused repeated errors:

  leases.lua:76: attempt to index upvalue 'sql_fwd' (a nil value)
  leases.lua:102: attempt to index upvalue 'sql_rev' (a nil value)

After changing ownership to knot-resolver:knot-resolver and creating the zones directory:

  /var/lib/knot-resolver              knot-resolver:knot-resolver 755
  /var/lib/knot-resolver/leases.db    knot-resolver:knot-resolver 644
  /var/lib/knot-resolver/zones        knot-resolver:knot-resolver 755

DHCP lease forward and reverse lookups started working:

  kres-test.home.home -> 192.168.0.250
  192.168.0.250 -> kres-test.home.home

This also still worked after reboot.

The resolver itself works once ownership is fixed, but the installed state had the wrong owner and was missing /var/lib/knot-resolver/zones.
Comment 5 Michael Tremer 2026-05-28 14:23:17 UTC
No, DON'T USE AI.

You should have posted one line. That is all it needed. Don't do it again.
Comment 7 Michael Tremer 2026-07-20 16:14:18 UTC
Core Update 203 has been released:

> https://www.ipfire.org/blog/ipfire-2-29-core-update-203-released