Skip to content

Commit

Permalink
rpm: fix error handling in WalkFunc
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <[email protected]>
  • Loading branch information
hdonnay committed Oct 26, 2020
1 parent b194f51 commit 04cb53c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rpm/packagescanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,15 @@ func (ps *Scanner) Scan(ctx context.Context, layer *claircore.Layer) ([]*clairco
// Need a big closure in this defer because of permissions being preserved.
defer func() {
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
// If a directory isn't o+w, fix it.
// If err != nil, then info will be nil.
if err != nil {
log.Warn().
Str("path", path).
Err(err).
Msg("error walking files")
return nil
}
// If a directory isn't u+w, fix it.
if m := info.Mode(); info.IsDir() && m&0200 == 0 {
return os.Chmod(path, m|0200)
}
Expand Down

0 comments on commit 04cb53c

Please sign in to comment.