osbuild2: selinux stage - introduce force_autorelabel option

This was added in osbuild: https://github.com/osbuild/osbuild/pull/875

Introduce the same option in composer and make it optional by specifying
it as a pointer to bool value. It would work the same even if it was
there every time, but as it should be an edge case, don't use it
everywhere. Also osbuild doesn't require it to be present, so it seems
like the right thing to do.
This commit is contained in:
Martin Sehnoutka 2021-11-18 14:21:13 +01:00 committed by Achilleas Koutsou
parent 841dd233c7
commit 04f69db2c0
2 changed files with 15 additions and 2 deletions

View file

@ -5,8 +5,9 @@ package osbuild2
// A file contexts configuration file is sepcified that describes
// the filesystem labels to apply to the image.
type SELinuxStageOptions struct {
FileContexts string `json:"file_contexts"`
Labels map[string]string `json:"labels,omitempty"`
FileContexts string `json:"file_contexts"`
Labels map[string]string `json:"labels,omitempty"`
ForceAutorelabel *bool `json:"force_autorelabel,omitempty"`
}
func (SELinuxStageOptions) isStageOptions() {}

View file

@ -452,6 +452,18 @@ func TestStage_UnmarshalJSON(t *testing.T) {
data: []byte(`{"type":"org.osbuild.selinux","options":{"file_contexts":""}}`),
},
},
{
name: "selinux-force_autorelabel",
fields: fields{
Type: "org.osbuild.selinux",
Options: &SELinuxStageOptions{
ForceAutorelabel: common.BoolToPtr(true),
},
},
args: args{
data: []byte(`{"type":"org.osbuild.selinux","options":{"file_contexts":"","force_autorelabel":true}}`),
},
},
{
name: "selinux.config-empty",
fields: fields{