From 543c997978525ac7de3a24ff73203ddbb2cef6dc Mon Sep 17 00:00:00 2001 From: Brielle Broder Date: Mon, 30 Jul 2018 17:16:49 -0700 Subject: Cleans up files created if there is a failure. PiperOrigin-RevId: 206674267 Change-Id: Ifc4eb19e0882e8bed566e9c553af910925fe6ae2 --- runsc/fsgofer/fsgofer.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runsc') diff --git a/runsc/fsgofer/fsgofer.go b/runsc/fsgofer/fsgofer.go index f685738c3..52cdc91a2 100644 --- a/runsc/fsgofer/fsgofer.go +++ b/runsc/fsgofer/fsgofer.go @@ -392,11 +392,17 @@ func (l *localFile) Create(name string, mode p9.OpenFlags, perm p9.FileMode, uid } if err := fchown(fd, uid, gid); err != nil { syscall.Close(fd) + if e := syscall.Unlinkat(l.controlFD(), name); e != nil { + log.Warningf("error unlinking file %q after failed chown: %v", name, e) + } return nil, nil, p9.QID{}, 0, extractErrno(err) } stat, err := stat(fd) if err != nil { syscall.Close(fd) + if e := syscall.Unlinkat(l.controlFD(), name); e != nil { + log.Warningf("error unlinking file %q after failed stat: %v", name, e) + } return nil, nil, p9.QID{}, 0, extractErrno(err) } -- cgit v1.2.3