diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d3b340c..4fffdf0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Capture "broken" symlinks during container build. #1267 - Fix the issue that removing lines during wwctl overlay edit didn't work. #1235 - Fix the issue that new files created with wwctl overlay edit have 755 permissions. #1236 +- Mount `/sys` and `/run` during `wwctl container exec`. #1287 ## v4.5.4, 2024-06-12 diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index 62d09a20..a6502111 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -135,11 +135,6 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { } } - err = syscall.Mount("/dev", path.Join(containerPath, "/dev"), "", syscall.MS_BIND, "") - if err != nil { - return errors.Wrap(err, "failed to mount /dev") - } - for _, mntPnt := range mountPts { err = syscall.Mount(mntPnt.Source, path.Join(containerPath, mntPnt.Dest), "", syscall.MS_BIND, "") if err != nil { @@ -166,9 +161,17 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { return errors.Wrap(err, "failed to chdir") } - err = syscall.Mount("/proc", "/proc", "proc", 0, "") - if err != nil { - return errors.Wrap(err, "failed to mount proc") + if err := syscall.Mount("devtmpfs", "/dev", "devtmpfs", 0, ""); err != nil { + return errors.Wrap(err, "failed to mount /dev") + } + if err := syscall.Mount("sysfs", "/sys", "sysfs", 0, ""); err != nil { + return errors.Wrap(err, "failed to mount /sys") + } + if err := syscall.Mount("proc", "/proc", "proc", 0, ""); err != nil { + return errors.Wrap(err, "failed to mount /proc") + } + if err := syscall.Mount("tmpfs", "/run", "tmpfs", 0, ""); err != nil { + return errors.Wrap(err, "failed to mount /run") } os.Setenv("PS1", ps1Str)