mirror of
https://github.com/containers/podman.git
synced 2025-05-17 23:26:08 +08:00

commit b3014c1c69d5870104aa45f7caae7af041094171 changed GetRootlessRuntimeDir() to return an empty string for root, so that its value is not exported as XDG_RUNTIME_DIR, and other programs like crun can use a better default. Now GetRootlessPauseProcessPidPath() uses homedir.GetRuntimeDir(). The homedir.GetRuntimeDir() function returns a value also when running as root so it can be used inside a nested Podman. Closes: https://github.com/containers/podman/issues/22327 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
//go:build !windows
|
|
|
|
package util
|
|
|
|
// TODO once rootless function is consolidated under libpod, we
|
|
// should work to take darwin from this
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/containers/podman/v5/pkg/rootless"
|
|
"github.com/containers/storage/pkg/homedir"
|
|
)
|
|
|
|
// GetRootlessRuntimeDir returns the runtime directory when running as non root
|
|
func GetRootlessRuntimeDir() (string, error) {
|
|
if !rootless.IsRootless() {
|
|
return "", nil
|
|
}
|
|
return homedir.GetRuntimeDir()
|
|
}
|
|
|
|
// GetRootlessConfigHomeDir returns the config home directory when running as non root
|
|
func GetRootlessConfigHomeDir() (string, error) {
|
|
return homedir.GetConfigHome()
|
|
}
|
|
|
|
// GetRootlessPauseProcessPidPath returns the path to the file that holds the pid for
|
|
// the pause process.
|
|
func GetRootlessPauseProcessPidPath() (string, error) {
|
|
runtimeDir, err := homedir.GetRuntimeDir()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
// Note this path must be kept in sync with pkg/rootless/rootless_linux.go
|
|
// We only want a single pause process per user, so we do not want to use
|
|
// the tmpdir which can be changed via --tmpdir.
|
|
return filepath.Join(runtimeDir, "libpod", "tmp", "pause.pid"), nil
|
|
}
|