Merge pull request #1292 from anderbubble/MountSys

mount /sys and /run during container exec
This commit is contained in:
Christian Goll
2024-07-04 07:55:18 +02:00
committed by GitHub
2 changed files with 12 additions and 8 deletions

View File

@@ -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

View File

@@ -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)