mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
pathrs: rename MkdirAllInRootOpen -> MkdirAllInRoot
Now that MkdirAllInRoot has been removed, we can make MkdirAllInRootOpen
less wordy by renaming it to MkdirAllInRoot. This is a non-functional
change.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
(cherry picked from commit 20c5a8ec4a)
Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
This commit is contained in:
committed by
Aleksa Sarai
parent
ec44abc710
commit
b60f248d71
@@ -28,7 +28,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// MkdirAllInRootOpen attempts to make
|
||||
// MkdirAllInRoot attempts to make
|
||||
//
|
||||
// path, _ := securejoin.SecureJoin(root, unsafePath)
|
||||
// os.MkdirAll(path, mode)
|
||||
@@ -49,10 +49,10 @@ import (
|
||||
// handling if unsafePath has already been scoped within the rootfs (this is
|
||||
// needed for a lot of runc callers and fixing this would require reworking a
|
||||
// lot of path logic).
|
||||
func MkdirAllInRootOpen(root, unsafePath string, mode os.FileMode) (*os.File, error) {
|
||||
func MkdirAllInRoot(root, unsafePath string, mode os.FileMode) (*os.File, error) {
|
||||
// If the path is already "within" the root, get the path relative to the
|
||||
// root and use that as the unsafe path. This is necessary because a lot of
|
||||
// MkdirAllInRootOpen callers have already done SecureJoin, and refactoring
|
||||
// MkdirAllInRoot callers have already done SecureJoin, and refactoring
|
||||
// all of them to stop using these SecureJoin'd paths would require a fair
|
||||
// amount of work.
|
||||
// TODO(cyphar): Do the refactor to libpathrs once it's ready.
|
||||
|
||||
@@ -53,7 +53,7 @@ func CreateInRoot(root, subpath string, flags int, fileMode uint32) (*os.File, e
|
||||
return nil, fmt.Errorf("create in root subpath %q has bad trailing component %q", subpath, filename)
|
||||
}
|
||||
|
||||
dirFd, err := MkdirAllInRootOpen(root, dir, 0o755)
|
||||
dirFd, err := MkdirAllInRoot(root, dir, 0o755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ func mountCgroupV1(m mountEntry, c *mountConfig) error {
|
||||
// TODO: Why not just use b.Destination (c.root is the root here)?
|
||||
subsystemPath := filepath.Join(c.root, b.Destination)
|
||||
subsystemName := filepath.Base(b.Destination)
|
||||
subsystemDir, err := pathrs.MkdirAllInRootOpen(c.root, subsystemPath, 0o755)
|
||||
subsystemDir, err := pathrs.MkdirAllInRoot(c.root, subsystemPath, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -560,7 +560,7 @@ func (m *mountEntry) createOpenMountpoint(rootfs string) (Err error) {
|
||||
if dstIsFile {
|
||||
dstFile, err = pathrs.CreateInRoot(rootfs, unsafePath, unix.O_CREAT|unix.O_EXCL|unix.O_NOFOLLOW, 0o644)
|
||||
} else {
|
||||
dstFile, err = pathrs.MkdirAllInRootOpen(rootfs, unsafePath, 0o755)
|
||||
dstFile, err = pathrs.MkdirAllInRoot(rootfs, unsafePath, 0o755)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("make mountpoint %q: %w", m.Destination, err)
|
||||
@@ -622,7 +622,7 @@ func mountToRootfs(c *mountConfig, m mountEntry) error {
|
||||
} else if !fi.IsDir() {
|
||||
return fmt.Errorf("filesystem %q must be mounted on ordinary directory", m.Device)
|
||||
}
|
||||
dstFile, err := pathrs.MkdirAllInRootOpen(rootfs, dest, 0o755)
|
||||
dstFile, err := pathrs.MkdirAllInRoot(rootfs, dest, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -997,7 +997,7 @@ func createDeviceNode(rootfs string, node *devices.Device, bind bool) error {
|
||||
return fmt.Errorf("%w: mknod over rootfs", errRootfsToFile)
|
||||
}
|
||||
destDirPath, destName := filepath.Split(destPath)
|
||||
destDir, err := pathrs.MkdirAllInRootOpen(rootfs, destDirPath, 0o755)
|
||||
destDir, err := pathrs.MkdirAllInRoot(rootfs, destDirPath, 0o755)
|
||||
if err != nil {
|
||||
return fmt.Errorf("mkdir parent of device inode %q: %w", node.Path, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user