Skip to content

fix else case for rootless storage path and path match#542

Merged
vrothberg merged 1 commit into
containers:masterfrom
QiWang19:fix_storage-path
Mar 2, 2020
Merged

fix else case for rootless storage path and path match#542
vrothberg merged 1 commit into
containers:masterfrom
QiWang19:fix_storage-path

Conversation

@QiWang19
Copy link
Copy Markdown
Member

move the assignment of rootless_storage_path out of else block to make the config work even the graphroot is empty.
fix the path match error

Signed-off-by: Qi Wang qiwan@redhat.com

Comment thread utils.go Outdated
if storageOpts.RootlessStoragePath != "" {
splitPaths := strings.SplitAfter(storageOpts.RootlessStoragePath, "$")
validEnv := regexp.MustCompile(`^(HOME|USER|UID)[^a-zA-Z]`).MatchString
validEnv := regexp.MustCompile(`^(HOME|USER|UID)([^a-zA-Z]|$)`).MatchString
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to change the regex?

@QiWang19, could you break the code in this if branch into a dedicated function and add unit tests? We have a long tradition in regressing with parsing code.

move the assignment of rootless_storage_path out of `else` block to make the config work even the graphroot is empty.
fix the path match error

Signed-off-by: Qi Wang <qiwan@redhat.com>
Comment thread utils_test.go
"/test/$HOME/path",
"/test/$HOME/$USER/$UID",
"/test/$HOME/$USER/$UID/path",
"$HOME/$USER/$UID/path",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about these valid paths?
/tmp/$HOME$USER$UID
/tmp/$HOME-$USER-$UID

Copy link
Copy Markdown
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @QiWang19 !

@vrothberg vrothberg merged commit bfb78f6 into containers:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants