···11+From 232e480ab1303f37d37d295b57fdcbb6b6648bca Mon Sep 17 00:00:00 2001
22+From: Alois Wohlschlager <alois1@gmx-topmail.de>
33+Date: Sun, 7 Aug 2022 16:12:31 +0200
44+Subject: [PATCH] Lower CAP_SYS_NICE from the ambient set
55+66+The capabilities wrapper raises CAP_SYS_NICE into the ambient set so it
77+is inherited by the wrapped program. However, we don't want it to leak
88+into the entire desktop environment.
99+1010+Lower the capability again at startup so that the kernel will clear it
1111+on exec.
1212+---
1313+ src/main_wayland.cpp | 3 +++
1414+ 1 file changed, 3 insertions(+)
1515+1616+diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp
1717+index 1720e14e7..f2bb446b0 100644
1818+--- a/src/main_wayland.cpp
1919++++ b/src/main_wayland.cpp
2020+@@ -39,7 +39,9 @@
2121+ #include <QWindow>
2222+ #include <qplatformdefs.h>
2323+2424++#include <linux/capability.h>
2525+ #include <sched.h>
2626++#include <sys/prctl.h>
2727+ #include <sys/resource.h>
2828+2929+ #include <iomanip>
3030+@@ -285,6 +287,7 @@ static QString automaticBackendSelection()
3131+3232+ int main(int argc, char *argv[])
3333+ {
3434++ prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, CAP_SYS_NICE, 0, 0);
3535+ KWin::Application::setupMalloc();
3636+ KWin::Application::setupLocalizedString();
3737+ KWin::gainRealTime();
3838+--
3939+2.37.1
4040+
+1
pkgs/desktops/plasma-5/kwin/default.nix
···4848 ./0002-xwayland.patch
4949 ./0003-plugins-qpa-allow-using-nixos-wrapper.patch
5050 ./0001-NixOS-Unwrap-executable-name-for-.desktop-search.patch
5151+ ./0001-Lower-CAP_SYS_NICE-from-the-ambient-set.patch
5152 # Pass special environments through arguemnts to `kwin_wayland`, bypassing
5253 # ld.so(8) environment stripping due to `kwin_wayland`'s capabilities.
5354 # We need this to have `TZDIR` correctly set for `plasmashell`, or