webbrowser fails to open for system crash when it runs as root

Bug #81207 reported by Vassilis Pandis
14
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Fix Released
High
Martin Pitt

Bug Description

Binary package hint: apport

(This is feistyu) I found a way to make network-admin crash. I get the notification that a crash report has been detected. I get the "the program has quit unexpectedly" window. I click "report bug" there, it asks if I want the full report or the compact one, I choose the full, a progress bar comes up and tells me to wait, and at some point it disappears and that's it. No link opens in the browser. I'm running compiz but have reported other bugs successfully. Same things happens with the "compact" report option.

Revision history for this message
Martin Pitt (pitti) wrote :

I have no idea off-hand what could have gone wrong, so we need to poke a bit: Can you please do the following:

  $ killall update-notifier
  $ touch /var/crash/*network-admin*.crash
  $ /usr/share/apport/apport-gtk

This should re-trigger apport-gtk for the network-admin crash. Do you get any output at the command line?

What is your default browser? You said that opening the browser works for other bugs/crashes?

What is the output of

  $ dpkg -l '*apport*' python-problem-report

?

Changed in apport:
status: Unconfirmed → Needs Info
Revision history for this message
Vassilis Pandis (pandisv) wrote :

I followed the instructions above and it works correctly (i.e. opens a new window of firefox, as expected). I tried to test it though with network-admin crash (which is I can reproduce reliably so getting a .crash is not an issue) by doing :

killall update-notifier
rm /var/crash/*network*
<run it, make it crash>
/usr/share/apport/apport-gtk

and it doesn't trigger. This is a clean install of Feisty (i.e. not upgrade), with a new FF profile and all. Firefox is the default browser.

pandis@pandis-laptop:~$ dpkg -l '*apport*' python-problem-report
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii apport 0.43 automatically generate crash reports for deb
ii apport-gtk 0.43 GTK frontend for the apport crash report sys
ii python-apport 0.43 apport crash report handling library
un python-apport- <none> (no description available)
ii python-problem 0.43 python library to handle problem reports
pandis@pandis-laptop:~$

Revision history for this message
Martin Pitt (pitti) wrote :

Ah, I see, that was a crash from a program that ran as root. The code that opens a browser as the user when apport-gtk is run as root is still a bit buggy. So, can you reproduce the bug with:

  $ killall update-notifier
  $ sudo touch /var/crash/*network-admin*.crash
  $ sudo /usr/share/apport/apport-gtk

? Does it make a difference whether Firefox was already open or not?

Revision history for this message
Vassilis Pandis (pandisv) wrote :

Still fails, but now I'm lucky enough to get an error message :-)

pandis@pandis-laptop:/var/crash$ sudo /usr/share/apport/apport-gtk
pandis@pandis-laptop:/var/crash$ Error: No running window found
The program 'firefox-bin' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
  (Details: serial 761 error_code 3 request_code 20 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

It doesn't make a difference whether firefox is already running or not.

Martin Pitt (pitti)
Changed in apport:
status: Needs Info → Confirmed
Revision history for this message
Simon Law (sfllaw) wrote : Re: webbrowser fails to open for system crash

I think apport-gtk doesn't have permissions to fire up something in your DISPLAY. A cookie issue?

Changed in apport:
importance: Undecided → High
Revision history for this message
Martin Pitt (pitti) wrote :

If you use apport 0.49 (to be uploaded today), then this phenomenon only occurs if you use Firefox as your prefered browser. With Epiphany it just works. With Firefox I now get 'Firefox is already running, but is not responding.'. I don't know why, I have to figure this out later.

Revision history for this message
Martin Pitt (pitti) wrote :

I created a test script which opens a browser as the user from a process running as root (through sudo). This is more or less what is happening when the user files a report for a system process crash.

   sudo ./test-81207.py epiphany

works just fine, but

  sudo ./test-81207.py firefox

errors out with 'Firefox is already running, but not responding'.

Alexander, any one else, do you have an idea why this happens? Is it a bug in my script or a bug in firefox? The environment is fully preserved, uid and gid are okay; I'm lost with this...

Changed in apport:
status: Confirmed → Needs Info
Revision history for this message
Mika Fischer (zoop) wrote :

There seems to be some support in firefox for using it with sudo, so maybe you could use sudo to change the uid, since that seems to be the cause of the problem.

See the attached modified version of your testcase. This one works for me but I'm not sure if there are security issues with this approach...

Regards,
 Mika

Revision history for this message
Martin Pitt (pitti) wrote :

Gosh, sometimes things can be so easy! :)

Thanks a lot Mika, you saved my day!

Changed in apport:
assignee: nobody → pitti
status: Needs Info → In Progress
Revision history for this message
Mika Fischer (zoop) wrote :

Glad I could help! :)

Revision history for this message
Martin Pitt (pitti) wrote :

Fixed in bzr head, will upload after Feisty's unfreeze.

Changed in apport:
status: In Progress → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

 apport (0.56) feisty; urgency=low
 .
   * apport/ui.py, open_url(): When being invoked as root, call gnome-open or
     firefox as root through sudo instead of dropping our uid/gid and calling
     it normally. The latter does not work for Firefox for some mysterious
     reason. Thanks to Mika Fischer for this trick. (LP: #81207)
   * Add debian/local/ubuntu-bug.1: Manpage for ubuntu-bug. Add it to
     debian/apport.manpages.
   * qt4/apport-qt: Add some missing features that are present in the GTK UI:
     - Do not show details by default, add a button to show them.
     - Add complete/reduced bug report radio buttons.
     - Thanks to Michael Hofmann for this!

Changed in apport:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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