]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bhyveload: use a dirfd to support -h
authorKyle Evans <kevans@FreeBSD.org>
Wed, 3 Jan 2024 22:17:59 +0000 (16:17 -0600)
committerKyle Evans <kevans@FreeBSD.org>
Mon, 15 Jan 2024 23:11:38 +0000 (17:11 -0600)
commit78345dbd7a004e0a6d1b717e7dbc758ae67ca293
tree5e0b8b0b26ac563dacbcb64c17810d14bec476e5
parent03bff02e81d38f0241b44769a79eb96f94a4960b
bhyveload: use a dirfd to support -h

Don't allow lookups from the loader scripts, which in rare cases may be
in guest control depending on the setup, to leave the specified host
root.  Open the root dir and strictly do RESOLVE_BENEATH lookups from
there.

cb_open() has been restructured a bit to work nicely with this, using
fdopendir() in the directory case and just using the fd we already
opened in the regular file case.

hostbase_open() was split out to provide an obvious place to apply
rights(4) if that's something we care to do.

Reviewed by: allanjude (earlier version), markj

(cherry picked from commit 6779d44bd878e3cf4723f7386b11da6508ab5431)
usr.sbin/bhyveload/bhyveload.c