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

sclang: SequenceableCollection:unixCmd respects PATH #3501

Merged
merged 1 commit into from Feb 9, 2018

Conversation

nhthn
Copy link
Contributor

@nhthn nhthn commented Feb 6, 2018

fix #2317

This commit changes a call to execve to execvpe in SequenceableCollection:unixCmd, so that PATH is now respected.

This only affects *nix systems. SequenceableCollection:unixCmd is not currently supported on Windows, or so I hear.

test case:

["which", "scsynth"].unixCmd

once this method is working on Windows, i suggest that we refactor all calls to String:unixCmd to use this method. it is much better to call actual command line arguments as an array rather than formatting shell strings, which is vulnerable to injections.

@nhthn nhthn added the comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library" label Feb 6, 2018
@nhthn nhthn added this to the 3.9.2 milestone Feb 6, 2018
@mossheim
Copy link
Contributor

mossheim commented Feb 6, 2018

execvpe isn't available on macos, it's a GNU extension.

IIUC you could just change this to execvp and remove all use of environ from the this file. According to https://linux.die.net/man/3/execvp:

The other functions [not e-postfixed] take the environment for the new process image from the external variable environ in the calling process.

Since nothing is actually being added to environ in this call, using it again as an argument has no effect.

This commit changes a call to execve to execvp in
SequenceableCollection:unixCmd, so that PATH is now respected.
Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can confirm this works on macos

@mossheim
Copy link
Contributor

mossheim commented Feb 8, 2018

it is much better to call actual command line arguments as an array rather than formatting shell strings, which is vulnerable to injections.

not sure why this is any less vulnerable - couldn't one of the args be something like "`rm -rf ~/*; 0`"?

@nhthn
Copy link
Contributor Author

nhthn commented Feb 8, 2018

seeing is believing :)

"ls `echo ~`".unixCmd // ls ~
["ls", "`echo ~`"].unixCmd  // literally tries to ls a directory called "`echo ~`"

the exec* family runs at a lower level than shell

@mossheim
Copy link
Contributor

mossheim commented Feb 8, 2018

ahhh, ok. thanks for the explanation!

@mossheim mossheim merged commit 24a4451 into supercollider:3.9 Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants