-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix bug of using symbolic link dir as storage path #340
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
Conversation
There is a bug to use symbolic link directory as storage root path. It is a problem that whether the path is canonical
be/src/http/download_action.cpp
Outdated
| DCHECK_EQ(_download_type, ERROR_LOG); | ||
| if (FileSystemUtil::contain_path(_error_log_root_dir, file_path)) { | ||
| std::string canonical_file_path = canonical(file_path).string(); | ||
| if (FileSystemUtil::contain_path(canonical(_error_log_root_dir).string(), canonical_file_path)) { |
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.
_error_log_root_dir should be set after canonical when initializing.
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.
why not just call canonical in DownloadAction construct method?
be/src/http/download_action.cpp
Outdated
| std::string canonical_file_path = canonical(file_path).string(); | ||
| for (auto& allow_path : _allow_paths) { | ||
| if (FileSystemUtil::contain_path(allow_path, file_path)) { | ||
| if (FileSystemUtil::contain_path(canonical(allow_path).string(), canonical_file_path)) { |
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.
same with _error_log_root_dir to _allow_paths
|
@kangpinghuang |
|
|
||
| Status DownloadAction::check_log_path_is_allowed(const std::string& file_path) { | ||
| DCHECK_EQ(_download_type, ERROR_LOG); | ||
| if (FileSystemUtil::contain_path(_error_log_root_dir, file_path)) { |
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.
Is it better to get canonical path in a unified place?
Or you may miss somewhere.
In DownloadAction, checking fails by comparing canonical path with noncanonical path. So fix the bug by convert all path to canonical path before comparison
be/src/http/download_action.cpp
Outdated
|
|
||
| _download_type(NORMAL) { | ||
| for (auto& dir : allow_dirs) { | ||
| _allow_paths.emplace_back(std::move(canonical(dir).string())); |
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.
canonical(dir).string() is already a rvalue, you needn't to call std::move
|
ISSUE #307 |
imay
left a comment
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.
LGTM
There is a bug to use symbolic link directory as storage root path.
It is a problem that whether the path is canonical