···11-From e7d9098e81289ae99d07ec3eac1fec1d303b8fe4 Mon Sep 17 00:00:00 2001
22-From: Thiago Kenji Okada <thiagokokada@gmail.com>
33-Date: Thu, 5 Oct 2023 15:23:35 +0100
44-Subject: [PATCH] drop ambient capabilities
55-66-Within NixOS the only possibility to gain cap_sys_nice is using the
77-security.wrapper infrastructure. However to pass the capabilities to the
88-wrapped program, they are raised to the ambient set. To fix this we make
99-sure to drop the ambient capabilities during sway startup and realtime
1010-setup. Otherwise all programs started by sway also gain cap_sys_nice,
1111-which is not something we want.
1212-1313-Co-authored-by: Rouven Czerwinski <rouven@czerwinskis.de>
1414----
1515- sway/realtime.c | 3 +++
1616- 1 file changed, 3 insertions(+)
1717-1818-diff --git a/sway/realtime.c b/sway/realtime.c
1919-index 11154af0..06f872a8 100644
2020---- a/sway/realtime.c
2121-+++ b/sway/realtime.c
2222-@@ -3,6 +3,7 @@
2323- #include <unistd.h>
2424- #include <pthread.h>
2525- #include "sway/server.h"
2626-+#include "sys/prctl.h"
2727- #include "log.h"
2828-2929- static void child_fork_callback(void) {
3030-@@ -10,6 +11,8 @@ static void child_fork_callback(void) {
3131-3232- param.sched_priority = 0;
3333-3434-+ prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0);
3535-+
3636- int ret = pthread_setschedparam(pthread_self(), SCHED_OTHER, ¶m);
3737- if (ret != 0) {
3838- sway_log(SWAY_ERROR, "Failed to reset scheduler policy on fork");
3939---
4040-2.42.0
4141-