| 277 | } |
| 278 | |
| 279 | func (b *Base) ContainerdAddress() string { |
| 280 | b.T.Helper() |
| 281 | if IsDocker() { |
| 282 | b.T.Skip("ContainerdAddress() should not be called for non-nerdctl target") |
| 283 | } |
| 284 | if os.Geteuid() == 0 { |
| 285 | return defaults.DefaultAddress |
| 286 | } |
| 287 | xdr, err := rootlessutil.XDGRuntimeDir() |
| 288 | if err != nil { |
| 289 | b.T.Log(err) |
| 290 | xdr = fmt.Sprintf("/run/user/%d", os.Geteuid()) |
| 291 | } |
| 292 | pidFile := filepath.Join(xdr, "containerd-rootless", "child_pid") |
| 293 | pidB, err := filesystem.ReadFile(pidFile) |
| 294 | if err != nil { |
| 295 | b.T.Fatal(err) |
| 296 | } |
| 297 | pidS := strings.TrimSpace(string(pidB)) |
| 298 | return filepath.Join("/proc", pidS, "root", defaults.DefaultAddress) |
| 299 | } |
| 300 | |
| 301 | func (b *Base) EnsureContainerStarted(con string) { |
| 302 | b.T.Helper() |