Bug 262995 - dns/unbound: Not recorded in syslogd
Summary: dns/unbound: Not recorded in syslogd
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-02 01:27 UTC by vfx9as
Modified: 2022-11-30 16:50 UTC (History)
5 users (show)

See Also:
jaap: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vfx9as 2022-04-02 01:27:10 UTC
Not recorded in syslog unless local-unbound is restarted 

unbound-1.14.0.pkg:

# pkg install unbound
# unbound-control-setup 

/var/log/console.log
 kernel: Starting local_unbound.
 kernel: Waiting for nameserver to start... good
 -- Unbound can not record log because syslogd has not started 

 kernel: Updating /var/run/os-release done.
 kernel: Creating and/or trimming log files.
 kernel: Updating motd:.
 kernel: Starting syslogd.
 -- After that, even if syslogd starts, unbound does not reopen the log, so it will continue to fail 

# sockstat | grep unb
unbound  unbound    452   3  udp6   ::1:53                *:*
unbound  unbound    452   4  tcp6   ::1:53                *:*
unbound  unbound    452   5  udp4   127.0.0.1:53          *:*
unbound  unbound    452   6  tcp4   127.0.0.1:53          *:*
unbound  unbound    452   7  stream -> ??
unbound  unbound    452   8  stream -> ??

# grep unbou /var/log/all.log 
 kernel: Starting unbound.
 -- unbound cannot be recorded in syslog

# service unbound restart
Stopping unbound.
Waiting for PIDS: 452.
Obtaining a trust anchor...
Starting unbound.

# sockstat | grep unb
unbound  unbound    758   3  udp6   ::1:53                *:*
unbound  unbound    758   4  tcp6   ::1:53                *:*
unbound  unbound    758   5  udp4   127.0.0.1:53          *:*
unbound  unbound    758   6  tcp4   127.0.0.1:53          *:*
unbound  unbound    758   7  dgram  -> /var/run/logpriv
unbound  unbound    758   8  stream -> ??
unbound  unbound    758   9  stream -> ??

# grep unbou /var/log/all.log 
 kernel: Starting unbound.
 kernel: Starting unbound.
 unbound[758]: [758:0] notice: init module 0: validator
 unbound[758]: [758:0] notice: init module 1: iterator
 unbound[758]: [758:0] info: start of service (unbound 1.14.0).
 -- unbound can be recorded in syslog 

Where is the best restert?

local-unbound also cause the same problem (bug #262844)
Comment 1 vfx9as 2022-04-02 01:37:18 UTC
x Not recorded in syslog unless local-unbound is restarted 
o Not recorded in syslog unless dns/unbound is restarted
Comment 2 Jaap Akkerhuis 2022-04-04 11:33:21 UTC
Instead of a restart, you could do a "unbound-control log_reopen".

See man 8 unbound-control for details
Comment 3 vfx9as 2022-04-05 12:22:16 UTC
(In reply to Jaap Akkerhuis from comment #2)

Confirmed fail.
It is chrooted by default, so log_reopen does not solve the problem.

man 8 unbound-contro log_reopen
>(which may not work if chrooted).

dns/unbound 
 # unbound-checkconf -o chroot
 /usr/local/etc/unbound

I'm not sure which script is appropriate to patch to fix the problem of not logging.
/etc/rc.d/syslogd ?
create /etc/rc.d/unbound-shyslog ?
Other mechanisms?
Comment 4 Jaap Akkerhuis 2022-04-05 13:08:06 UTC
Just restart the daemon fixes it.

You can always try to complain to upstairs about unbound-control not matching expectations.
Comment 5 vfx9as 2022-04-11 12:35:52 UTC
The following script could handle it

-- /usr/local/etc/rc.d/unbound_syslog --
#!/bin/sh

# PROVIDE: unbound_syslog
# REQUIRE: unbound syslogd

. /etc/rc.subr

name="unbound_syslog"
desc="unbound to use syslog"
start_cmd="${name}_start"
stop_cmd=":"

load_rc_config "unbound"

: ${unbound_enable:="NO"}
: ${unbound_config:=/usr/local/etc/unbound/unbound.conf}

checkconf="/usr/local/sbin/unbound-checkconf"

unbound_syslog_start()
{
	if checkyesno unbound_enable; then
		usesyslog=`${checkconf} -o use-syslog ${unbound_config}`
		if checkyesno usesyslog; then
			echo unbound restarts to use syslog
			/usr/sbin/service unbound restart
		fi
	fi
}

run_rc_command "$1"
Comment 6 Tatsuki Makino 2022-04-12 21:35:22 UTC
(In reply to vfx9as from comment #5)

There is such a thing, but please write the results of the rcorder here first :)

rcorder /etc/rc.d/*

My 12.3-STABLE results also had syslogd later than local_unbound, so it must not find it.

︙
/etc/rc.d/local_unbound
/etc/rc.d/NETWORKING
︙
/etc/rc.d/syslogd
︙

I reverted back to bind because of the poor performance of unbound :)
Comment 7 vfx9as 2022-04-13 16:16:49 UTC
(In reply to Tatsuki Makino from comment #6)

local_unbound is at bug #262844 
bug #262844 Comment #6 has rcorder results
Comment 8 Jaap Akkerhuis 2022-04-21 13:24:59 UTC
Running syslog is the default for a system. It is not the function of unbound to enforce that so this is not a bug.
Comment 9 Jaap Akkerhuis 2022-04-21 13:25:13 UTC
Running syslog is the default for a system. It is not the function of unbound to enforce that so this is not a bug.
Comment 10 Chris Hutchinson 2022-04-22 16:35:25 UTC
(In reply to Jaap Akkerhuis from comment #9)
If unbound doesn't have the facilities available
to satisfy it's needs. It is unbound' responsibility
to complain && indicate that.

--Chris
Comment 11 Borja Marcos 2022-11-04 08:34:42 UTC
I have stumbled upon a similar, related problem.

With the default configuration, after installing dns/unbound from ports, it won't 
log to syslogd because syslogd starts _after_ unbound is started.

The fix is trivial, after adding syslogd to the REQUIRE section in /usr/local/etc/rc.d/unbound it works as expected.
Comment 12 Chris Hutchinson 2022-11-04 17:49:07 UTC
(In reply to Borja Marcos from comment #11)
See also rcorder(8) || start late. :-)
Comment 13 Richard Russo 2022-11-30 16:50:23 UTC
I'm not sure if it's part of the syslog issue, but the rc change in the 1.17.0 port causes unbound to be first in rcorder instead of the same time as local_unbound, (seen on 13.1-RELEASE-p5)

moving the load_rc_config line back so it's ahead of the defaults fixed my issue 

link to the rc change: 
https://cgit.freebsd.org/ports/commit/?id=7b0d6de05baabfbcd7a25fd0440ee3bf1f3bc23e

FWIW, re: syslog, on my FreeBSD 13.1 system, and skipping unrelated scripts:

/etc/rc.d/syslogd
/etc/rc.d/SERVERS
/etc/rc.d/local_unbound /usr/local/etc/rc.d/unbound
/etc/rc.d/NETWORKING

So perhaps changes to syslogd or other rc files in base may have fixed the issue (assuming unbound from ports doesn't start first, like it did after upgrading)