packages: reduce the number of packages which are using inplace sandbox wrapping

This commit is contained in:
2024-02-28 17:35:40 +00:00
parent 7ca5ae84b7
commit 812c0c8029
14 changed files with 48 additions and 37 deletions

View File

@@ -4,7 +4,7 @@
{ {
sane.programs.aerc = { sane.programs.aerc = {
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "inplace"; #< /share/aerc/aerc.conf refers to other /share files by absolute path
sandbox.net = "clearnet"; sandbox.net = "clearnet";
secrets.".config/aerc/accounts.conf" = ../../../secrets/common/aerc_accounts.conf.bin; secrets.".config/aerc/accounts.conf" = ../../../secrets/common/aerc_accounts.conf.bin;
mime.associations."x-scheme-handler/mailto" = "aerc.desktop"; mime.associations."x-scheme-handler/mailto" = "aerc.desktop";

View File

@@ -215,7 +215,7 @@ in
blanket.sandbox.whitelistWayland = true; blanket.sandbox.whitelistWayland = true;
blueberry.sandbox.method = "bwrap"; blueberry.sandbox.method = "bwrap";
blueberry.sandbox.wrapperType = "inplace"; # /etc/xdg/autostart hardcodes paths blueberry.sandbox.wrapperType = "inplace"; #< various /lib scripts refer to the bins by full path
blueberry.sandbox.whitelistWayland = true; blueberry.sandbox.whitelistWayland = true;
blueberry.sandbox.extraPaths = [ blueberry.sandbox.extraPaths = [
"/dev/rfkill" "/dev/rfkill"
@@ -381,11 +381,11 @@ in
fluffychat-moby.persist.byStore.plaintext = [ ".local/share/chat.fluffy.fluffychat" ]; fluffychat-moby.persist.byStore.plaintext = [ ".local/share/chat.fluffy.fluffychat" ];
font-manager.sandbox.method = "bwrap"; font-manager.sandbox.method = "bwrap";
font-manager.sandbox.wrapperType = "inplace"; # .desktop and dbus .service file refer to /libexec font-manager.sandbox.wrapperType = "wrappedDerivation";
font-manager.packageUnwrapped = pkgs.font-manager.override { font-manager.packageUnwrapped = pkgs.rmDbusServicesInPlace (pkgs.font-manager.override {
# build without the "Google Fonts" integration feature, to save closure / avoid webkitgtk_4_0 # build without the "Google Fonts" integration feature, to save closure / avoid webkitgtk_4_0
withWebkit = false; withWebkit = false;
}; });
forkstat.sandbox.method = "landlock"; #< doesn't seem to support bwrap forkstat.sandbox.method = "landlock"; #< doesn't seem to support bwrap
forkstat.sandbox.wrapperType = "wrappedDerivation"; forkstat.sandbox.wrapperType = "wrappedDerivation";
@@ -409,7 +409,7 @@ in
]; ];
gawk.sandbox.method = "bwrap"; # TODO:sandbox: untested gawk.sandbox.method = "bwrap"; # TODO:sandbox: untested
gawk.sandbox.wrapperType = "inplace"; # share/gawk libraries refer to /libexec gawk.sandbox.wrapperType = "inplace"; # /share/gawk libraries refer to /libexec
gawk.sandbox.autodetectCliPaths = true; gawk.sandbox.autodetectCliPaths = true;
gdb.sandbox.enable = false; # gdb doesn't sandbox well. i don't know how you could. gdb.sandbox.enable = false; # gdb doesn't sandbox well. i don't know how you could.
@@ -443,7 +443,7 @@ in
]; ];
"gnome.gnome-calculator".sandbox.method = "bwrap"; "gnome.gnome-calculator".sandbox.method = "bwrap";
"gnome.gnome-calculator".sandbox.wrapperType = "inplace"; # /libexec/gnome-calculator-search-provider "gnome.gnome-calculator".sandbox.wrapperType = "wrappedDerivation";
"gnome.gnome-calculator".sandbox.whitelistWayland = true; "gnome.gnome-calculator".sandbox.whitelistWayland = true;
# gnome-calendar surely has data to persist, but i use it strictly to do date math, not track events. # gnome-calendar surely has data to persist, but i use it strictly to do date math, not track events.
@@ -458,7 +458,7 @@ in
# gnome-disks # gnome-disks
"gnome.gnome-disk-utility".sandbox.method = "bwrap"; "gnome.gnome-disk-utility".sandbox.method = "bwrap";
"gnome.gnome-disk-utility".sandbox.wrapperType = "inplace"; # /etc/xdg/autostart "gnome.gnome-disk-utility".sandbox.wrapperType = "wrappedDerivation";
"gnome.gnome-disk-utility".sandbox.whitelistDbus = [ "system" ]; "gnome.gnome-disk-utility".sandbox.whitelistDbus = [ "system" ];
"gnome.gnome-disk-utility".sandbox.whitelistWayland = true; "gnome.gnome-disk-utility".sandbox.whitelistWayland = true;
@@ -660,8 +660,9 @@ in
lua = {}; lua = {};
"mate.engrampa".packageUnwrapped = pkgs.rmDbusServices pkgs.mate.engrampa;
"mate.engrampa".sandbox.method = "bwrap"; # TODO:sandbox: untested "mate.engrampa".sandbox.method = "bwrap"; # TODO:sandbox: untested
"mate.engrampa".sandbox.wrapperType = "inplace"; "mate.engrampa".sandbox.wrapperType = "wrappedDerivation";
"mate.engrampa".sandbox.whitelistWayland = true; "mate.engrampa".sandbox.whitelistWayland = true;
"mate.engrampa".sandbox.autodetectCliPaths = "existingOrParent"; "mate.engrampa".sandbox.autodetectCliPaths = "existingOrParent";
"mate.engrampa".sandbox.extraHomePaths = [ "mate.engrampa".sandbox.extraHomePaths = [

View File

@@ -234,7 +234,7 @@ in
sane.programs.firefox = { sane.programs.firefox = {
inherit packageUnwrapped; inherit packageUnwrapped;
sandbox.method = "bwrap"; # landlock works, but requires all of /proc to be linked sandbox.method = "bwrap"; # landlock works, but requires all of /proc to be linked
sandbox.wrapperType = "inplace"; # probably wrappedDerivation could work too. sandbox.wrapperType = "inplace"; # trivial package; cheap enough to wrap inplace
sandbox.net = "all"; sandbox.net = "all";
sandbox.whitelistAudio = true; sandbox.whitelistAudio = true;
sandbox.whitelistDbus = [ "user" ]; # mpris sandbox.whitelistDbus = [ "user" ]; # mpris

View File

@@ -1,8 +1,9 @@
{ ... }: { pkgs, ... }:
{ {
sane.programs."gnome.gnome-maps" = { sane.programs."gnome.gnome-maps" = {
packageUnwrapped = pkgs.rmDbusServices pkgs.gnome.gnome-maps;
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; #< dbus files sandbox.wrapperType = "wrappedDerivation";
sandbox.whitelistDri = true; # for perf sandbox.whitelistDri = true; # for perf
sandbox.whitelistDbus = [ sandbox.whitelistDbus = [
"system" # system is required for non-portal location services "system" # system is required for non-portal location services

View File

@@ -4,7 +4,7 @@
{ {
sane.programs."gnome.gnome-weather" = { sane.programs."gnome.gnome-weather" = {
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "inplace"; #< /share/org.gnome.Weather/org.gnome.Weather file refers to bins by full path
sandbox.whitelistWayland = true; sandbox.whitelistWayland = true;
sandbox.net = "clearnet"; sandbox.net = "clearnet";
suggestedPrograms = [ "dconf" ]; #< stores city/location settings suggestedPrograms = [ "dconf" ]; #< stores city/location settings

View File

@@ -1,16 +1,17 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
sane.programs."gnome.nautilus" = { sane.programs."gnome.nautilus" = {
packageUnwrapped = pkgs.gnome.nautilus.overrideAttrs (orig: { # some of its dbus services don't even refer to real paths
packageUnwrapped = pkgs.rmDbusServicesInPlace (pkgs.gnome.nautilus.overrideAttrs (orig: {
# enable the "Audio and Video Properties" pane. see: <https://nixos.wiki/wiki/Nautilus> # enable the "Audio and Video Properties" pane. see: <https://nixos.wiki/wiki/Nautilus>
buildInputs = orig.buildInputs ++ (with pkgs.gst_all_1; [ buildInputs = orig.buildInputs ++ (with pkgs.gst_all_1; [
gst-plugins-good gst-plugins-good
gst-plugins-bad gst-plugins-bad
]); ]);
}); }));
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "wrappedDerivation";
sandbox.whitelistDbus = [ "user" ]; # for portals launching apps sandbox.whitelistDbus = [ "user" ]; # for portals launching apps
sandbox.whitelistWayland = true; sandbox.whitelistWayland = true;
sandbox.extraHomePaths = [ sandbox.extraHomePaths = [

View File

@@ -2,7 +2,7 @@
{ {
sane.programs.playerctl = { sane.programs.playerctl = {
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "inplace"; #< /lib/pkgconfig/playerctl.pc refers to $out by full path
sandbox.whitelistDbus = [ "user" ]; # notifications sandbox.whitelistDbus = [ "user" ]; # notifications
services.playerctld = { services.playerctld = {

View File

@@ -3,7 +3,7 @@
sane.programs.portfolio-filemanager = { sane.programs.portfolio-filemanager = {
# this is all taken pretty directly from nautilus config # this is all taken pretty directly from nautilus config
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "wrappedDerivation";
sandbox.whitelistDbus = [ "user" ]; # for portals launching apps sandbox.whitelistDbus = [ "user" ]; # for portals launching apps
sandbox.whitelistWayland = true; sandbox.whitelistWayland = true;
sandbox.extraHomePaths = [ sandbox.extraHomePaths = [

View File

@@ -6,7 +6,7 @@
packageUnwrapped = pkgs.linkIntoOwnPackage pkgs.binutils-unwrapped "bin/strings"; packageUnwrapped = pkgs.linkIntoOwnPackage pkgs.binutils-unwrapped "bin/strings";
sandbox.method = "landlock"; sandbox.method = "landlock";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "inplace"; # trivial package; cheaper to wrap in place
sandbox.autodetectCliPaths = "existing"; sandbox.autodetectCliPaths = "existing";
}; };
} }

View File

@@ -8,7 +8,7 @@
# useHardenedMalloc = false; # useHardenedMalloc = false;
# }; # };
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "inplace"; # trivial package, so cheaper to wrap in-place
sandbox.net = "clearnet"; # tor over VPN wouldn't make sense sandbox.net = "clearnet"; # tor over VPN wouldn't make sense
sandbox.whitelistAudio = true; sandbox.whitelistAudio = true;
sandbox.whitelistWayland = true; sandbox.whitelistWayland = true;

View File

@@ -5,7 +5,7 @@ in
{ {
sane.programs.wireplumber = { sane.programs.wireplumber = {
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; #< it ships systemd files in a non-standard /lib/systemd dir sandbox.wrapperType = "wrappedDerivation";
sandbox.whitelistDbus = [ sandbox.whitelistDbus = [
# i think this isn't strictly necessary; it just wants to ask the portal for realtime perms # i think this isn't strictly necessary; it just wants to ask the portal for realtime perms
# "system" # "system"

View File

@@ -8,7 +8,7 @@ in
packageUnwrapped = pkgs.rmDbusServicesInPlace pkgs.xdg-desktop-portal-gtk; packageUnwrapped = pkgs.rmDbusServicesInPlace pkgs.xdg-desktop-portal-gtk;
sandbox.method = "bwrap"; sandbox.method = "bwrap";
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "wrappedDerivation";
sandbox.whitelistDbus = [ "user" ]; # speak to main xdg-desktop-portal sandbox.whitelistDbus = [ "user" ]; # speak to main xdg-desktop-portal
sandbox.whitelistWayland = true; sandbox.whitelistWayland = true;
sandbox.extraHomePaths = [ sandbox.extraHomePaths = [

View File

@@ -8,7 +8,7 @@ in
packageUnwrapped = pkgs.rmDbusServicesInPlace pkgs.xdg-desktop-portal-wlr; packageUnwrapped = pkgs.rmDbusServicesInPlace pkgs.xdg-desktop-portal-wlr;
sandbox.method = "bwrap"; # TODO:sandbox: untested sandbox.method = "bwrap"; # TODO:sandbox: untested
sandbox.wrapperType = "inplace"; sandbox.wrapperType = "wrappedDerivation";
sandbox.whitelistDbus = [ "user" ]; # speak to main xdg-desktop-portal sandbox.whitelistDbus = [ "user" ]; # speak to main xdg-desktop-portal
sandbox.whitelistWayland = true; sandbox.whitelistWayland = true;

View File

@@ -81,13 +81,13 @@ let
esac esac
} }
sandboxWrap() { sandboxWrap() {
_dir="$1" local _dir="$1"
_name="$2" local _name="$2"
_profileFromBinMap="$(getProfileFromBinMap $_name)" local _profileFromBinMap="$(getProfileFromBinMap $_name)"
_profiles=("$_profileFromBinMap" "$_name" "${pkgName}" "${unwrapped.pname or ""}" "${unwrapped.name or ""}") local _profiles=("$_profileFromBinMap" "$_name" "${pkgName}" "${unwrapped.pname or ""}" "${unwrapped.name or ""}")
# filter to just the unique profiles # filter to just the unique profiles
_profileArgs=(${extraSandboxArgsStr}) local _profileArgs=(${extraSandboxArgsStr})
for _profile in "''${_profiles[@]}"; do for _profile in "''${_profiles[@]}"; do
if [ -n "$_profile" ] && ! [[ " ''${_profileArgs[@]} " =~ " $_profile " ]]; then if [ -n "$_profile" ] && ! [[ " ''${_profileArgs[@]} " =~ " $_profile " ]]; then
_profileArgs+=("--sane-sandbox-profile" "$_profile") _profileArgs+=("--sane-sandbox-profile" "$_profile")
@@ -117,7 +117,7 @@ let
} }
crawlAndWrap() { crawlAndWrap() {
_dir="$1" local _dir="$1"
for _p in $(ls "$_dir/"); do for _p in $(ls "$_dir/"); do
if [ -x "$_dir/$_p" ] && ! [ -d "$_dir/$_p" ]; then if [ -x "$_dir/$_p" ] && ! [ -d "$_dir/$_p" ]; then
sandboxWrap "$_dir" "$_p" sandboxWrap "$_dir" "$_p"
@@ -172,10 +172,10 @@ let
fixHardcodedRefs = unsandboxed: sandboxedBin: unsandboxedNonBin: unsandboxedNonBin.overrideAttrs (prevAttrs: { fixHardcodedRefs = unsandboxed: sandboxedBin: unsandboxedNonBin: unsandboxedNonBin.overrideAttrs (prevAttrs: {
postInstall = (prevAttrs.postInstall or "") + '' postInstall = (prevAttrs.postInstall or "") + ''
trySubstitute() { trySubstitute() {
_outPath="$1" local _outPath="$1"
_pattern="$2" local _pattern="$2"
_from=$(printf "$_pattern" "${unsandboxed}") local _from=$(printf "$_pattern" "${unsandboxed}")
_to=$(printf "$_pattern" "${sandboxedBin}") local _to=$(printf "$_pattern" "${sandboxedBin}")
printf "applying known substitutions to %s\n" "$_outPath" printf "applying known substitutions to %s\n" "$_outPath"
# for closure efficiency, we only want to rewrite stuff which actually needs changing, # for closure efficiency, we only want to rewrite stuff which actually needs changing,
# and allow unchanged stuff to remain as symlinks. # and allow unchanged stuff to remain as symlinks.
@@ -186,11 +186,19 @@ let
fi fi
} }
# fixup a few files i understand well enough # fixup a few files i understand well enough
for d in $out/share/applications/*.desktop; do for d in \
trySubstitute "$d" "Exec=%s/bin/" $out/etc/xdg/autostart/*.desktop \
done $out/lib/systemd/user/*.service \
for d in $out/share/dbus-1/services/*.service; do $out/share/applications/*.desktop \
$out/share/dbus-1/services/*.service \
$out/share/systemd/user/*.service \
; do
# dbus and desktop files
trySubstitute "$d" "Exec=%s/bin/" trySubstitute "$d" "Exec=%s/bin/"
trySubstitute "$d" "Exec=%s/libexec/"
# systemd service files
trySubstitute "$d" "ExecStart=%s/bin/"
trySubstitute "$d" "ExecStart=%s/libexec/"
done done
''; '';
passthru = (prevAttrs.passthru or {}) // { passthru = (prevAttrs.passthru or {}) // {