]> git.ipfire.org Git - thirdparty/bind9.git/commit
Stop nzd_env_close from chowning through symlinks
authorOndřej Surý <ondrej@isc.org>
Wed, 29 Apr 2026 15:49:46 +0000 (17:49 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 29 Apr 2026 17:18:47 +0000 (19:18 +0200)
commit63d30566bb8be8a49dd5320c3be6bc037ec9d399
tree4c49ae4faf00f14de3bf8994df688174aef9d1a5
parentb8e09a5b5f1e17c9f1d38a91a8b62e2c26d786f7
Stop nzd_env_close from chowning through symlinks

When named is running as root, nzd_env_close() chowns the per-view
NZD database file to the unprivileged user that named will drop to.
The call used chown(), which follows symlinks, so a symlink at the
NZD path would silently transfer ownership of whatever the link
pointed at instead of the database file itself.

Switch to lstat() + S_ISREG() + lchown() so the chown only fires when
the path is a regular file and never traverses a symlink even if one
is planted between the lstat and the lchown.

Assisted-by: Claude:claude-opus-4-7
bin/named/nzd.c