|
@@ -26,7 +26,12 @@ func chroot(path string) (err error) {
|
|
return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
|
|
return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
|
|
}
|
|
}
|
|
|
|
|
|
- if err := mount.MakeRPrivate(path); err != nil {
|
|
|
|
|
|
+ // make everything in new ns private
|
|
|
|
+ if err := mount.MakeRPrivate("/"); err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ // ensure path is a mountpoint
|
|
|
|
+ if err := mount.MakePrivate(path); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
@@ -57,13 +62,6 @@ func chroot(path string) (err error) {
|
|
err = errCleanup
|
|
err = errCleanup
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if errCleanup := syscall.Unmount("/", syscall.MNT_DETACH); errCleanup != nil {
|
|
|
|
- if err == nil {
|
|
|
|
- err = fmt.Errorf("error unmounting root: %v", errCleanup)
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
}()
|
|
}()
|
|
|
|
|
|
if err := syscall.PivotRoot(path, pivotDir); err != nil {
|
|
if err := syscall.PivotRoot(path, pivotDir); err != nil {
|