setuid and setgid confusion

view story

http://unix.stackexchange.com – I'm trying to fully grasp the concept of setuid and setgid, and I'm not quite sure in what way permissions are actually elevated. Let me provide an example: Users userA (groups: userA groupA) userB (groups: userB groupB GroupC) Executable Permission owner group filename -rws-----x userA groupD file -rwsrws--x userA groupD file2 If userB executes file and file2, what group permission will the executables have? What I'm not completely sure about, is whether the executable gains user/group permissions of both the caller and the file owner, or if permissions are "replaced". I know this is (HowTos)