Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster: improve SELinux compatibility #2501

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions pkg/cluster/spec/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ func (i *BaseInstance) InitConfig(ctx context.Context, e ctxt.Executor, opt Glob
return errors.Annotatef(err, "execute: %s", cmd)
}

// restorecon restores SELinux Contexts
// Check with: ls -lZ /path/to/file
// If the context is wrong systemctl will complain about a missing unit file
// Note that we won't check for errors here because:
// - We don't support SELinux in Enforcing mode
// - restorecon might not be available (Ubuntu doesn't install SELinux tools by default)
cmd = fmt.Sprintf("restorecon %s%s-%d.service", systemdDir, comp, port)
e.Execute(ctx, cmd, sudo) //nolint

// doesn't work
if _, err := i.setTLSConfig(ctx, false, nil, paths); err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions pkg/cluster/spec/tispark.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ func (i *TiSparkMasterInstance) InitConfig(
return errors.Annotatef(err, "execute: %s", cmd)
}

// restorecon restores SELinux Contexts
// Check with: ls -lZ /path/to/file
// If the context is wrong systemctl will complain about a missing unit file
// Note that we won't check for errors here because:
// - We don't support SELinux in Enforcing mode
// - restorecon might not be available (Ubuntu doesn't install SELinux tools by default)
cmd = fmt.Sprintf("restorecon %s%s-%d.service", systemdDir, comp, port)
e.Execute(ctx, cmd, sudo) //nolint

// transfer default config
pdList := topo.GetPDList()
masterList := make([]string, 0)
Expand Down
10 changes: 10 additions & 0 deletions pkg/cluster/task/monitored_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ func (m *MonitoredConfig) syncMonitoredSystemConfig(ctx context.Context, exec ct
}
return err
}

// restorecon restores SELinux Contexts
// Check with: ls -lZ /path/to/file
// If the context is wrong systemctl will complain about a missing unit file
// Note that we won't check for errors here because:
// - We don't support SELinux in Enforcing mode
// - restorecon might not be available (Ubuntu doesn't install SELinux tools by default)
cmd := fmt.Sprintf("restorecon %s%s-%d.service", systemdDir, comp, port)
exec.Execute(ctx, cmd, sudo) //nolint

return nil
}

Expand Down
Loading