From owner-freebsd-questions Sat Mar 29 15:01:51 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id PAA18849 for questions-outgoing; Sat, 29 Mar 1997 15:01:51 -0800 (PST) Received: from tor.muc.de (tor.muc.de [193.174.4.131]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id PAA18844 for ; Sat, 29 Mar 1997 15:01:40 -0800 (PST) Received: from odin.muc.de (odin.muc.de [193.31.20.18]) by tor.muc.de (8.8.5/8.6.6) with SMTP id AAA06989; Sun, 30 Mar 1997 00:02:49 +0100 (CET) Received: (from eilts@localhost) by odin.muc.de (8.6.8/8.6.6) id AAA00407; Sun, 30 Mar 1997 00:02:45 +0100 Date: Sun, 30 Mar 1997 00:02:45 +0100 From: Hinrich Eilts Message-Id: <199703292302.AAA00407@odin.muc.de> Received: by NeXT.Mailer (1.100) Received: by NeXT Mailer (1.100) To: freebsd-questions@freebsd.org Subject: setgid(2) Cc: eilts@tor.muc.de Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hello, what is the right behaviour of setgid(2)? Assume following situation: A program is installed with group-bit 's' and contain two setgid(2)-calls, the first set the program to its real group, the second to its old effective group (this the program is installed and set to). For example: -rwxr-sr-x 1 root mail 387562 Mar 29 17:29 /usr/local/bin/elm is invoked by user Fred in group 'wheel'. Just after start 'elm' has effective group 'mail'. After the first setgid it becomes effective group 'wheel', the second setgid shall set effective group back to 'mail'. In FreeBSD-2.1, this worked but now in FreeBSD-2.2.1 it fails, because the second setgid(2) failed. If setgid(2) is replaced by setegid(2), it works. I assume, setgid(2) in FreeBSD-2.1 has not overwritten the saved-gid but in FreeBSD-2.2 it overwrite it? What is the right behaviour? Hinrich