From 5d76a2ef43e8d9f69e68130210495ff81eb71c83 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 14 Apr 2025 12:30:24 +0200 Subject: [PATCH] types: Always apply rootless path defaults When running as non-root, the code previously checked if usePerUserStorage() before applying default paths for RunRoot and GraphRoot if they were missing from the configuration file. This check prevented defaults from being applied if the STORAGE_DRIVER environment variable was set. Signed-off-by: Giuseppe Scrivano --- types/options.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/types/options.go b/types/options.go index 1255a0290..451a3f6de 100644 --- a/types/options.go +++ b/types/options.go @@ -160,19 +160,17 @@ func loadStoreOptionsFromConfFile(storageConf string) (StoreOptions, error) { defaultRootlessGraphRoot = storageOpts.GraphRoot storageOpts = StoreOptions{} reloadConfigurationFileIfNeeded(storageConf, &storageOpts) - if usePerUserStorage() { - // If the file did not specify a graphroot or runroot, - // set sane defaults so we don't try and use root-owned - // directories - if storageOpts.RunRoot == "" { - storageOpts.RunRoot = defaultRootlessRunRoot - } - if storageOpts.GraphRoot == "" { - if storageOpts.RootlessStoragePath != "" { - storageOpts.GraphRoot = storageOpts.RootlessStoragePath - } else { - storageOpts.GraphRoot = defaultRootlessGraphRoot - } + // If the file did not specify a graphroot or runroot, + // set sane defaults so we don't try and use root-owned + // directories + if storageOpts.RunRoot == "" { + storageOpts.RunRoot = defaultRootlessRunRoot + } + if storageOpts.GraphRoot == "" { + if storageOpts.RootlessStoragePath != "" { + storageOpts.GraphRoot = storageOpts.RootlessStoragePath + } else { + storageOpts.GraphRoot = defaultRootlessGraphRoot } } }