File: utils_supported.go

package info (click to toggle)
podman 5.7.0%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,824 kB
  • sloc: sh: 4,700; python: 2,798; perl: 1,885; ansic: 1,484; makefile: 977; ruby: 42; csh: 8
file content (39 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//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"
	"go.podman.io/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
}