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

RFE: support "--" flag in su to circumvent additional shell #224

Open
vcaputo opened this issue Feb 23, 2020 · 3 comments
Open

RFE: support "--" flag in su to circumvent additional shell #224

vcaputo opened this issue Feb 23, 2020 · 3 comments

Comments

@vcaputo
Copy link
Contributor

vcaputo commented Feb 23, 2020

There's a convention in the GNU userspace for a bare '--' arg to indicate "everything in argv following the -- is not to be interpreted as a flag, just use as input to the program"

In the case of su, when you want su to run a command, you currently must use "-c/--command WORD_REPRESENTING_COMMAND", which will then be interpolated by another shell's -c invocation running as the target user.

This can be rather annoying and error prone, depending on the complexity of whatever is being executed via su.

I'd like to propose supporting "--" as an alternative to -c/--command which instead treats whatever remains in argv as the argv to supply directly to execve(), bypassing any further shell invocation or subsequent word splitting.

@hallyn
Copy link
Member

hallyn commented Mar 3, 2020

I'm all for this. Will try to do it if I find some spare time.

@vcaputo
Copy link
Contributor Author

vcaputo commented May 9, 2020

After glancing at the code and actually reading the man page I see there's already existing semantics for '--' to pass subsequent argv entries on as flags.

So it looks like this should instead add a new flag to suppress using any interpretive shell when running the command, and suppress argv manipulation like adding the '-c' shell command flag.

How about supporting "--exec-command" / "-e" to suppress any "$shell -c", directly calling execve() on the command, with any arguments after '--' supplied as the rest of argv?

@vcaputo
Copy link
Contributor Author

vcaputo commented May 10, 2020

I took a stab at implementing this #254
PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants