-
Notifications
You must be signed in to change notification settings - Fork 112
Unset the executable bit on Ansible modules. #45
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
|
applies. Is the unit-test even packaged in the RPM? It probably should not, should it? |
|
Thanks for the explanations. I have a few comments:
If it is not a module, it should not be, IMO, in
This will actually simplify the copy task: no need to reference this special Anyway that was rather a digression. Back to the topic:
In
Unfortunately, the check actually checks whether the shebang invokes python or pythonN. Whether it invokes it directly or via
It is; the |
|
why does the script reject pure "python"? What is a script supposed to specify, that works both with python2 and python3? PEP394 remarks "... python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3.". |
|
From what I understood, the point of the check is to make sure that nothing in Fedora uses |
Sorry, I was looking at an older version of the tests, please disregard that part. The point about a file which is only referenced in a copy task belonging to |
Per the policy defined in https://docs.ansible.com/ansible/latest/dev_guide/testing/sanity/shebang.html. (Some RPM checks https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/f7e8f73eadbd09f6eee0e836bf3cb80f14f0c053/f/brp-mangle-shebangs do not like an executable script to have a #!/usr/bin/python shebang.)
This script is not being executed directly, but by using python, python2 or python3 interpreter and passing the script name as argument. This is because the script is to be tested under multiple versions of Python. (It is also only referenced in a copy task and the remote copy gets executed, which makes the executable bit on the original unneeded as well.) (Some RPM checks https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/f7e8f73eadbd09f6eee0e836bf3cb80f14f0c053/f/brp-mangle-shebangs do not like an executable script to have a #!/usr/bin/python shebang. This script has it to indicate that it is compatible with both versions of Python, although a shebang line is not very meaningful here for the same reason as the executable bit.)
|
I split the commit in two because the two files are a bit different cases. |
|
the commit message says:
this is not correct. I run the unit-tests manually all the time (without explicitly selecting the interpreter, which is the entire point of the shebang). The Fedora script warns when a shebang contains python alone. I think that is wrong, or at least overly strict. Note that the RPM script is only for Fedora 28 or newer. This is the upstream project, if you need to patch anything to make Fedora 28+ build scripts happy, then the right place is downstream. |
OK, beware though that
I am not the right person to complain about that, but it seems that this error (not warning) has justification, if the intent is to remove
I will do that, in general since the project is mostly focused on Fedora-derived distributions (Fedora, RHEL, CentOS), it makes sense to minimize differences between upstream and downstream. Can you at least merge the first commit, which has been uncontroversial so far? |
To clarify that, in Fedora it is currently still a warning, but it says |
Interesting. Do you have a source for that? It would break countless scripts (and upstream projects). The warning in the RPM script, makes it sound like it will later ERROR instead of WARN when building packages for Fedora. But even then, we couldn't patch the shebang upstream (here), because then it would stop working on RHEL7 and RHEL6.
yes, first one lgtm. I am pretty sure you have permissions to merge. Please go ahead. |
That's how I read the discussion in python/peps#630.
We can turn it into |
|
IMHO we should move the commands required for packaging into a Makefile or some other install script and then adjust things there when installing to an actual system. I would assume that we do not need any executable flags at all on the installed system and also not shebangs. It is strange for me that https://docs.ansible.com/ansible/latest/dev_guide/testing/sanity/shebang.html requires shebangs for non-executable Ansible modules. @pcahyna is there a Fedora package for this project? It would be good to call the unit scripts as part of %check there. |
The files in |
|
We don't indeed.
I guess they are treating this shebang line specially (like searching for this exact string and replacing it with the actual interpreter after the module is pushed to the managed host).
So far only a RHEL package. The unit test script can be called as part of %check, if it does not make any changes to the system (I haven't looked what it does; the fact that it calls the ansible module looks a bit suspicious). But the unit test script is being executed in the integration tests in every GitHub PR. |
Good point. Still, how does moving it make running the unit tests more complicated?
It is certainly possible, my motivation was to keep the differences with upstream at a minimum. |
|
Do we still need to do something here when #46 is merged? |
|
No, the first commit was merged separately, the other file will not be touched for now. |
Per the policy defined in https://docs.ansible.com/ansible/latest/dev_guide/testing/sanity/shebang.html.
(Some RPM checks do not like an executable script to have a #!/usr/bin/python
shebang.)