community.general icon indicating copy to clipboard operation
community.general copied to clipboard

fix: sudosu not working on some BSD machines

Open lekoOwO opened this issue 1 year ago • 5 comments
trafficstars

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

lekoOwO avatar Apr 11 '24 08:04 lekoOwO

cc @dagwieers click here for bot help

ansibullbot avatar Apr 11 '24 08:04 ansibullbot

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.

lekoOwO avatar Apr 11 '24 10:04 lekoOwO

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.)

felixfontein avatar Apr 14 '24 19:04 felixfontein

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?

lekoOwO avatar Apr 16 '24 09:04 lekoOwO

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.

lekoOwO avatar Apr 16 '24 09:04 lekoOwO

Ping @lekoOwO

needs_info

felixfontein avatar Jul 13 '24 12:07 felixfontein

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

click here for bot help

ansibullbot avatar Jul 13 '24 15:07 ansibullbot

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

click here for bot help

ansibullbot avatar Jul 13 '24 17:07 ansibullbot

If nobody objects, I'll merge this tomorrow.

felixfontein avatar Jul 13 '24 20:07 felixfontein

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.

patchback[bot] avatar Jul 14 '24 12:07 patchback[bot]

@lekoOwO thanks for your contribution!

felixfontein avatar Jul 14 '24 12:07 felixfontein