summaryrefslogtreecommitdiff
path: root/libpod/reset.go
diff options
context:
space:
mode:
authorQi Wang <qiwan@redhat.com>2020-02-18 15:45:48 -0500
committerQi Wang <qiwan@redhat.com>2020-03-05 09:21:41 -0500
commitd4540e07c73ed5576f42f653781e1af19d8b1f0d (patch)
tree2602b0cd10b602b7f5a7c240f646972e6d2743c3 /libpod/reset.go
parentd5f5b2e8becfb3a6e13d8b3248e26f3fbe22bdb4 (diff)
downloadpodman-d4540e07c73ed5576f42f653781e1af19d8b1f0d.tar.gz
podman-d4540e07c73ed5576f42f653781e1af19d8b1f0d.tar.bz2
podman-d4540e07c73ed5576f42f653781e1af19d8b1f0d.zip
Fix bug podman reset to not remove $XDG_RUNTIME_DIR
In some older systems we point the temporary directory to /run/user/1000 which leads podman system reset to clear unrelated files under XDG_RUNTIME_DIR. This patch only removes files created by podman if TmpDir is the same as the XDG_RUNTIME_DIR. Signed-off-by: Qi Wang <qiwan@redhat.com>
Diffstat (limited to 'libpod/reset.go')
-rw-r--r--libpod/reset.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/libpod/reset.go b/libpod/reset.go
index a35b476a4..ae0a0cde9 100644
--- a/libpod/reset.go
+++ b/libpod/reset.go
@@ -7,6 +7,7 @@ import (
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/rootless"
+ "github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -87,12 +88,22 @@ func (r *Runtime) Reset(ctx context.Context) error {
}
prevError = err
}
- if err := os.RemoveAll(r.config.TmpDir); err != nil {
+
+ runtimeDir, err := util.GetRuntimeDir()
+ if err != nil {
+ return err
+ }
+ tempDir := r.config.TmpDir
+ if r.config.TmpDir == runtimeDir {
+ tempDir = filepath.Join(r.config.TmpDir, "containers")
+ }
+ if err := os.RemoveAll(tempDir); err != nil {
if prevError != nil {
logrus.Error(prevError)
}
prevError = err
}
+
if rootless.IsRootless() {
configPath := filepath.Join(os.Getenv("HOME"), ".config/containers")
if err := os.RemoveAll(configPath); err != nil {