From a245def340de818910acb9e3c845e0381dc313ef Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 17 Feb 2025 21:30:49 +0100 Subject: syscallcompat: add SetgroupsPanic,SetregidPanic,SetreuidPanic Will use those later. --- internal/syscallcompat/thread_credentials.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/internal/syscallcompat/thread_credentials.go b/internal/syscallcompat/thread_credentials.go index 3ef5233..8cfb703 100644 --- a/internal/syscallcompat/thread_credentials.go +++ b/internal/syscallcompat/thread_credentials.go @@ -19,6 +19,10 @@ // Note: _Gid_t is always uint32 on linux, so we can directly use uint32 for setgroups. package syscallcompat +import ( + "log" +) + func Setgroups(gids []int) (err error) { if len(gids) == 0 { return setgroups(0, nil) @@ -30,3 +34,27 @@ func Setgroups(gids []int) (err error) { } return setgroups(len(a), &a[0]) } + +// SetgroupsPanic calls Setgroups and panics on error +func SetgroupsPanic(gids []int) { + err := Setgroups(gids) + if err != nil { + log.Panic(err) + } +} + +// SetregidPanic calls Setregid and panics on error +func SetregidPanic(rgid int, egid int) { + err := Setregid(rgid, egid) + if err != nil { + log.Panic(err) + } +} + +// SetreuidPanic calls Setreuid and panics on error +func SetreuidPanic(ruid int, euid int) { + err := Setreuid(ruid, euid) + if err != nil { + log.Panic(err) + } +} -- cgit v1.2.3