Skip to content

Commit

Permalink
isChownNeeded bad when only user/group (!both) set
Browse files Browse the repository at this point in the history
isChownNeeded returned the wrong result if either (exclusive) user or
group were set but not the other. It uses a guard value but only
compares both at the start and doesn't take this into account on the
final comparison which compares both against the current values.

IE. it always returns true in these cases as the guard value is never
going to be the same as an real file value.
  • Loading branch information
eikenb committed Oct 4, 2022
1 parent f3e8f8a commit 0bb9fc2
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 117 deletions.
8 changes: 8 additions & 0 deletions renderer/file_ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ func isChownNeeded(path string, uid, gid int) (bool, error) {
if err != nil {
return false, err
}

switch {
case uid == -1:
currUid = -1
case gid == -1:
currGid = -1
}

return uid != currUid || gid != currGid, nil
}

Expand Down
Loading

0 comments on commit 0bb9fc2

Please sign in to comment.