mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-20 01:01:20 +00:00
fix(agent): detect rootless Docker/Podman sockets for other users (#1200)
When the agent runs as root, os.Getuid() returns 0 so it only probes /run/user/0/docker.sock. Rootless Docker installs live at /run/user/1000/docker.sock (or similar). Glob /run/user/*/docker.sock and /run/user/*/podman/podman.sock to discover sockets for all users.
This commit is contained in:
parent
10872c8ca8
commit
0493fb78bf
1 changed files with 35 additions and 0 deletions
|
|
@ -441,6 +441,18 @@ func buildRuntimeCandidates(preference RuntimeKind) []runtimeCandidate {
|
|||
label: "podman rootless socket",
|
||||
})
|
||||
|
||||
// Discover rootless Podman sockets for other users (e.g. agent runs as root
|
||||
// but Podman rootless is installed for uid 1000)
|
||||
if matches, err := filepath.Glob("/run/user/*/podman/podman.sock"); err == nil {
|
||||
for _, match := range matches {
|
||||
sockURI := "unix://" + match
|
||||
add(runtimeCandidate{
|
||||
host: sockURI,
|
||||
label: fmt.Sprintf("podman rootless socket (%s)", match),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
add(runtimeCandidate{
|
||||
host: "unix:///run/podman/podman.sock",
|
||||
label: "podman system socket",
|
||||
|
|
@ -489,6 +501,17 @@ func buildRuntimeCandidates(preference RuntimeKind) []runtimeCandidate {
|
|||
label: "podman rootless socket",
|
||||
})
|
||||
|
||||
// Discover rootless Podman sockets for other users
|
||||
if matches, err := filepath.Glob("/run/user/*/podman/podman.sock"); err == nil {
|
||||
for _, match := range matches {
|
||||
sockURI := "unix://" + match
|
||||
add(runtimeCandidate{
|
||||
host: sockURI,
|
||||
label: fmt.Sprintf("podman rootless socket (%s)", match),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
add(runtimeCandidate{
|
||||
host: "unix:///run/podman/podman.sock",
|
||||
label: "podman system socket",
|
||||
|
|
@ -509,6 +532,18 @@ func buildRuntimeCandidates(preference RuntimeKind) []runtimeCandidate {
|
|||
label: "docker rootless socket",
|
||||
})
|
||||
|
||||
// Discover rootless Docker sockets for other users (e.g. agent runs as root
|
||||
// but Docker rootless is installed for uid 1000)
|
||||
if matches, err := filepath.Glob("/run/user/*/docker.sock"); err == nil {
|
||||
for _, match := range matches {
|
||||
sockURI := "unix://" + match
|
||||
add(runtimeCandidate{
|
||||
host: sockURI,
|
||||
label: fmt.Sprintf("docker rootless socket (%s)", match),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// macOS Docker Desktop socket
|
||||
if home := os.Getenv("HOME"); home != "" {
|
||||
add(runtimeCandidate{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue