()
| 25 | ) |
| 26 | |
| 27 | func XDGRuntimeDir() (string, error) { |
| 28 | if xrd := os.Getenv("XDG_RUNTIME_DIR"); xrd != "" { |
| 29 | return xrd, nil |
| 30 | } |
| 31 | // Fall back to "/run/user/<euid>". |
| 32 | // Note that We cannot rely on os.Geteuid() because we might be inside UserNS. |
| 33 | if parentEuid, ok := os.LookupEnv("ROOTLESSKIT_PARENT_EUID"); ok { |
| 34 | if _, err := strconv.Atoi(parentEuid); err != nil { |
| 35 | return "", fmt.Errorf("invalid ROOTLESSKIT_PARENT_EUID environment variable value %q: %w", parentEuid, err) |
| 36 | } |
| 37 | return "/run/user/" + parentEuid, nil |
| 38 | } |
| 39 | return "", errors.New("environment variable XDG_RUNTIME_DIR is not set, see https://rootlesscontaine.rs/getting-started/common/login/") |
| 40 | } |
| 41 | |
| 42 | func XDGConfigHome() (string, error) { |
| 43 | if xch := os.Getenv("XDG_CONFIG_HOME"); xch != "" { |
no outgoing calls
no test coverage detected
searching dependent graphs…