From bfbea34fd808aa10974040a81c7e6cde06b0bec9 Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Fri, 22 Nov 2024 12:13:10 +0100 Subject: [PATCH] Unset all auxiliary groups and simplify code Since `rungid` is already set as primary group, there's no reason to also set it as auxiliary group. Closes #2589 --- judge/runguard.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/judge/runguard.cc b/judge/runguard.cc index 55aebe9283..4fd24e04db 100644 --- a/judge/runguard.cc +++ b/judge/runguard.cc @@ -923,9 +923,7 @@ void setrestrictions() /* Set group-id (must be root for this, so before setting user). */ if ( use_group ) { if ( setgid(rungid) ) error(errno,"cannot set group ID to `%d'",rungid); - gid_t aux_groups[1]; - aux_groups[0] = rungid; - if ( setgroups(1, aux_groups) ) error(errno,"cannot clear auxiliary groups"); + if ( setgroups(0, NULL) ) error(errno,"cannot clear auxiliary groups"); verbose("using group ID `%d'",rungid); }