| 166 | } |
| 167 | |
| 168 | fn podman_socket_candidates_from_env( |
| 169 | socket: Option<PathBuf>, |
| 170 | runtime_dir: Option<PathBuf>, |
| 171 | home: Option<PathBuf>, |
| 172 | ) -> Vec<PathBuf> { |
| 173 | let mut candidates = Vec::new(); |
| 174 | |
| 175 | if let Some(path) = socket { |
| 176 | candidates.push(path); |
| 177 | } |
| 178 | |
| 179 | if let Some(runtime_dir) = runtime_dir { |
| 180 | candidates.push(runtime_dir.join("podman/podman.sock")); |
| 181 | } |
| 182 | |
| 183 | #[cfg(target_os = "linux")] |
| 184 | { |
| 185 | candidates.push(PathBuf::from(format!( |
| 186 | "/run/user/{}/podman/podman.sock", |
| 187 | current_uid() |
| 188 | ))); |
| 189 | } |
| 190 | |
| 191 | if let Some(home) = home { |
| 192 | candidates.push(home.join(".local/share/containers/podman/machine/podman.sock")); |
| 193 | } |
| 194 | |
| 195 | candidates |
| 196 | } |
| 197 | |
| 198 | fn is_docker_available() -> bool { |
| 199 | is_binary_available("docker") || docker_socket_available() |