Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[su] stop parsing arguments after - and -- #1809

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dcermak
Copy link

@dcermak dcermak commented Sep 16, 2022

Currently su will try to parse all flags, even those after "-", which should be passed on to the spawned program. However, getopt will try to interpret all flags and mostly these do not belong to su and cause an error. Thus we set argc to the position of "-" or "--" and ensure that the rest is never interpreted.

Currently su will try to parse all flags, even those after "-", which should be
passed on to the spawned program. However, getopt will try to interpret all
flags and mostly these do not belong to su and cause an error.
Thus we set argc to the position of "-" or "--" and ensure that the rest is
never interpreted.
@karelzak
Copy link
Collaborator

Do you have any use-case for this change (an example)? I'm just curious.

@dcermak
Copy link
Author

dcermak commented Sep 19, 2022

I have created this PR for compatibility with su implementations that follow the LSB to the letter: https://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/su.html. It does not mention the -- at all and requires all arguments after - to be passed to the application being launched.

@karelzak
Copy link
Collaborator

Tested, the classic su - user does not work. This is unacceptable ;-(

@karelzak karelzak added the NOT-READY The patch is not ready yet. Need rework. label Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NOT-READY The patch is not ready yet. Need rework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants