在 GNU/Linux 安装 Firefox 时,您可能会看到一条警告:“某些 Firefox 的安全功能在您当前的操作系统上可能提供较少的保护”。
Firefox 的沙箱在创建新进程时使用了非特权用户命名空间,以增强安全性。这可能被视为一种安全风险,因此一些 GNU/Linux 发行版开始限制其使用,并仅允许在存在 AppArmor 配置文件的情况下使用。
这些配置文件只能覆盖有限的安装路径,包括 Snap 和 Debian 包。然而,它们无法覆盖某些其他用例,例如 tarball 安装以及本地开发构建。
要为 Firefox 创建 AppArmor 配置文件:
在 /etc/apparmor.d/
目录中,创建一个名为 firefox-local
的文件。
在文件中添加以下内容:
# This profile allows everything and only exists to give the
# application a name instead of having the label "unconfined"
abi <abi/4.0>,
include <tunables/global>
profile firefox-local
/home/<USER>/bin/firefox/{firefox,firefox-bin,updater}
flags=(unconfined) {
userns,
# Site-specific additions and overrides. See local/README for details.
include if exists <local/firefox>
}
将 <USER>
替换为您的 GNU/Linux 用户名。这里假设 Firefox 安装在 $HOME/bin/
目录下。
保存文件后,在 GNU/Linux 终端中运行 sudo systemctl restart apparmor.service
。