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

salt.wheel.file_roots.find missing subdir=true #59800

Closed
kevthehermit opened this issue Mar 14, 2021 · 2 comments · Fixed by #64429
Closed

salt.wheel.file_roots.find missing subdir=true #59800

kevthehermit opened this issue Mar 14, 2021 · 2 comments · Fixed by #64429
Assignees
Labels
Bug broken, incorrect, or confusing behavior Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases severity-high 2nd top severity, seen by most users, causes major problems

Comments

@kevthehermit
Copy link

kevthehermit commented Mar 14, 2021

/srv/salt # salt --version
salt 3002.5

When using file_roots.write we are allowed to write to subdirs, however, if we try to read the newly created file we are blocked from doing so.

I believe it is because the find function is missing subdir=True from the clean_path check

if not salt.utils.verify.clean_path(root, full):

the write function has this check

if not salt.utils.verify.clean_path(root, dest, subdir=True):

Tests performed using the Pepper API

Write file

>>> pepper_client.api.low([{'client': 'wheel', 'fun': 'file_roots.write', 'path': 'frames/docker_linux.sls', 'data': 'hello world'}])
{'return': [{'tag': 'salt/wheel/20210314115719692923', 'data': {'fun': 'wheel.file_roots.write', 'jid': '20210314115719692923', 'tag': 'salt/wheel/20210314115719692923', 'user': 'salt', '_stamp': '2021-03-14T11:57:19.709197', 'return': 'Wrote data to file /srv/salt/frames/docker_linux.sls', 'success': True}}]}

read file

>>> pepper_client.api.low([{'client': 'wheel', 'fun': 'file_roots.read', 'path': 'frames/docker_linux.sls'}])
{'return': [{'tag': 'salt/wheel/20210314115802924030', 'data': {'fun': 'wheel.file_roots.read', 'jid': '20210314115802924030', 'tag': 'salt/wheel/20210314115802924030', 'user': 'salt', '_stamp': '2021-03-14T11:58:02.941864', 'return': [], 'success': True}}]}

find

>>> pepper_client.api.low([{'client': 'wheel', 'fun': 'file_roots.find', "path": "frames/docker_linux.sls"}])
{'return': [{'tag': 'salt/wheel/20210314120236946891', 'data': {'fun': 'wheel.file_roots.find', 'jid': '20210314120236946891', 'tag': 'salt/wheel/20210314120236946891', 'user': 'salt', '_stamp': '2021-03-14T12:02:36.960801', 'return': [], 'success': True}}]}

list env

>>> pepper_client.api.low([{'client': 'wheel', 'fun': 'file_roots.list_env'}])
{'return': [{'tag': 'salt/wheel/20210314115836835377', 'data': {'fun': 'wheel.file_roots.list_env', 'jid': '20210314115836835377', 'tag': 'salt/wheel/20210314115836835377', 'user': 'salt', '_stamp': '2021-03-14T11:58:36.850508', 'return': {'/srv/salt': {'frames': {'docker_linux.sls': 'f'}, 'test': 'f'}, '/srv/spm/salt': {}}, 'success': True}}]}

list roots

>>> pepper_client.api.low([{'client': 'wheel', 'fun': 'file_roots.list_roots'}])
{'return': [{'tag': 'salt/wheel/20210314115904413257', 'data': {'fun': 'wheel.file_roots.list_roots', 'jid': '20210314115904413257', 'tag': 'salt/wheel/20210314115904413257', 'user': 'salt', '_stamp': '2021-03-14T11:59:04.424949', 'return': {'base': [{'/srv/salt': {'frames': {'docker_linux.sls': 'f'}, 'test': 'f'}, '/srv/spm/salt': {}}]}, 'success': True}}]}
@welcome
Copy link

welcome bot commented Mar 14, 2021

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at core@saltstack.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@kevthehermit
Copy link
Author

Confirmed that setting clean_path(root, full) to clean_path(root, full, subdir=True) allows me to read files as expected

>>> pepper_client.api.low([{'client': 'wheel', 'fun': 'file_roots.read', 'path': 'frames/docker_linux.sls'}])
{'return': [{'tag': 'salt/wheel/20210314130704569888', 'data': {'fun': 'wheel.file_roots.read', 'jid': '20210314130704569888', 'tag': 'salt/wheel/20210314130704569888', 'user': 'salt', '_stamp': '2021-03-14T13:07:05.005846', 'return': [{'/srv/salt/frames/docker_linux.sls': 'hello world'}], 'success': True}}]}

@sagetherage sagetherage added Bug broken, incorrect, or confusing behavior needs-triage labels Mar 15, 2021
@sagetherage sagetherage added severity-high 2nd top severity, seen by most users, causes major problems and removed needs-triage labels Apr 30, 2021
@sagetherage sagetherage added this to the Approved milestone Apr 30, 2021
@sagetherage sagetherage added the Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Apr 30, 2021
@sagetherage sagetherage added the Phosphorus v3005.0 Release code name and version label Jun 18, 2021
@sagetherage sagetherage modified the milestones: Approved, Phosphorus Jun 18, 2021
@Ch3LL Ch3LL removed the Phosphorus v3005.0 Release code name and version label Mar 30, 2022
@MKLeb MKLeb self-assigned this May 23, 2023
@MKLeb MKLeb closed this as completed Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases severity-high 2nd top severity, seen by most users, causes major problems
Projects
None yet
5 participants