diff options
author | Jakob Unterwurzacher | 2025-02-17 21:30:49 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2025-02-17 21:30:49 +0100 |
commit | a245def340de818910acb9e3c845e0381dc313ef (patch) | |
tree | 10ab18272319d4e121b51042bfc7dfcca5cd1b37 | |
parent | f31bc4a64c151244c92261a72f93b38cd9aacd5b (diff) |
syscallcompat: add SetgroupsPanic,SetregidPanic,SetreuidPanic
Will use those later.
-rw-r--r-- | internal/syscallcompat/thread_credentials.go | 28 |
1 files changed, 28 insertions, 0 deletions
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) + } +} |