diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-08-06 17:42:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 17:42:54 +0200 |
commit | 37b40e9acdae6bfa79d53928361540754417cdc6 (patch) | |
tree | 77a8f189ed503f5c75efa27a4702ea8b4e004bb0 /cmd/podman | |
parent | 3bffe77f824772b841080ea463324f5ae5c833d4 (diff) | |
parent | 5779e898090b7182ad9307e3ddf1087ac913c770 (diff) | |
download | podman-37b40e9acdae6bfa79d53928361540754417cdc6.tar.gz podman-37b40e9acdae6bfa79d53928361540754417cdc6.tar.bz2 podman-37b40e9acdae6bfa79d53928361540754417cdc6.zip |
Merge pull request #3466 from TomSweeneyRedHat/dev/tsweeney/myhome
Touch up XDG, add rootless links
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/main.go | 2 | ||||
-rw-r--r-- | cmd/podman/main_local.go | 1 | ||||
-rw-r--r-- | cmd/podman/main_remote.go | 17 | ||||
-rw-r--r-- | cmd/podman/remoteclientconfig/config_linux.go | 9 |
4 files changed, 23 insertions, 6 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go index 1b54c9458..dc44a9110 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -101,7 +101,7 @@ func initConfig() { } func before(cmd *cobra.Command, args []string) error { - if err := libpod.SetXdgRuntimeDir(); err != nil { + if err := libpod.SetXdgDirs(); err != nil { logrus.Errorf(err.Error()) os.Exit(1) } diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go index 5c8b2b1ff..0f43e0b88 100644 --- a/cmd/podman/main_local.go +++ b/cmd/podman/main_local.go @@ -122,6 +122,7 @@ func setupRootless(cmd *cobra.Command, args []string) error { if os.Geteuid() == 0 || cmd == _searchCommand || cmd == _versionCommand || cmd == _mountCommand || cmd == _migrateCommand || strings.HasPrefix(cmd.Use, "help") { return nil } + podmanCmd := cliconfig.PodmanCommand{ Command: cmd, InputArgs: args, diff --git a/cmd/podman/main_remote.go b/cmd/podman/main_remote.go index ecbb44d5a..d534f5bcb 100644 --- a/cmd/podman/main_remote.go +++ b/cmd/podman/main_remote.go @@ -8,7 +8,8 @@ import ( "os/user" "path/filepath" - "github.com/docker/docker/pkg/homedir" + "github.com/containers/libpod/pkg/util" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -31,9 +32,19 @@ func init() { } func setSyslog() error { + var err error + cfgHomeDir := os.Getenv("XDG_CONFIG_HOME") + if cfgHomeDir == "" { + if cfgHomeDir, err = util.GetRootlessConfigHomeDir(); err != nil { + return err + } + if err = os.Setenv("XDG_CONFIG_HOME", cfgHomeDir); err != nil { + return errors.Wrapf(err, "cannot set XDG_CONFIG_HOME") + } + } + path := filepath.Join(cfgHomeDir, "containers") + // Log to file if not using syslog - homeDir := homedir.Get() - path := filepath.Join(homeDir, ".config", "containers") if _, err := os.Stat(path); os.IsNotExist(err) { if err := os.MkdirAll(path, 0750); err != nil { diff --git a/cmd/podman/remoteclientconfig/config_linux.go b/cmd/podman/remoteclientconfig/config_linux.go index b94941381..5d27f19f2 100644 --- a/cmd/podman/remoteclientconfig/config_linux.go +++ b/cmd/podman/remoteclientconfig/config_linux.go @@ -1,12 +1,17 @@ package remoteclientconfig import ( + "os" "path/filepath" "github.com/docker/docker/pkg/homedir" ) func getConfigFilePath() string { - homeDir := homedir.Get() - return filepath.Join(homeDir, ".config", "containers", remoteConfigFileName) + path := os.Getenv("XDG_CONFIG_HOME") + if path == "" { + homeDir := homedir.Get() + path = filepath.Join(homeDir, ".config") + } + return filepath.Join(path, "containers", remoteConfigFileName) } |