Skip to content

Commit

Permalink
Handling multiple relabelling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemric committed Mar 3, 2022
1 parent d554570 commit dd1bc49
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 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 @@ -132,7 +132,7 @@ func (s *stage) checkRelabeling() error {

// initialize to non-nil (whereas a nil slice 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 := []string{}
for key := range s.toRelabel {
keys = append(keys, key)
}
return s.RelabelFiles(keys)
}

0 comments on commit dd1bc49

Please sign in to comment.