[英]Get Firefox version as root
I have an installation script that I'd like to run on macOS/Linux.我有一个要在 macOS/Linux 上运行的安装脚本。
Mid-installation, I need to detect the currently installed Firefox version to decide whether or not to use a deprecated feature (ie AutoConfig
) versus a modern feature (ie policies.json
).在安装过程中,我需要检测当前安装的 Firefox 版本来决定是否使用不推荐使用的功能(即
AutoConfig
)与现代功能(即policies.json
)。
firefox --version
however when firefox
sees the script running as root
it complains:firefox --version
的输出,但是当firefox
看到脚本以root
身份运行时,它会抱怨:Running Firefox as root in a regular user's session is not supported.
不支持在普通用户的会话中以 root 身份运行 Firefox。 (
$HOME
is/Users/foo
which is owned byfoo
.)(
$HOME
是/Users/foo
拥有的/Users/foo
foo
。)
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.我可以使用
sudo -u $USER firefox --version
但这似乎与未启用sudo
系统存在可扩展性问题。 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.我试过
--headless
无济于事。
It appears the following is a viable workaround for running firefox --version
as root.以下似乎是以 root 身份运行
firefox --version
的可行解决方法。
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.据我所知,
/tmp
应该始终由root
拥有,但如果有例外,请提出更好的路径,以便可以改进此解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.