[lxc-devel] [distrobuilder/master] shared: Close created files
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Thu Feb 27 13:25:41 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200227/eea05988/attachment.bin>
-------------- next part --------------
From acd0645e45c14be07907d5b2cc9f6a068b0794cf Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Thu, 27 Feb 2020 14:17:11 +0100
Subject: [PATCH] shared: Close created files
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
shared/chroot.go | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/shared/chroot.go b/shared/chroot.go
index 6b27b01..e15540e 100644
--- a/shared/chroot.go
+++ b/shared/chroot.go
@@ -44,10 +44,11 @@ func setupMounts(rootfs string, mounts []ChrootMount) error {
return err
}
} else {
- _, err = os.Create(tmpTarget)
+ f, err := os.Create(tmpTarget)
if err != nil {
return err
}
+ f.Close()
}
// Mount to the temporary path
@@ -109,10 +110,11 @@ func moveMounts(mounts []ChrootMount) error {
return err
}
} else {
- _, err = os.Create(target)
+ f, err := os.Create(target)
if err != nil {
return err
}
+ f.Close()
}
// Move the mount to its destination
More information about the lxc-devel
mailing list