I have an installation script that I'd like to run on macOS/Linux.
Mid-installation, I need to detect the currently installed Firefox version to decide whether or not to use a deprecated feature (i.e. AutoConfig
) versus a modern feature (i.e. policies.json
).
firefox --version
however when firefox
sees the script running as root
it complains:Running Firefox as root in a regular user's session is not supported. (
$HOME
is/Users/foo
which is owned byfoo
.)
I can use sudo -u $USER firefox --version
but this seems like it will have scalability issues with systems that don't have sudo
enabled. Is there another way to get the version without launching the process as a regular user? Is there an undocumented override flag? I've tried --headless
to no avail.
It appears the following is a viable workaround for running firefox --version
as root.
HOME=/tmp XAUTHORITY=/tmp firefox --version
As far as I know, /tmp
should always be owned by root
, but if there are exceptions, please propose a better path so that this solution can be improved.