mirror of
https://github.com/containers/podman.git
synced 2025-05-17 23:26:08 +08:00
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>
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/libpod/libpod/define"
|
"github.com/containers/libpod/libpod/define"
|
||||||
"github.com/containers/libpod/pkg/rootless"
|
"github.com/containers/libpod/pkg/rootless"
|
||||||
|
"github.com/containers/libpod/pkg/util"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -87,12 +88,22 @@ func (r *Runtime) Reset(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
prevError = err
|
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 {
|
if prevError != nil {
|
||||||
logrus.Error(prevError)
|
logrus.Error(prevError)
|
||||||
}
|
}
|
||||||
prevError = err
|
prevError = err
|
||||||
}
|
}
|
||||||
|
|
||||||
if rootless.IsRootless() {
|
if rootless.IsRootless() {
|
||||||
configPath := filepath.Join(os.Getenv("HOME"), ".config/containers")
|
configPath := filepath.Join(os.Getenv("HOME"), ".config/containers")
|
||||||
if err := os.RemoveAll(configPath); err != nil {
|
if err := os.RemoveAll(configPath); err != nil {
|
||||||
|
Reference in New Issue
Block a user