Add /run/containers/systemd, ${XDG_RUNTIME_DIR}/containers/systemd quadlet dirs
Fixes: https://github.com/containers/podman/issues/23363 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
c804f10686
commit
ce7dded38b
|
|
@ -109,7 +109,7 @@ func Debugf(format string, a ...interface{}) {
|
|||
// This returns the directories where we read quadlet .container and .volumes from
|
||||
// For system generators these are in /usr/share/containers/systemd (for distro files)
|
||||
// and /etc/containers/systemd (for sysadmin files).
|
||||
// For user generators these can live in /etc/containers/systemd/users, /etc/containers/systemd/users/$UID, and $XDG_CONFIG_HOME/containers/systemd
|
||||
// For user generators these can live in $XDG_RUNTIME_DIR/containers/systemd, /etc/containers/systemd/users, /etc/containers/systemd/users/$UID, and $XDG_CONFIG_HOME/containers/systemd
|
||||
func getUnitDirs(rootless bool) []string {
|
||||
// Allow overriding source dir, this is mainly for the CI tests
|
||||
unitDirsEnv := os.Getenv("QUADLET_UNIT_DIRS")
|
||||
|
|
@ -127,6 +127,11 @@ func getUnitDirs(rootless bool) []string {
|
|||
}
|
||||
|
||||
if rootless {
|
||||
runtimeDir, found := os.LookupEnv("XDG_RUNTIME_DIR")
|
||||
if found {
|
||||
dirs = appendSubPaths(dirs, path.Join(runtimeDir, "containers/systemd"), false, nil)
|
||||
}
|
||||
|
||||
configDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: %v", err)
|
||||
|
|
@ -143,6 +148,7 @@ func getUnitDirs(rootless bool) []string {
|
|||
return append(dirs, filepath.Join(quadlet.UnitDirAdmin, "users"))
|
||||
}
|
||||
|
||||
dirs = appendSubPaths(dirs, quadlet.UnitDirTemp, false, userLevelFilter)
|
||||
dirs = appendSubPaths(dirs, quadlet.UnitDirAdmin, false, userLevelFilter)
|
||||
return appendSubPaths(dirs, quadlet.UnitDirDistro, false, nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ func TestIsUnambiguousName(t *testing.T) {
|
|||
|
||||
func TestUnitDirs(t *testing.T) {
|
||||
rootDirs := []string{}
|
||||
rootDirs = appendSubPaths(rootDirs, quadlet.UnitDirTemp, false, userLevelFilter)
|
||||
rootDirs = appendSubPaths(rootDirs, quadlet.UnitDirAdmin, false, userLevelFilter)
|
||||
rootDirs = appendSubPaths(rootDirs, quadlet.UnitDirDistro, false, userLevelFilter)
|
||||
unitDirs := getUnitDirs(false)
|
||||
|
|
@ -60,6 +61,10 @@ func TestUnitDirs(t *testing.T) {
|
|||
|
||||
rootlessDirs := []string{}
|
||||
|
||||
runtimeDir, found := os.LookupEnv("XDG_RUNTIME_DIR")
|
||||
if found {
|
||||
rootlessDirs = appendSubPaths(rootlessDirs, path.Join(runtimeDir, "containers/systemd"), false, nil)
|
||||
}
|
||||
rootlessDirs = appendSubPaths(rootlessDirs, path.Join(configDir, "containers/systemd"), false, nil)
|
||||
rootlessDirs = appendSubPaths(rootlessDirs, filepath.Join(quadlet.UnitDirAdmin, "users"), true, nonNumericFilter)
|
||||
rootlessDirs = appendSubPaths(rootlessDirs, filepath.Join(quadlet.UnitDirAdmin, "users", u.Uid), true, userLevelFilter)
|
||||
|
|
|
|||
|
|
@ -10,15 +10,25 @@ podman\-systemd.unit - systemd units using Podman Quadlet
|
|||
|
||||
### Podman rootful unit search path
|
||||
|
||||
Quadlet files for the root user can be placed in the following two directories:
|
||||
Quadlet files for the root user can be placed in the following directories ordered in precedence. Meaning duplicate named quadlets found under /run take precedence over ones in /etc, as well as those in /usr:
|
||||
|
||||
* /etc/containers/systemd/
|
||||
* /usr/share/containers/systemd/
|
||||
Temporary quadlets, usually used for testing:
|
||||
|
||||
* /run/containers/systemd/
|
||||
|
||||
System administrator's defined quadlets:
|
||||
|
||||
* /etc/containers/systemd/
|
||||
|
||||
Distribution defined quadlets:
|
||||
|
||||
* /usr/share/containers/systemd/
|
||||
|
||||
### Podman rootless unit search path
|
||||
|
||||
Quadlet files for non-root users can be placed in the following directories
|
||||
|
||||
* $XDG_RUNTIME_DIR/containers/systemd/
|
||||
* $XDG_CONFIG_HOME/containers/systemd/ or ~/.config/containers/systemd/
|
||||
* /etc/containers/systemd/users/$(UID)
|
||||
* /etc/containers/systemd/users/
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ const (
|
|||
// github.com/containers/podman/v5/libpod/define.AutoUpdateLabel
|
||||
// but it is causing bloat
|
||||
autoUpdateLabel = "io.containers.autoupdate"
|
||||
// Directory for temporary Quadlet files (sysadmin owned)
|
||||
UnitDirTemp = "/run/containers/systemd"
|
||||
// Directory for global Quadlet files (sysadmin owned)
|
||||
UnitDirAdmin = "/etc/containers/systemd"
|
||||
// Directory for global Quadlet files (distro owned)
|
||||
|
|
|
|||
Loading…
Reference in New Issue