diff --git a/libpod/runtime.go b/libpod/runtime.go index d80add032b..5534e6ab5f 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -322,6 +322,11 @@ func makeRuntime(runtime *Runtime) (retErr error) { } } + // Create the TmpDir if needed + if err := os.MkdirAll(runtime.config.Engine.TmpDir, 0751); err != nil { + return fmt.Errorf("creating runtime temporary files directory: %w", err) + } + // Set up the state. // // TODO - if we further break out the state implementation into @@ -458,14 +463,6 @@ func makeRuntime(runtime *Runtime) (retErr error) { } runtime.imageContext.SignaturePolicyPath = runtime.config.Engine.SignaturePolicyPath - // Create the tmpDir - if err := os.MkdirAll(runtime.config.Engine.TmpDir, 0751); err != nil { - // The directory is allowed to exist - if !errors.Is(err, os.ErrExist) { - return fmt.Errorf("creating tmpdir: %w", err) - } - } - // Get us at least one working OCI runtime. runtime.ociRuntimes = make(map[string]OCIRuntime) @@ -516,14 +513,6 @@ func makeRuntime(runtime *Runtime) (retErr error) { return fmt.Errorf("no default OCI runtime was configured: %w", define.ErrInvalidArg) } - // Make the per-boot files directory if it does not exist - if err := os.MkdirAll(runtime.config.Engine.TmpDir, 0755); err != nil { - // The directory is allowed to exist - if !errors.Is(err, os.ErrExist) { - return fmt.Errorf("creating runtime temporary files directory: %w", err) - } - } - // the store is only set up when we are in the userns so we do the same for the network interface if !needsUserns { netBackend, netInterface, err := network.NetworkBackend(runtime.store, runtime.config, runtime.syslog)