From ec4f46b6984a4fcfbd23126c4a27dde89602f851 Mon Sep 17 00:00:00 2001 From: Cesar Talledo Date: Wed, 4 Dec 2024 18:30:29 -0800 Subject: [PATCH] Fix left-over .sysbox dirs inside the container. Fixes left-over .sysbox-procfs-* and .sysbox-sysfs-* dirs inside containers. They were being incorrectly left over by sysbox-fs nsenter processes. Fixes https://github.com/nestybox/sysbox/issues/829. Signed-off-by: Cesar Talledo --- nsenter/utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nsenter/utils.go b/nsenter/utils.go index 387e935..2372f91 100644 --- a/nsenter/utils.go +++ b/nsenter/utils.go @@ -96,7 +96,7 @@ func processPayloadMounts(mountSysfs, mountProcfs bool) (*payloadMountsInfo, err cleanupSysfs := func(mountpoint string) { if mountpoint != "" { unix.Unmount(mountpoint, unix.MNT_DETACH) - if strings.HasPrefix(mountpoint, ".sysbox-sysfs-") { + if strings.HasPrefix(mountpoint, "/.sysbox-sysfs-") { os.RemoveAll(mountpoint) } } @@ -125,6 +125,9 @@ func processPayloadMounts(mountSysfs, mountProcfs bool) (*payloadMountsInfo, err cleanupProcfs := func(mountpoint string) { if mountpoint != "" { unix.Unmount(mountpoint, unix.MNT_DETACH) + if strings.HasPrefix(mountpoint, "/.sysbox-procfs-") { + os.RemoveAll(mountpoint) + } } }