mount /sys and /run during container exec
Also unify mounting of sys, run, proc, and dev as occuring within the chroot and without bind mounts from the host. Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user