From 628b4d471579035583a3fbfe918ea8e608027734 Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Wed, 4 Feb 2026 00:01:55 +0800 Subject: [PATCH] Allow reacquiring capabilities if not explicitly cleared - Old behavior: Switching to a non-zero UID was implicitly interpreted as a request to drop capabilities, thereby preventing subsequent reacquisition via `su`. - New behavior: Switching to a non-zero UID now requires the `--drop-cap` argument to explicitly prevent the reacquisition of capabilities. --- native/src/core/su/su.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/src/core/su/su.cpp b/native/src/core/su/su.cpp index 70dfb5194..901b743aa 100644 --- a/native/src/core/su/su.cpp +++ b/native/src/core/su/su.cpp @@ -448,7 +448,7 @@ void exec_root_shell(int client, int pid, SuRequest &req, MntNsMode mode) { auto f = xopen_file("/proc/self/attr/exec", "we"); if (f) fprintf(f.get(), "%s", req.context.c_str()); } - if (req.target_uid != AID_ROOT || req.drop_cap || proc_is_restricted(pid)) + if (req.drop_cap || proc_is_restricted(pid)) drop_caps(); if (req.target_uid != AID_ROOT || req.gids.size() > 0) set_identity(req.target_uid, req.gids);