X programs don't run from job definitions with user: root

Bug #1288318 reported by Daniel Manrique
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PlainBox (Toolkit)
Fix Released
High
Sylvain Pineau

Bug Description

A job that has user: root and whose command invokes an X application will fail to run the application. This uses the trusted launcher whose policy regarding GUI applications is correctly set in the policy file.

For instance, mediacard/sd-performance-manual uses zenity to display results, but since it uses user:root it fails to display this to the user.

This has been confirmed in both Trusty and Precise.

I created a bogus job that just prints the environment and tries to run gedit as an example, to rule out a problem with zenity. With user: root it doesn't launch gedit and I see this in the test result:

PATH=/tmp/nest-mqsliy4c.722881a52a9cfb4a81721cbd5daab751db5659894c86162c88d8ad771ca8f815:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
PWD=/root
LANG=C.UTF-8
SHLVL=1
CHECKBOX_SHARE=/usr/lib/plainbox-providers-1/checkbox/
CHECKBOX_DATA=/home/roadmr/.cache/plainbox/sessions/pbox-z5r75cgg.session/CHECKBOX_DATA
_=/usr/bin/env
error: XDG_RUNTIME_DIR not set in the environment.

(gedit:30425): Gtk-WARNING **: cannot open display:

If I remove user: root to bypass the trusted launcher, gedit runs and I see this:

XDG_VTNR=7
SSH_AGENT_PID=1294
XDG_SESSION_ID=c1
CLUTTER_IM_MODULE=xim
SELINUX_INIT=YES
DBUS_STARTER_ADDRESS=unix:abstract=/tmp/dbus-EKG5JibWpS,guid=3ed2bbf7025a5632648f9c5a5314f52b
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/roadmr
GPG_AGENT_INFO=/run/user/1000/keyring-qjr6Mf/gpg:0:1
SHELL=/bin/bash
XDG_MENU_PREFIX=gnome-
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1223
GNOME_KEYRING_CONTROL=/run/user/1000/keyring-qjr6Mf
GTK_MODULES=overlay-scrollbar:unity-gtk-module
USER=roadmr
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/run/user/1000/keyring-qjr6Mf/ssh
ZEITGEIST_DATA_PATH=/home/roadmr/.local/share/zeitgeist
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
SESSION_MANAGER=local/roadmr-Latitude-3440:@/tmp/.ICE-unix/1497,unix/roadmr-Latitude-3440:/tmp/.ICE-unix/1497
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
PATH=/tmp/nest-i6rizz3y.546647aa43f3d13ad63be4b77cad89ed4ed863f3855e0ba07bdb6e58ac245cc2:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
DESKTOP_SESSION=ubuntu
JOB=xsession-init
PWD=/
XMODIFIERS=@im=ibus
LANG=C.UTF-8
GDM_LANG=en_US
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
UBUNTU_MENUPROXY=1
COMPIZ_CONFIG_PROFILE=ubuntu
IM_CONFIG_PHASE=1
GDMSESSION=ubuntu
DBUS_STARTER_BUS_TYPE=session
SESSIONTYPE=gnome-session
SHLVL=1
HOME=/home/roadmr
XDG_SEAT=seat0
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
UPSTART_INSTANCE=
UPSTART_EVENTS=starting
LOGNAME=roadmr
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-EKG5JibWpS,guid=3ed2bbf7025a5632648f9c5a5314f52b
QT4_IM_MODULE=xim
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
TEXTDOMAIN=im-config
UPSTART_JOB=dbus
INSTANCE=
XDG_RUNTIME_DIR=/run/user/1000
DBUS_DEBUG_OUTPUT=1
DISPLAY=:0
CHECKBOX_SHARE=/usr/lib/plainbox-providers-1/checkbox/
XDG_CURRENT_DESKTOP=Unity
GTK_IM_MODULE=ibus
CHECKBOX_DATA=/home/roadmr/.cache/plainbox/sessions/pbox-9i28hr8e.session/CHECKBOX_DATA
TEXTDOMAINDIR=/usr/share/locale/
XAUTHORITY=/home/roadmr/.Xauthority
_=/usr/bin/env
Fontconfig warning: ignoring C.UTF-8: not a valid language tag

Related branches

Daniel Manrique (roadmr)
description: updated
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Thanks for the details bug report. I'll see if I can fix this. The odd thing is that we pass all the client side environment to plainbox-trusted-launcher but apparently (somehow) it is not being respected. Are you sure this job got started with plainbox-trusted-launcher and not sudo?

Changed in checkbox:
assignee: nobody → Zygmunt Krynicki (zkrynicki)
assignee: Zygmunt Krynicki (zkrynicki) → nobody
Revision history for this message
Daniel Manrique (roadmr) wrote :

An easy way to reproduce it is to install plainbox (apt-get install plainbox is what I did), then:

plainbox run -i .*sd-performance.*

that'll show a policykit prompt, and then show the failed output from the job run. I know it's not using sudo because I never saw a sudo prompt and this system always requires sudo passwords so it would have asked me.

Chris Gregan (cgregan)
Changed in checkbox-ihv-ng:
milestone: none → version1.7
importance: Undecided → High
Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, I ran plainbox with -C --trace=plainbox.runner, and I see it's selecting the RootViaPTL1ExecutionController with a score of "3" for the given job. I've never heard of PTL1 :) I thought it'd be RootViaPkexec.

Anyway, this is possibly another clue, I'll look at what PTL1 does and why it's outbidding Pkexec, and maybe we need to tweak the bid scores; or if this PTL1 controller is not behaving as it should, it could need fixing.

Revision history for this message
Daniel Manrique (roadmr) wrote :

DOH, PTL1 is the plainbox trusted launcher... disregard me.

Revision history for this message
Daniel Manrique (roadmr) wrote :

using --trace plainbox.ctrl I see this:

DEBUG plainbox.ctrl: job[mediacard/sd-performance-manual] executing ['pkexec', '--user', 'root', 'plainbox-trusted-launcher-1', '--target', '722881a52a9cfb4a81721cbd5daab751db5659894c86162c88d8ad771ca8f815', '-T', 'CHECKBOX_DATA=/home/roadmr/.cache/plainbox/sessions/pbox-hn652bgr.session/CHECKBOX_DATA', '-T', 'CHECKBOX_SHARE=/usr/lib/plainbox-providers-1/checkbox/', '-T', 'LANG=C.UTF-8', '-T', 'PATH=/tmp/nest-n9x7b28j.722881a52a9cfb4a81721cbd5daab751db5659894c86162c88d8ad771ca8f815:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games'] with env None

The final "env None" looks suspicious. I'll continue trying to dig into this.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

The trusted launcher does not keep the original env set by pkexec, so all the variables kept by setting the allow_gui in the action file definition were lost. I proposed a fix that update the existing env set by pkexec by the one provided by plainbox.

Changed in checkbox:
status: New → In Progress
assignee: nobody → Sylvain Pineau (sylvain-pineau)
milestone: none → 2014-mar-14
Changed in checkbox:
status: In Progress → Fix Committed
Changed in checkbox-ihv-ng:
assignee: nobody → Sylvain Pineau (sylvain-pineau)
status: New → Fix Committed
Changed in checkbox-ihv-ng:
status: Fix Committed → Fix Released
Zygmunt Krynicki (zyga)
affects: checkbox → plainbox
Changed in plainbox:
milestone: 2014-mar-14 → none
Zygmunt Krynicki (zyga)
Changed in plainbox:
status: Fix Committed → Fix Released
tags: removed: plainbox
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.