-
Notifications
You must be signed in to change notification settings - Fork 269
Add rootless_storage_path directive to storage.conf
#529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,9 @@ import ( | |
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "os/user" | ||
| "path/filepath" | ||
| "regexp" | ||
| "strconv" | ||
| "strings" | ||
|
|
||
|
|
@@ -146,6 +148,7 @@ func getRootlessStorageOpts(rootlessUID int) (StoreOptions, error) { | |
| } | ||
| opts.RunRoot = rootlessRuntime | ||
| opts.GraphRoot = filepath.Join(dataDir, "containers", "storage") | ||
| opts.RootlessStoragePath = opts.GraphRoot | ||
| if path, err := exec.LookPath("fuse-overlayfs"); err == nil { | ||
| opts.GraphDriverName = "overlay" | ||
| opts.GraphDriverOptions = []string{fmt.Sprintf("overlay.mount_program=%s", path)} | ||
|
|
@@ -161,6 +164,7 @@ func getTomlStorage(storeOptions *StoreOptions) *tomlConfig { | |
| config.Storage.Driver = storeOptions.GraphDriverName | ||
| config.Storage.RunRoot = storeOptions.RunRoot | ||
| config.Storage.GraphRoot = storeOptions.GraphRoot | ||
| config.Storage.RootlessStoragePath = storeOptions.RootlessStoragePath | ||
| for _, i := range storeOptions.GraphDriverOptions { | ||
| s := strings.Split(i, "=") | ||
| if s[0] == "overlay.mount_program" { | ||
|
|
@@ -226,6 +230,25 @@ func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error) { | |
| } | ||
| if storageOpts.GraphRoot == "" { | ||
| storageOpts.GraphRoot = defaultRootlessGraphRoot | ||
| } else if storageOpts.RootlessStoragePath != "" { | ||
| splitPaths := strings.SplitAfter(storageOpts.RootlessStoragePath, "$") | ||
| validEnv := regexp.MustCompile(`^(HOME|USER|UID)[^a-zA-Z]`).MatchString | ||
| if len(splitPaths) > 1 { | ||
| for _, path := range splitPaths { | ||
| if !validEnv(path) { | ||
| return storageOpts, errors.Errorf("Unrecognized environment variable") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| rootlessStoragePath := strings.Replace(storageOpts.RootlessStoragePath, "$HOME", homedir.Get(), -1) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, ouch. This sort of string replacement isn't as simple as that: for instance, what if someone writes |
||
| rootlessStoragePath = strings.Replace(rootlessStoragePath, "$UID", strconv.Itoa(rootlessUID), -1) | ||
| usr, err := user.LookupId(strconv.Itoa(rootlessUID)) | ||
| if err != nil { | ||
| return storageOpts, err | ||
| } | ||
| rootlessStoragePath = strings.Replace(rootlessStoragePath, "$USER", usr.Username, -1) | ||
| storageOpts.GraphRoot = rootlessStoragePath | ||
| } | ||
| } else { | ||
| if err := os.MkdirAll(filepath.Dir(storageConf), 0755); err != nil { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the RHS of the
=supposed to be? In all other options it's simply an empty string"". Why is this one different? Especially why is it misleadingly different? The=here implies that it's a default, but right below it says otherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the value of rootless_storage_path will not be used unless the user overwrites it in storage.conf. I think it can be described as "". But I'n not sure. I need ask @rhatdan