Skip to content

Commit

Permalink
options: reject empty runroot or graphroot
Browse files Browse the repository at this point in the history
make sure that the runroot and graphroot are not empty otherwise we will
end up using an empty directory as path prefix and create files in the
current directory.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Feb 16, 2023
1 parent 0d8301b commit 9ebdbd9
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,24 @@ func defaultStoreOptionsIsolated(rootless bool, rootlessUID int, storageConf str
}
}
}
if storageOpts.RunRoot != "" {
runRoot, err := expandEnvPath(storageOpts.RunRoot, rootlessUID)
if err != nil {
return storageOpts, err
}
storageOpts.RunRoot = runRoot
if storageOpts.RunRoot == "" {
return storageOpts, fmt.Errorf("runroot must be set")
}
if storageOpts.GraphRoot != "" {
graphRoot, err := expandEnvPath(storageOpts.GraphRoot, rootlessUID)
if err != nil {
return storageOpts, err
}
storageOpts.GraphRoot = graphRoot
runRoot, err := expandEnvPath(storageOpts.RunRoot, rootlessUID)
if err != nil {
return storageOpts, err
}
storageOpts.RunRoot = runRoot

if storageOpts.GraphRoot == "" {
return storageOpts, fmt.Errorf("graphroot must be set")
}
graphRoot, err := expandEnvPath(storageOpts.GraphRoot, rootlessUID)
if err != nil {
return storageOpts, err
}
storageOpts.GraphRoot = graphRoot

if storageOpts.RootlessStoragePath != "" {
storagePath, err := expandEnvPath(storageOpts.RootlessStoragePath, rootlessUID)
if err != nil {
Expand Down

0 comments on commit 9ebdbd9

Please sign in to comment.