We would like to generate mobi files on server side. For this we need to use kindlegen(to generate mobi from epub) from Amazon. I have read that enabling exec is not entirely safe, but my question is if i use something like
exec('kindlegen ' . $epubInput . ' -c0 -o ' . $mobiOutput );
is there a possiblity to go something wrong?
The two variables($epubInput and $mobiOutput) are not coming from user input, they are generated by the script.
Another question(i guess it’s impossible), but is there a setting maybe, that would allow exec to execute only a specific file, in my case kindlegen?
It depends on if the code that produces these values can be tricked into producing evil values. In this case it really doesn’t look like it, but you should be sure.
You should also use
escapeshellargon the two arguments before callingexec; this is not strictly necessary when the values are under your control, but there’s no argument against doing it.