diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 2d4247ca29a4..e3b1da951d27 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -285,7 +285,9 @@ execve(p, uap, retval) p->p_ucred->cr_groups[0] = attr.va_gid; p->p_flag |= P_SUGID; } else { - p->p_flag &= ~P_SUGID; + if (p->p_ucred->cr_uid == p->p_cred->p_ruid && + p->p_ucred->cr_gid == p->p_cred->p_rgid) + p->p_flag &= ~P_SUGID; } /*