[Midnightbsd-cvs] [MidnightBSD/src] 35fdfc: unix: support fchmod(2) on unix sockets before bin...
Lucas Holt
noreply at github.com
Tue Sep 29 17:51:52 EDT 2026
Branch: refs/heads/unix-fchmod
Home: https://github.com/MidnightBSD/src
Commit: 35fdfc23f8c6e740ec883628f0bc8fd3a5ea7ff2
https://github.com/MidnightBSD/src/commit/35fdfc23f8c6e740ec883628f0bc8fd3a5ea7ff2
Author: Lucas Holt <luke at foolishgames.com>
Date: 2026-09-29 (Tue, 29 Sep 2026)
Changed paths:
M lib/libc/sys/chmod.2
M share/man/man4/unix.4
M sys/kern/sys_socket.c
M sys/kern/uipc_usrreq.c
M sys/sys/protosw.h
M sys/sys/unpcb.h
M tests/sys/kern/Makefile
A tests/sys/kern/unix_dgram.c
Log Message:
-----------
unix: support fchmod(2) on unix sockets before bind(2)
Allow fchmod() on an AF_UNIX socket prior to bind(), so that the mode
of the socket file is set atomically when it is created in the
filesystem. Without this, callers must chmod() after bind(), leaving a
window where the socket is reachable with the default mode. Once the
socket is bound, fchmod() reverts to failing with EINVAL. The
interface mirrors Linux.
Adapted from FreeBSD bfd03046d187 (D47361, PR 282393). Our protosw
still uses the pr_usrreqs layout, so the hook is a new pru_chmod entry
rather than pr_chmod; soo_chmod() dispatches to it and returns EINVAL
for protocols that do not provide one. fstat() behaviour is unchanged.
The FreeBSD stable/15 syslogd imported in #526 uses this in
socksetup(); its chmod()-after-bind fallback now only triggers on
older kernels.
Only the fchmod test from FreeBSD's tests/sys/kern/unix_dgram.c is
carried, since the other cases depend on newer socket buffer code.
Closes #527
Signed-off-by: Lucas Holt <luke at foolishgames.com>
AI-Assisted-by: Claude Fable 5.1
Co-Authored-By: Claude Fable 5.1 <noreply at anthropic.com>
To unsubscribe from these emails, change your notification settings at https://github.com/MidnightBSD/src/settings/notifications
More information about the Midnightbsd-cvs
mailing list