Skip to content

Commit

Permalink
exec: Change MountFS to only relabel dirs that didnt exist
Browse files Browse the repository at this point in the history
This PR introduces a new change to how ignition mounts filesystems,
Now when file systems are being mounted ignition will relabel directories
if they did not exist previously.
Whereas before file systems could be relabelled if they did/didnt exist previously
Fix #1452
  • Loading branch information
Adam0Brien committed Jun 28, 2023
1 parent 153df40 commit 6e46d9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Starting with this release, ignition-validate binaries are signed with the
- Clarify documentation of `passwordHash` fields
- Correctly document Tang `advertisement` field as optional
- Fix failure disabling nonexistent unit with systemd ≥ 252
- Don't relabel a mount point that already exists

### Test changes

Expand Down
20 changes: 8 additions & 12 deletions internal/exec/stages/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,25 @@ func (s stage) mountFs(fs types.Filesystem) error {
return err
}

var firstMissing string
if distro.SelinuxRelabel() {
var err error
firstMissing, err = util.FindFirstMissingPathComponent(path)
if _, err := os.Stat(path); err != nil && os.IsNotExist(err) {
firstMissing, err := util.FindFirstMissingPathComponent(path)
if err != nil {
return err
}
}

if _, err := os.Stat(path); err != nil && os.IsNotExist(err) {
// Record created directories for use by the files stage.
// NotateMkdirAll() is relative to the DestDir.
if err := s.NotateMkdirAll(relpath, 0755); err != nil {
return err
}
} else if err != nil {
return err
}

if distro.SelinuxRelabel() {
if err := s.RelabelFiles([]string{firstMissing}); err != nil {
return err
if distro.SelinuxRelabel() {
if err := s.RelabelFiles([]string{firstMissing}); err != nil {
return err
}
}
} else if err != nil {
return err
}

args := translateOptionSliceToString(fs.MountOptions, ",")
Expand Down

0 comments on commit 6e46d9a

Please sign in to comment.