diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-09-10 13:06:22 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-09-10 13:23:52 +0200 |
commit | 8d638d502bf97f3d34d7210f63e4d758ced88dac (patch) | |
tree | b6b6555d096d9941c406cb9079ca0eb87ad6ac93 /libpod/runtime.go | |
parent | 63f6656f8fa79d7f6e01379d7ba0aa4ab3c03b37 (diff) | |
download | podman-8d638d502bf97f3d34d7210f63e4d758ced88dac.tar.gz podman-8d638d502bf97f3d34d7210f63e4d758ced88dac.tar.bz2 podman-8d638d502bf97f3d34d7210f63e4d758ced88dac.zip |
try to create the runroot before we warn that it is not writable
The rootless integration tests show the XDG_RUNTIME_DIR warning without
any reasons. Podman runs without problems in these and yet the warning
is shown. I think the problem is that we check the permission before we
create the runroot directory.
[NO TESTS NEEDED]
Fixes #11521
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 1c9c56d16..761fa08a2 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -335,8 +335,16 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) { // If user is rootless and XDG_RUNTIME_DIR is found, podman will not proceed with /tmp directory // it will try to use existing XDG_RUNTIME_DIR // if current user has no write access to XDG_RUNTIME_DIR we will fail later - if unix.Access(runtime.storageConfig.RunRoot, unix.W_OK) != nil { - logrus.Warnf("XDG_RUNTIME_DIR is pointing to a path which is not writable. Most likely podman will fail.") + if err := unix.Access(runtime.storageConfig.RunRoot, unix.W_OK); err != nil { + msg := "XDG_RUNTIME_DIR is pointing to a path which is not writable. Most likely podman will fail." + if errors.Is(err, os.ErrNotExist) { + // if dir does not exists try to create it + if err := os.MkdirAll(runtime.storageConfig.RunRoot, 0700); err != nil { + logrus.Warn(msg) + } + } else { + logrus.Warn(msg) + } } } |