Bug 267016

Summary: dns/knot-resolver: Fix file permissions to enable cache garbage collector
Product: Ports & Packages Reporter: Yonas Yanfa <yonas.yanfa>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: fernape, freebsd, portmaster
Priority: --- Flags: bugzilla: maintainer-feedback? (freebsd)
Version: Latest   
Hardware: Any   
OS: Any   

Description Yonas Yanfa 2022-10-13 13:12:45 UTC
I've added the following to /usr/local/etc/rc.d/krescachegc:

start_precmd="${name}_prestart"

krescachegc_prestart() {
    chmod 660 /var/run/kresd/*.mdb
}

It might be a temporary fix until /var/run/kresd/data.mdb and /var/run/kresd/lock.mdb are created with proper file permissions.
Comment 1 Chris Hutchinson 2022-10-13 15:45:45 UTC
I keep these in /tmp/ as I mount it as an md(4).
Which makes reading/writing the files a great deal faster.
Hard-wiring these files and folder location seems like an
undesirable restriction to me.
Maybe make the location a variable?
Comment 2 Leo Vandewoestijne 2022-10-25 11:48:03 UTC
(In reply to Chris Hutchinson from comment #1)
How/where do you currently define the custom path?

AFAIK, I think if we change
  chmod 660 /var/run/kresd/*.mdb
to simply:
  chmod 660 %%RUNDIR%%/*.mdb
then both of you are happy†, since rundir is already a variable in the kresd rc script - and it seems(!) the krescachegc rc script knows this.



† on condition you did what the manual at knot-resolver.readthedocs.io recommend: have the entire rundir an md.
OR; do you maybe happen to set yours in kresd.conf?
Comment 3 Fernando Apesteguía freebsd_committer freebsd_triage 2022-11-09 18:14:08 UTC
diff --git a/dns/knot-resolver/pkg-plist b/dns/knot-resolver/pkg-plist
index bdc679d32de7..9f2f55ed0ef6 100644
--- a/dns/knot-resolver/pkg-plist
+++ b/dns/knot-resolver/pkg-plist
@@ -96,4 +96,4 @@ sbin/kres-cache-gc
 sbin/kresc
 sbin/kresd
 @dir(%%USERS%%,%%GROUPS%%,0755) %%ETCDIR%%
-@dir(%%USERS%%,%%GROUPS%%,0755) %%RUNDIR%%
+@dir(%%USERS%%,%%GROUPS%%,0660) %%RUNDIR%%

Would this work for you?
Comment 4 Yonas Yanfa 2022-11-09 23:27:52 UTC
(In reply to Chris Hutchinson from comment #1)
(In reply to Fernando Apesteguía from comment #3)

> Would this work for you?

Yes, this works for me, thanks.
Comment 5 Fernando Apesteguía freebsd_committer freebsd_triage 2022-11-10 15:48:32 UTC
Committed,

Thanks!
Comment 6 commit-hook freebsd_committer freebsd_triage 2022-11-10 15:49:02 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=42a47e6afb86a7da4a80ff88e672116538a8a398

commit 42a47e6afb86a7da4a80ff88e672116538a8a398
Author:     Fernando Apesteguía <fernape@FreeBSD.org>
AuthorDate: 2022-11-09 18:09:39 +0000
Commit:     Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2022-11-10 15:44:16 +0000

    dns/knot-resolver: Fix file permissions

    To enable cache garbage collector
    PR:             267016
    Reported by:    yonas.yanfa@gmail.com

 dns/knot-resolver/pkg-plist | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 7 Chris Hutchinson 2022-11-10 20:15:03 UTC
(In reply to Leo Vandewoestijne from comment #2)
FWIW I create the databases in a md(4) (memory disk/device)
So as long as I'm not restricted to some specific location.
I'm happy.

thanks.
Comment 8 Leo Vandewoestijne 2024-07-01 13:03:31 UTC
@Yonas / @Chris:
Part of this PR is re-addressed in PR 277540