Page MenuHomeFreeBSD

daemon: Add option for output file mode
ClosedPublic

Authored by michaelo on Jan 28 2026, 7:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 28, 11:13 AM
Unknown Object (File)
Sun, Feb 22, 7:03 AM
Unknown Object (File)
Fri, Feb 13, 2:58 AM
Unknown Object (File)
Thu, Feb 12, 4:13 PM
Unknown Object (File)
Wed, Feb 11, 11:08 AM
Unknown Object (File)
Tue, Feb 10, 1:09 PM
Unknown Object (File)
Sun, Feb 8, 1:08 PM
Unknown Object (File)
Tue, Feb 3, 4:49 AM
Subscribers

Details

Summary

The daemon utility has always created its output file with a fixed mode
of 0600. This causes issues for log collection setups where the collector
does not run as root but instead relies on group access to the watched
daemon’s log file.

Introduce a new option that allows specifying the output file mode using
install(1)-style semantics. This enables non-root log collectors to access
the file as intended and improves compatibility with log rotation tools.

MFC after: 1 week
Relnotes: yes

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I used the code logic from install(1).

Fails properly with invalid value:

# service fluent-bit restart
fluent_bit not running? (check /var/run/fluent_bit.pid).
Starting fluent_bit.
daemon: unrecognized output file mode: 0640X
/usr/local/etc/rc.d/fluent-bit: WARNING: failed to start fluent_bit

Properly passes when the file is opened:

# truss -p 77411
kevent(6,0x0,0,{ SIGHUP,EVFILT_SIGNAL,EV_CLEAR,0,0x1,0x0 },1,0x0) = 1 (0x1)
openat(AT_FDCWD,"/var/log/fluent_bit/fluent_bit.log",O_WRONLY|O_APPEND|O_CREAT|O_CLOEXEC,0640) = 8 (0x8)
close(3)                                         = 0 (0x0)

Guys, please have a look. It'd be fantastic to have it in 14.4-RELEASE.

usr.sbin/daemon/daemon.c
79

Technically this should sort below between ints and bools as a 16-bit type, but we've not done a very good job of keeping this sorted properly and it's effectively a singleton anyways...

256

This free() should go away, since we don't intend to keep a live set around

257

style(9), though I realize install(1) is also wrong here.

262

Just to be safe / avoid a possible double-free.

This revision is now accepted and ready to land.Sat, Feb 7, 1:53 AM
This revision was automatically updated to reflect the committed changes.