diff options
author | Brielle Broder <bbroder@google.com> | 2018-07-30 17:16:49 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-07-30 17:18:02 -0700 |
commit | 543c997978525ac7de3a24ff73203ddbb2cef6dc (patch) | |
tree | e7fed37da5fc22ff6a578ae51d4bf9df55032c99 /runsc/fsgofer | |
parent | 0a55f8c1c11dc6d2dfb1bed02489f92bab437ea1 (diff) |
Cleans up files created if there is a failure.
PiperOrigin-RevId: 206674267
Change-Id: Ifc4eb19e0882e8bed566e9c553af910925fe6ae2
Diffstat (limited to 'runsc/fsgofer')
-rw-r--r-- | runsc/fsgofer/fsgofer.go | 6 |
1 files changed, 6 insertions, 0 deletions
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) } |