SETREGID(2)
π SETREGID β set real and effective group ID π
okay bestie, we're in the setregid(2) page, and it lives in section 2 of the System Calls Manual, so get comfy π«Ά
β¨ LIBRARY β¨
Standard C Library (libc, -lc) β she's a libc girlie, no cap π
πΈ SYNOPSIS πΈ
#include <unistd.h>
int
setregid(gid_t rgid, gid_t egid);
π DESCRIPTION π
So here's the tea: the real and effective group ID's of the current process get set to the arguments. That's the whole vibe. π¦
And the way that if the real group ID is changed, the saved group ID also gets changed to the new value of the effective group ID. like they're matching, periodt.
Unprivileged users may change the real group ID to the effective group ID and vice-versa β that swap is allowed, bestie π only the super-user may make other changes. so if you're not root, don't even try it, it's giving EPERM.
Supplying a value of -1 for either the real or effective group ID forces the system to substitute the current ID in place of the -1 argument. lowkey a "keep it as is" cheat code β¨
π¨ history lesson that's also a warning: thesetregid()system call was intended to allow swapping the real and effective group IDs in set-group-ID programs to temporarily relinquish the set-group-ID value. But β and I cannot stress this enough β this system call did not work correctly. π its purpose is now better served by the use of thesetegid(2)system call. so, like, use that one instead, fr fr.
When setting the real and effective group IDs to the same value, the standard setgid() system call is preferred. that's the move, that's the main character call π
β RETURN VALUES β
The setregid() function returns the value 0 if successful π otherwise the value -1 is returned and the global variable errno is set to indicate the error. classic. she tells you what went wrong through errno, so go read it π
π₯ ERRORS π₯
[EPERM]β The current process is not the super-user and a change other than changing the effective group-id to the real group-id was specified. translation: you're not root and you tried to do something spicy π
π SEE ALSO π
getgid(2), issetugid(2), setegid(2), setgid(2), setuid(2) β go read the whole friend group, iykyk π«Ά
π HISTORY π
The setregid() system call appeared in 4.2BSD. an icon, an absolute legend, even if she's a lil broken π
and that's the whole page, bestie!! this one came from the Debian fam, dated April 16, 1994, and it's filed under SETREGID(2) β¨π stay safe out there, use setegid(2), and don't forget your errno check πΈπ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1980, 1991, 1993, 1994 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms