Hacker News new | past | comments | ask | show | jobs | submit login

this works for me

env -i DISPLAY=$DISPLAY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS firefox

this doesn't, it gives me the "Firefox is already running, but is not responding." message

env -i DISPLAY=$DISPLAY firefox




I'm not sure what you mean. What I try to achieve is start a new firefox window (for the normal user) from a root terminal. So part of the command has to be "sudo -u normaluser" or "su -l normaluser" or something.


You have to pass those environment variables to Firefox through sudo.

sudo has a --preserve-env=list option but you must know the value for DBUS_SESSION_BUS_ADDRESS. That's usually

  unix:path=/run/user/1000/bus
where 1000 is the id of the user Firefox is running for. Your root console could have no DBUS_SESSION_BUS_ADDRESS or have a different value for it.

To be 100% sure of the value, as you are root you could look into the environment of one of the running Firefox processes. Or wrap Firefox in a script that echoes that variable to a file before starting the browser.


Assuming it is "unix:path=/run/user/1000/bus", what would be the command to start Firefox as the normaluser with that setting?


I didn't test it but probably

  DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
  DISPLAY=:1 \
  sudo -H -u normaluser \
    --preserve-env=DBUS_SESSION_BUS_ADDRESS,DISPLAY \
  firefox
I'd add -H to the options of sudo to make it set the home to normaluser's one.

I assumed that your DISPLAY is :1, which is what my Debian has set for me. That's another variable that you could read from the environment of Firefox.

You might have to pass/preserve other environment variables to make Firefox work.


Whe don't you test it? It takes less time than to guess and have a back and forth via HN comments.


The parent gave all information which should help you in figuring it out by yourself now. The message it, it should work with the right env vars, and you have multiple example env vars to check for (DBUS related, DISPLAY, etc) and Google for. This is your work now.

(You could also test the extreme case: Just copy all the env vars.)


Because this is not a support forum or a stack exchange. I give the idea, then all the test and debugging is for who has to actually make the code work.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: