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

[Backport release-1.28] Fix "executable in PATH" sysprobe #3643

Merged
merged 1 commit into from
Oct 26, 2023
Merged
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
4 changes: 3 additions & 1 deletion docs/raspberry-pi4.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ Operating system: Linux (pass)
Linux kernel release: 5.15.0-1013-raspi (pass)
Max. file descriptors per process: current: 1024 / max: 1048576 (warning: < 65536)
AppArmor: unavailable (pass)
Executable in path: modprobe: /usr/sbin/modprobe (pass)
Executable in PATH: modprobe: /usr/sbin/modprobe (pass)
Executable in PATH: mount: /usr/bin/mount (pass)
Executable in PATH: umount: /usr/bin/umount (pass)
/proc file system: mounted (0x9fa0) (pass)
Control Groups: version 2 (pass)
cgroup controller "cpu": available (pass)
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/sysinfo/host_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ func (s *K0sSysinfoSpec) addHostSpecificProbes(p probes.Probes) {
linux.AssertAppArmor()

if s.WorkerRoleEnabled {
probes.AssertExecutablesInPath(linux, "modprobe", "mount", "umount")
probes.AssertExecutableInPath(linux, "modprobe")
probes.AssertExecutableInPath(linux, "mount")
probes.AssertExecutableInPath(linux, "umount")
linux.RequireProcFS()
addCgroups(linux)
}
Expand Down
22 changes: 10 additions & 12 deletions internal/pkg/sysinfo/probes/executables.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ import (
"os/exec"
)

func AssertExecutablesInPath(p Probes, executables ...string) {
for _, executable := range executables {
p.Set(fmt.Sprintf("executableInPath:%s", executable), func(path ProbePath, _ Probe) Probe {
return ProbeFn(func(r Reporter) error {
desc := NewProbeDesc(fmt.Sprintf("Executable in path: %s", executable), path)
path, err := exec.LookPath(executable)
if err != nil {
return r.Warn(desc, ErrorProp(err), "")
}
func AssertExecutableInPath(p Probes, executable string) {
p.Set(fmt.Sprintf("executableInPath:%s", executable), func(path ProbePath, _ Probe) Probe {
return ProbeFn(func(r Reporter) error {
desc := NewProbeDesc(fmt.Sprintf("Executable in PATH: %s", executable), path)
path, err := exec.LookPath(executable)
if err != nil {
return r.Warn(desc, ErrorProp(err), "")
}

return r.Pass(desc, StringProp(path))
})
return r.Pass(desc, StringProp(path))
})
}
})
}
Loading