by nodesocket · 14y ago · 0 comments
Never seen $found = `grep $udid FILE` using back-ticks in PHP land. Is that the same as the exec() function?
It's still relatively unsafe, as it invokes external programs through a shell, so you're dependent on the shell's environment, which can diverge on different systems. Last I checked, PHP did not have an easy, obvious way to safely invoke another program. You can do it manually with a mix of pcntl_fork and pcntl_exec, but capturing the output using that is more difficult.
Is there any shell on which those functions are unsafe ? I think they assume cmd.exe on windows and sh on others.
The right thing to do is provide an output capturing API that does not require escaping because it takes a list of strings passed to the exec(2) system call.