Skip to content
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

VCC: Fix +glob with relative path #4250

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

walid-git
Copy link
Member

Fixes: #4249

Copy link
Member

@nigoroll nigoroll left a comment

Choose a reason for hiding this comment

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

Thank you for looking after this issue, but ...

as a general note, I have the impression that more and more PRs now contain super terse commit messages and no additional explanations in the notes either. I can hardly avoid taking this a message towards reviewers in the direction of "my time is more important than yours", and I would really appreciate if we made it a custom (again) to explain which problem you are solving and why you have chosen the particular implementation.

On the actual implementation: Can we not use VFIL_searchpath() with an appropriate vfil_path_func_f()?

@walid-git
Copy link
Member Author

Thank you for looking after this issue, but ...

as a general note, I have the impression that more and more PRs now contain super terse commit messages and no additional explanations in the notes either. I can hardly avoid taking this a message towards reviewers in the direction of "my time is more important than yours", and I would really appreciate if we made it a custom (again) to explain which problem you are solving and why you have chosen the particular implementation.

Apologies for the lack of additional explanation in the commit log, but I though the code was simple enough and self explanatory here. I will try to add some content to it.

On the actual implementation: Can we not use VFIL_searchpath() with an appropriate vfil_path_func_f()?

That wouldn't work, VFIL_searchpath uses access() to test if the file exists then calls func on it if it is the case. In this case, we need to use glob() to test for file existence.

This function returns an array of paths built by concatenating
the vfil_path elements with the string pointed by the "name" argument.

Unlike VFIL_searchpath, VFIL_concat does not check that the files
exist and does not attempt anything on them.

Both the array and array elements returned must be freed by the caller.
We preivously called glob() on the included file name regardless of whether it
was an absolute or relative path. As a result, relative paths were not appended
to vcl_path elements before checking if the glob expression matched anything.

It is not possible to (re)use VFIL_searchpath here, since VFIL_searchpath uses
access() to check that the file exists, and that would fail in this case.

Fixes: varnishcache#4249
@walid-git
Copy link
Member Author

One question that came to my mind regarding how we handle +glob includes: Should we include all the matching files in all vcl_path directories, or do we only include the matching files from the first directory in vcl_path where we have a match (as we do for regular includes) ?

@nigoroll
Copy link
Member

nigoroll commented Jan 7, 2025

Apologies for the lack of additional explanation in the commit log, but I though the code was simple enough and self explanatory here. I will try to add some content to it.

IMHO, commit messages and ticket notes should not explain the code. They should explain the problem, the solution idea and the reasons for the implementation.

On the actual implementation: Can we not use VFIL_searchpath() with an appropriate vfil_path_func_f()?

That wouldn't work, VFIL_searchpath uses access() to test if the file exists then calls func on it if it is the case. In this case, we need to use glob() to test for file existence.

Right. But would it not make more sense to add an option to VFIL_searchpath to run the glob, rather than adding a different interface with some code duplication?

@nigoroll
Copy link
Member

nigoroll commented Jan 7, 2025

One question that came to my mind regarding how we handle +glob includes

This is a very good point. My first reaction is to include all matches within all path elements, but I am not entirely sure.

@walid-git
Copy link
Member Author

Right. But would it not make more sense to add an option to VFIL_searchpath to run the glob, rather than adding a different interface with some code duplication?

That could be an option. I will give it a try and see how that would look.

This is a very good point. My first reaction is to include all matches within all path elements, but I am not entirely sure.

That is also my opinion, but I need to think more about it.

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.

VCL include +glob with relative path is not working
2 participants