(root string, idMap userns.IDMap)
| 125 | } |
| 126 | |
| 127 | func chown(root string, idMap userns.IDMap) filepath.WalkFunc { |
| 128 | return func(path string, info os.FileInfo, err error) error { |
| 129 | if err != nil { |
| 130 | return err |
| 131 | } |
| 132 | stat := info.Sys().(*syscall.Stat_t) |
| 133 | h, cerr := idMap.ToHost(userns.User{Uid: stat.Uid, Gid: stat.Gid}) |
| 134 | if cerr != nil { |
| 135 | return cerr |
| 136 | } |
| 137 | // be sure the lchown the path as to not de-reference the symlink to a host file |
| 138 | if cerr = os.Lchown(path, int(h.Uid), int(h.Gid)); cerr != nil { |
| 139 | return cerr |
| 140 | } |
| 141 | // we must retain special permissions such as setuid, setgid and sticky bits |
| 142 | if mode := info.Mode(); mode&os.ModeSymlink == 0 && mode&(os.ModeSetuid|os.ModeSetgid|os.ModeSticky) != 0 { |
| 143 | return os.Chmod(path, mode) |
| 144 | } |
| 145 | return nil |
| 146 | } |
| 147 | } |
no test coverage detected
searching dependent graphs…