graphdriver.platformLChown: improve errors

Functions from os package, such as os.Lchown or os.Chmod,
return an os.PathError which already contains the operation
and the file name, so there is no need to add them one more time.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-10-29 02:06:55 -07:00 committed by Giuseppe Scrivano
parent fa9f65d202
commit 3a1bcb0e4b
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
1 changed files with 2 additions and 2 deletions

View File

@ -55,12 +55,12 @@ func platformLChown(path string, info os.FileInfo, toHost, toContainer *idtools.
// Make the change.
if err := os.Lchown(path, uid, gid); err != nil {
return fmt.Errorf("%s: chown(%q): %v", os.Args[0], path, err)
return fmt.Errorf("%s: %v", os.Args[0], err)
}
// Restore the SUID and SGID bits if they were originally set.
if (info.Mode()&os.ModeSymlink == 0) && info.Mode()&(os.ModeSetuid|os.ModeSetgid) != 0 {
if err := os.Chmod(path, info.Mode()); err != nil {
return fmt.Errorf("%s: chmod(%q): %v", os.Args[0], path, err)
return fmt.Errorf("%s: %v", os.Args[0], err)
}
}
if cap != nil {