Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/exec/stages/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (creator) Name() string {

type stage struct {
util.Util
toRelabel []string
toRelabel map[string]struct{}
}

func (stage) Name() string {
Expand Down Expand Up @@ -130,9 +130,9 @@ func (s *stage) checkRelabeling() error {
return nil
}

// initialize to non-nil (whereas a nil slice means not to append, even
// initialize to non-nil (whereas a nil map means not to append, even
// though they're functionally equivalent)
s.toRelabel = []string{}
s.toRelabel = make(map[string]struct{})
return nil
}

Expand All @@ -145,7 +145,7 @@ func (s *stage) relabeling() bool {
func (s *stage) relabel(paths ...string) {
if s.toRelabel != nil {
for _, path := range paths {
s.toRelabel = append(s.toRelabel, filepath.Join(s.DestDir, path))
s.toRelabel[filepath.Join(s.DestDir, path)] = struct{}{}
}
}
}
Expand All @@ -163,5 +163,9 @@ func (s *stage) relabelFiles() error {
// loaded and hence no MAC enforced, and (2) we'd still need after-the-fact
// labeling for files created by processes we call out to, like `useradd`.

return s.RelabelFiles(s.toRelabel)
keys := make([]string, 0, len(s.toRelabel))
for key := range s.toRelabel {
keys = append(keys, key)
}
return s.RelabelFiles(keys)
}