splitbrain.org

electronic brain surgery since 2001

Apache's private /tmp/ on ArchLinux

Today I figured something out that really confused me yesterday. I was trying to use up xdebug's function tracing, so I set up my config like this:

/etc/php/conf.d/xdebug.ini
zend_extension=/usr/lib/php/modules/xdebug.so                                                                           
xdebug.remote_enable=off                                                                                                
xdebug.remote_host=127.0.0.1                                                                                            
xdebug.remote_port=9000                                                                                                 
xdebug.remote_handler=dbgp                                                                                              
 
xdebug.trace_enable_trigger=1                                                                                           
xdebug.trace_output_dir=/tmp/                                                                                           
xdebug.trace_output_name=xdebug.%t

But sending the XDEBUG_TRACE trigger never did produce any output in /tmp/. I then tried to call xdebug_start_trace() and xdebug_stop_trace() directly. But still no output in /tmp/.

Next I made a simple test script doing nothing more than starting tracing, echoing “test” and stop tracing. I ran it from the command line and I got a trace file in /tmp/! So I ran the same file through my webserver… and got nothing.

That's when it dawned on me and I changed my test file to this:

<?php
xdebug_start_trace();
echo "test";
xdebug_stop_trace();
print_r(glob('/tmp/*'));

I ran it from my webserver and there they were! All the traces I produced earlier. But doing an ls /tmp/ did not show them!?

A bit googling finally brought the answer. In ArchLinux, Apache is started from systemd with the option PrivateTmp=true. Apparently that creates a virtual /tmp/ using the Kernel's file system namespace feature – here's a blog post describing it a bit more.

So the solution is to reconfigure the xdebug.trace_output_dir to point to a different directory.

TIL: /tmp/ might not be what you think it is.

Tags:
archlinux, xdebug, tmp, apache, systemd
Similar posts: