Skip to content

Commit

Permalink
Merge pull request uyuni-project#441 from mbussolotto/selinux
Browse files Browse the repository at this point in the history
restore SELinux permission after migration (bsc#1229501)
  • Loading branch information
deneb-alpha authored Sep 4, 2024
2 parents 7ea9d06 + 6858296 commit 3bff107
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mgradm/shared/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ func RunMigration(
[]string{"/var/lib/uyuni-tools/migrate.sh"}); err != nil {
return nil, utils.Errorf(err, L("cannot run uyuni migration container"))
}

//now that everything is migrated, we need to fix SELinux permission
for _, volumeMount := range utils.ServerVolumeMounts {
mountPoint, err := GetMountPoint(volumeMount.Name)
if err != nil {
return nil, utils.Errorf(err, L("cannot inspect volume %s"), volumeMount)
}
if err := utils.RunCmdStdMapping(zerolog.DebugLevel, "restorecon", "-F", "-r", "-v", mountPoint); err != nil {
return nil, utils.Errorf(err, L("cannot restore %s SELinux permissions"), mountPoint)
}
}

extractedData, err := utils.ReadInspectData[utils.InspectResult](path.Join(scriptDir, "data"))

if err != nil {
Expand Down Expand Up @@ -452,3 +464,13 @@ func CallCloudGuestRegistryAuth() error {
// silently ignore error if it is missing
return nil
}

// GetMountPoint return folder where a given volume is mounted.
func GetMountPoint(volumeName string) (string, error) {
args := []string{"volume", "inspect", "--format", "{{.Mountpoint}}", volumeName}
mountPoint, err := utils.RunCmdOutput(zerolog.DebugLevel, "podman", args...)
if err != nil {
return "", err
}
return strings.TrimSuffix(string(mountPoint), "\n"), nil
}
1 change: 1 addition & 0 deletions uyuni-tools.changes.mbussolotto.selinux
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- restore SELinux permission after migration (bsc#1229501)

0 comments on commit 3bff107

Please sign in to comment.