Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It works fine on the commandline, when I do

xhost +  
su - jenkins  
emulator -avd myAVD.avd  


emulator -avd myAVD.avd

executed by jenkins daemon fails with

"SDL init failure: No available video device"  

How can I relax the X security constraints for the jenkins daemon,
so that it can do emulator -avd myAVD.avd without failing ?

share|improve this question
If you don't get any satisfying answer you might get one at – N.N. Aug 11 '11 at 16:57
up vote 1 down vote accepted

The most likely reason you get the error is that emulator does not know where your display is. X11 programs use the $DISPLAY environment variable to discover the X11 server location, and the way most daemons are started they do not receive the environ variable. (Most daemons do not [and should not] need X11 to run.)

You will need to find a way to pass the current value of $DISPLAY to the daemon – note that it may change between logins.

As for security, do not ever use xhost + – it gives full access to everyone1. Instead, give the other account access to your Xauthority data.

$ xauth extract /dev/stdout $DISPLAY | su -c "xauth merge /dev/stdin" jenkins

One possible way to automate all of this is to put a few commands in your ~/.xprofile... you will need ACL support enabled for the following to work:

# your .xprofile
if [ "$DISPLAY" ]; then
    touch /tmp/jenkins-display
    setfacl -m u::rw,u:jenkins:r,g::-,o::- /tmp/jenkins-display
    { echo $DISPLAY; xauth nextract /dev/stdout $DISPLAY; } > /tmp/jenkins-display

and make an emulator-wrapper script for running the emulator tool:

# a wrapper script for 'emulator'
{ read -r DISPLAY; export DISPLAY; xauth nmerge /dev/stdin; } < /tmp/jenkins-display
exec emulator "$@"

Somewhat ugly.

1 "Everyone" usually means any user who can run programs on the computer – but if your X11 server is listening for TCP connections, it would mean "the whole Internet", although this is uncommon in modern distros.

share|improve this answer
localhost:8080/systemInfo shows all environment variables for the jenkins daemon process, and $DISPLAY is missing. – user19496 Aug 11 '11 at 19:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.