From 0f4f76a9a23bf430ba2058eb72a84e7f5dc5f99e Mon Sep 17 00:00:00 2001 From: yo Date: Sun, 19 Jun 2022 19:14:11 +0200 Subject: [PATCH] fix Error unmounting display bug, unconditionally unmount /dev & /dev/fd, remove parameter file --- cmd/stop.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/stop.go b/cmd/stop.go index 80c9df3..d945376 100644 --- a/cmd/stop.go +++ b/cmd/stop.go @@ -132,7 +132,7 @@ func umountJailFsFromHost(jail *Jail, mountpoint string) error { cmd = fmt.Sprintf("umount %s%s", jail.RootPath, mountpoint) _, err := executeCommand(cmd) if err != nil { - return errors.New(fmt.Sprintf("Error umounting %s/%s: %s", jail.RootPath, mountpoint, err.Error())) + return errors.New(fmt.Sprintf("Error umounting %s%s: %s", jail.RootPath, mountpoint, err.Error())) } return nil } @@ -293,15 +293,16 @@ func StopJail(args []string) { } } - if cj.Config.Mount_fdescfs > 0 { + // FIXME: /dev/fd is mounted even with Mount_fdescfs = 0 ?! + //if cj.Config.Mount_fdescfs > 0 { fmt.Printf(" > Umount fdescfs:\n") - err := umountJailFsFromHost(cj, "/dev/fd") + err = umountJailFsFromHost(cj, "/dev/fd") if err != nil { fmt.Printf("ERROR: %s\n", err.Error()) } else { fmt.Printf(" > Umount fdescfs: OK\n") } - } + //} if cj.Config.Mount_devfs > 0 { fmt.Printf(" > Umount devfs:\n") @@ -314,7 +315,6 @@ func StopJail(args []string) { } // Remove local mounts from $JAIL/fstab - // The way we get fstab is presumptuous fstab := strings.Replace(cj.ConfigPath, "config.json", "fstab", 1) mounts, err := getFstab(fstab) if err != nil { @@ -334,5 +334,13 @@ func StopJail(args []string) { fmt.Printf(" > Umount mountpoints from %s: OK\n", fstab) } } + + // Remove parameter file + pfile := fmt.Sprintf("/var/run/jail.%s.conf", cj.InternalName) + if err = os.Remove(pfile); err != nil { + fmt.Printf("Error deleting parameter file %s\n", pfile) + } + + cj.InternalName = "" } }