summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/main.go2
-rw-r--r--cmd/podman/main_local.go1
-rw-r--r--cmd/podman/main_remote.go17
-rw-r--r--cmd/podman/remoteclientconfig/config_linux.go9
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)
}