drivers/platformLChown: rm os.Lstat call
This function is already called with the result from os.Lstat(), so there's no need to do it again. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
1e8bf20d6b
commit
be28a551a5
|
|
@ -48,10 +48,6 @@ func platformLChown(path string, info os.FileInfo, toHost, toContainer *idtools.
|
|||
uid, gid = mappedPair.UID, mappedPair.GID
|
||||
}
|
||||
if uid != int(st.Uid) || gid != int(st.Gid) {
|
||||
stat, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: lstat(%q): %v", os.Args[0], path, err)
|
||||
}
|
||||
cap, err := system.Lgetxattr(path, "security.capability")
|
||||
if err != nil && err != system.ErrNotSupportedPlatform {
|
||||
return fmt.Errorf("%s: Lgetxattr(%q): %v", os.Args[0], path, err)
|
||||
|
|
@ -62,8 +58,8 @@ func platformLChown(path string, info os.FileInfo, toHost, toContainer *idtools.
|
|||
return fmt.Errorf("%s: chown(%q): %v", os.Args[0], path, err)
|
||||
}
|
||||
// Restore the SUID and SGID bits if they were originally set.
|
||||
if (stat.Mode()&os.ModeSymlink == 0) && stat.Mode()&(os.ModeSetuid|os.ModeSetgid) != 0 {
|
||||
if err := os.Chmod(path, stat.Mode()); err != nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue