soravux / scoop

SCOOP (Scalable COncurrent Operations in Python)
https://github.com/soravux/scoop
GNU Lesser General Public License v3.0
625 stars 88 forks source link

source prolog file not working #74

Open nikoladze opened 5 years ago

nikoladze commented 5 years ago

Hi,

When i pass a file by the --prolog argument i get the error message:

OSError: [Errno 2] No such file or directory

originating from the subprocess.Popen call in:

https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/workerLaunch.py#L192-L195

The error seems to refer to the bash builtin source. When i run the above command with shell=True and executable="/bin/bash" it seems to work

self.subprocesses.append(subprocess.Popen(" ".join(c), shell=True, executable="/bin/bash"))

I'm aware this poses security risks and i have no overview which (potentially un-escaped) external inputs go into this command, so i'm not suggesting to just fix it in this way. Also i don't know if relying on bash is the only way to do this. Maybe somebody has an idea?

Cheers, Nikolai

ljluestc commented 10 months ago

import subprocess import shlex

Construct the subprocess command

prolog_command = [ '/full/path/to/your/prolog_script.sh', 'arg1', 'arg2', ]

Escape and join the command arguments

escaped_command = ' '.join(shlex.quote(arg) for arg in prolog_command)

Run the subprocess

subprocess.Popen(escaped_command, shell=True, executable="/bin/bash")