Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/containers.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ a TOML format that can be easily modified and versioned.

Container engines read the __/usr/share/containers/containers.conf__,
__/etc/containers/containers.conf__, and __/etc/containers/containers.conf.d/\*.conf__
for global configuration that effects all users.
for global configuration that affects all users.
For global configuration that only affects rootless users use __/etc/containers/containers.rootless.conf__,
__/etc/containers/containers.rootless.d/\*.conf__ and __/etc/containers/containers.rootless.d/\$UID/\*.conf__. The UID is the user's uid which podman runs under so it can be used to specify a certain config for only a single user without having to put the config into the user's home directory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should split $UID out into a separate sentence. containers.rootless.conf and containers.rootless.conf.d are global configuration. the $UID bit is not, and should be discussed separately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh I read globally different here. Globally to me == system directories in this context.

How should this be worded instead then? tbf I think the entire paragraph is just pointless noise and hard to parse. I think just listing each location in the right order like I have in the design docs is likely the most logical.

For user specific configuration it reads __\$XDG_CONFIG_HOME/containers/containers.conf__ and
__\$XDG_CONFIG_HOME/containers/containers.conf.d/\*.conf__ files. When `$XDG_CONFIG_HOME` is not set it falls back to using `$HOME/.config` instead.

Expand Down
21 changes: 21 additions & 0 deletions pkg/config/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"io/fs"
"os"
"path/filepath"
"strconv"
"strings"
"sync"

"github.com/BurntSushi/toml"
"github.com/containers/storage/pkg/fileutils"
"github.com/containers/storage/pkg/unshare"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -172,6 +174,25 @@ func systemConfigs() (configs []string, finalErr error) {
return nil, err
}

// add rootless specific file overwrites in a global system dir
// /etc/containers/containers.rootless.conf
// /etc/containers/containers.rootless.conf.d/
// /etc/containers/containers.rootless.conf.d/<UID>/
uid := unshare.GetRootlessUID()
if uid > 0 {
rootlessOverwritePath := filepath.Join(filepath.Dir(path), "containers.rootless.conf")
configs = append(configs, rootlessOverwritePath)
rootlessOverwritePathD := rootlessOverwritePath + ".d"
configs, err = addConfigs(rootlessOverwritePathD, configs)
if err != nil {
return nil, err
}
configs, err = addConfigs(filepath.Join(rootlessOverwritePathD, strconv.Itoa(uid)), configs)
if err != nil {
return nil, err
}
}

path, err = userConfigPath()
if err != nil {
return nil, err
Expand Down