Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I getting a SegFault when I call pdftk from PHP/Apache but not PHP/CLI or directly
    primarykey
    data
    text
    <p>When I call <code>/usr/local/bin/pdftk</code> from PHP in Apache (via <code>shell_exec()</code>, <code>exec()</code>, <code>system()</code>, <em>etc.</em>), it returns the SYNOPSIS message as expected.</p> <p>When I call <code>/usr/local/bin/pdftk input.pdf fill_form input.fdf output output.pdf flatten</code> via <code>shell_exec()</code>, nothing returns.</p> <p>When I copy and paste the exact same string to the same path in the shell (as the apache user), the output.pdf file is generated as expected.</p> <p>Moving the <code>pdftk</code> command into a PHP shell script (shebang is <code>#!/usr/bin/php</code>) and executing it with <code>php script.php</code> works perfectly.</p> <p>Calling that shell script (with its stderr redirected to stdout) from PHP in Apache (via <code>shell_exec(script.php);</code>) results in this line:</p> <pre><code>sh: line 1: 32547 Segmentation fault /usr/local/bin/pdftk input.pdf fill_form input.fdf output output.pdf flatten 2&gt;&amp;1 </code></pre> <p>Whenever I run the script from the command line (via PHP or directly), it works fine. Whenever I run the script through PHP via Apache, it either fails without any notification or gives the SegFault listed above.</p> <p>It's PHP 4.3.9 on RHEL4. Please don't shoot me. I've set memory to 512M with ini_set() and made sure that the apache user had read/write to all paths (with fopen()) and by logging in as apache ...</p> <p>Just went and checked /var/log/messages to find this:</p> <pre><code>Oct 4 21:17:58 discovery kernel: audit(1286241478.692:1764638): avc: denied { read } for pid=32627 comm="pdftk" name="zero" dev=tmpfs ino=2161 scontext=root:system_r:httpd_sys_script_t tcontext=system_u:object_r:zero_device_t tclass=chr_file </code></pre> <p><strong>NOTE:</strong> Disabling SELinux "fixed" the problem. Has this moved into a ServerFault question? Can anybody give me the 30 second SELinux access controls primer here?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload