mirror of
https://github.com/containers/podman.git
synced 2025-05-20 16:47:39 +08:00
libpod: don't make a broken symlink for /etc/mtab on FreeBSD
This file has not been present in BSD systems since 2.9.1 BSD and as far as I remember /proc/mounts has never existed on BSD systems. [NO NEW TESTS NEEDED] Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
@ -784,3 +784,20 @@ func (c *Container) safeMountSubPath(mountPoint, subpath string) (s *safeMountIn
|
||||
mountPoint: npath,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Container) makePlatformMtabLink(etcInTheContainerFd, rootUID, rootGID int) error {
|
||||
// If /etc/mtab does not exist in container image, then we need to
|
||||
// create it, so that mount command within the container will work.
|
||||
err := unix.Symlinkat("/proc/mounts", etcInTheContainerFd, "mtab")
|
||||
if err != nil && !os.IsExist(err) {
|
||||
return fmt.Errorf("creating /etc/mtab symlink: %w", err)
|
||||
}
|
||||
// If the symlink was created, then also chown it to root in the container
|
||||
if err == nil && (rootUID != 0 || rootGID != 0) {
|
||||
err = unix.Fchownat(etcInTheContainerFd, "mtab", rootUID, rootGID, unix.AT_SYMLINK_NOFOLLOW)
|
||||
if err != nil {
|
||||
return fmt.Errorf("chown /etc/mtab: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user