community.general
community.general copied to clipboard
fix: sudosu not working on some BSD machines
SUMMARY
The original sudosu does not work on some BSD machines and some versions of linux machine as the argument of su differs .
ISSUE TYPE
- Bugfix Pull Request
COMPONENT NAME
become.sudosu
ADDITIONAL INFORMATION
cc @dagwieers click here for bot help
BTW, if /bin/sh is prefered, we should pass -s /bin/sh to su.
The original version passes /bin/sh without -s, thus on many su it does not work.
Thanks for your contribution! Please note that you need to add a changelog fragment, and that the unit tests are failing (https://github.com/ansible-collections/community.general/blob/main/tests/unit/plugins/become/test_sudosu.py).
Also it seems to me that this is potentially a larger change that might break some use-cases on other systems. I'm wondering whether the switch between the current and the new behavior should maybe be controlled by a toggle?
(The /bin/sh comes from the currently selected shell plugin, so hardcoding that is out of the question. That would break other mechanisms.)
ummmm the unit test is failing because it is asserting the original command which is not working on all system... Maybe we should change the unit test?
I'm wondering whether the switch between the current and the new behavior should maybe be controlled by a toggle?
That sounds good to me.
Ping @lekoOwO
needs_info
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 3 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:60:69: W291: trailing whitespace
plugins/become/sudosu.py:62:28: W291: trailing whitespace
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 3 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:60:69: W291: trailing whitespace
plugins/become/sudosu.py:62:28: W291: trailing whitespace
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 3 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:60:69: W291: trailing whitespace
plugins/become/sudosu.py:62:28: W291: trailing whitespace
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 3 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:60:69: W291: trailing whitespace
plugins/become/sudosu.py:62:28: W291: trailing whitespace
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:63:28: W291: trailing whitespace
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:63:28: W291: trailing whitespace
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:63:28: W291: trailing whitespace
The test ansible-test sanity --test line-endings [explain] failed with 1 error:
changelogs/fragments/8214-sudosu-not-working-on-some-BSD-machines.yml:0:0: use "\n" for line endings instead of "\r\n"
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/become/sudosu.py:59:25: W291: trailing whitespace
plugins/become/sudosu.py:63:28: W291: trailing whitespace
If nobody objects, I'll merge this tomorrow.
Backport to stable-9: 💚 backport PR created
✅ Backport PR branch: patchback/backports/stable-9/83318c36aaf3f0e88362ac9d8a8d5ba7a4bfead2/pr-8214
Backported as https://github.com/ansible-collections/community.general/pull/8631
🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.
@lekoOwO thanks for your contribution!