libct: switch final WithProcfd users to WithProcfdFile

This probably should've been done as part of commit d40b3439a9
("rootfs: switch to fd-based handling of mountpoint targets") but it
seems I missed them when doing the rest of the conversions.

This also lets us remove utils.WithProcfd entirely, as well as
pathrs.MkdirAllInRoot. Unfortunately, WithProcfd was exposed in the
externally-importable "libcontainer/utils" package and so we need to
have a deprecation notice to remove it in runc 1.5.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai
2025-11-09 02:03:42 +11:00
parent 42a1e19d67
commit 9dbd37e06f
4 changed files with 27 additions and 21 deletions
+10 -2
View File
@@ -152,6 +152,9 @@ func NewSockPair(name string) (parent, child *os.File, err error) {
// through the passed fdpath should be safe. Do not access this path through
// the original path strings, and do not attempt to use the pathname outside of
// the passed closure (the file handle will be freed once the closure returns).
//
// Deprecated: This function is an internal implementation detail of runc and
// is no longer used. It will be removed in runc 1.5.
func WithProcfd(root, unsafePath string, fn func(procfd string) error) error {
// Remove the root then forcefully resolve inside the root.
unsafePath = pathrs.LexicallyStripRoot(root, unsafePath)
@@ -181,10 +184,15 @@ func WithProcfd(root, unsafePath string, fn func(procfd string) error) error {
return fn(procfd)
}
// WithProcfdFile is a very minimal wrapper around [ProcThreadSelfFd], intended
// to make migrating from [WithProcfd] and [WithProcfdPath] usage easier. The
// WithProcfdFile is a very minimal wrapper around [ProcThreadSelfFd]. The
// caller is responsible for making sure that the provided file handle is
// actually safe to operate on.
//
// NOTE: THIS FUNCTION IS INTERNAL TO RUNC, DO NOT USE IT.
//
// TODO: Migrate the mount logic towards a more move_mount(2)-friendly design
// where this is kind of /proc/self/... tomfoolery is only done in a fallback
// path for old kernels.
func WithProcfdFile(file *os.File, fn func(procfd string) error) error {
fdpath, closer := ProcThreadSelfFd(file.Fd())
defer closer()