Skip to content

Commit

Permalink
merge #499 into opencontainers/umoci:main
Browse files Browse the repository at this point in the history
Serge Hallyn (1):
  Do not chmod +r if we don't need to

LGTMs: cyphar
  • Loading branch information
cyphar committed Sep 20, 2023
2 parents fbc1339 + b73c9b4 commit 7dc114a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/unpriv/unpriv.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ func Open(path string) (*os.File, error) {
return errors.Wrap(err, "lstat file")
}

// Add +r permissions to the file.
if err := os.Chmod(path, fi.Mode()|0400); err != nil {
return errors.Wrap(err, "chmod +r")
if fi.Mode()&0400 != 0400 {
// Add +r permissions to the file.
if err := os.Chmod(path, fi.Mode()|0400); err != nil {
return errors.Wrap(err, "chmod +r")
}
defer fiRestore(path, fi)
}
defer fiRestore(path, fi)

// Open the damn thing.
fh, err = os.Open(path)
Expand Down

0 comments on commit 7dc114a

Please sign in to comment.