From 56115d5e5be9dbed4bc7b0ab2a85f379f0b85cc3 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 9 Nov 2022 11:30:38 +0100 Subject: [PATCH] libpod: Move the creation of TmpDir to an earlier time Later changes will need to access it earlier, so move its creation to just after the creation of StaticDir. Note: For whatever reason this we created twice before, but we now only do it once. Signed-off-by: Alexander Larsson --- libpod/runtime.go | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) 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)