Skip to content

Error out when passing a list to run_cmd* to avoid running wrong command unintended, unless shell=True is used#3737

Merged
boegel merged 1 commit intoeasybuilders:developfrom
Flamefire:run_cmd_shell
Jul 1, 2021
Merged

Error out when passing a list to run_cmd* to avoid running wrong command unintended, unless shell=True is used#3737
boegel merged 1 commit intoeasybuilders:developfrom
Flamefire:run_cmd_shell

Conversation

@Flamefire
Copy link
Copy Markdown
Contributor

@Flamefire Flamefire commented Jun 11, 2021

This is a serious pitfall as e.g. run_cmd(['python', '-c' , 'print(1)']) would be interpreted as bash -c python -c 'print(1)', i.e. the arguments are passed to bash and not to python!

Allow to opt-in into that by passing shell=True explicitely.

edit (by @boegel): only occurrence in central easyblocks was in custom easyblock for TensorFlow, which was fixed in easybuilders/easybuild-easyblocks#2469 (I went through all easyblocks, didn't find other instances of passing a list of strings to run_cmd*)

@boegel boegel added this to the next release (4.4.1) milestone Jun 11, 2021
@Flamefire Flamefire force-pushed the run_cmd_shell branch 2 times, most recently from 726777d to 886741f Compare June 14, 2021 17:35
Copy link
Copy Markdown
Contributor

@bartoldeman bartoldeman left a comment

Choose a reason for hiding this comment

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

just a little typo to fix, otherwise lgtm

Comment thread easybuild/tools/run.py Outdated
Comment thread easybuild/tools/run.py Outdated
This is a serious pitfall as e.g. run_cmd(['python', '-c' , 'print(1)'])
would be interpreted as `bash -c python -c 'print(1)'`, i.e. the
arguments are passed to bash and not to python!

Allow to opt-in into that by passing shell=True explicitely.
@easybuilders easybuilders deleted a comment from boegelbot Jul 1, 2021
@easybuilders easybuilders deleted a comment from boegelbot Jul 1, 2021
@easybuilders easybuilders deleted a comment from boegelbot Jul 1, 2021
@boegel boegel changed the title Error out when passing a list to run_cmd* Error out when passing a list to run_cmd*, unless shell=True is used Jul 1, 2021
@boegel boegel changed the title Error out when passing a list to run_cmd*, unless shell=True is used Eerror out when passing a list to run_cmd* to avoid running wrong command unintended, unless shell=True is used Jul 1, 2021
Copy link
Copy Markdown
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

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

lgtm

@boegel boegel merged commit a5345e1 into easybuilders:develop Jul 1, 2021
@Flamefire Flamefire deleted the run_cmd_shell branch July 2, 2021 06:54
@boegel boegel changed the title Eerror out when passing a list to run_cmd* to avoid running wrong command unintended, unless shell=True is used Error out when passing a list to run_cmd* to avoid running wrong command unintended, unless shell=True is used Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants