diff options
author | Andreas Kling <kling@serenityos.org> | 2021-12-16 19:31:50 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-16 22:48:17 +0100 |
commit | ad37ca48152e9b87a7d7480a41224245465b4f8c (patch) | |
tree | 8c94030d78eebd8ce36cd51fe4eb837e1d7b065c | |
parent | 92e6532bf139aca0be568b545e8c0a47dc7f665f (diff) | |
download | serenity-ad37ca48152e9b87a7d7480a41224245465b4f8c.zip |
LibCore: Add syscall wrapper for setgroups()
-rw-r--r-- | Userland/Libraries/LibCore/System.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/System.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index e99cf059c8..9e3fe04c76 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -83,6 +83,13 @@ ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destinati int rc = syscall(SC_ptrace, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("ptrace_peekbuf", rc, {}); } + +ErrorOr<void> setgroups(Span<gid_t const> gids) +{ + if (::setgroups(gids.size(), gids.data()) < 0) + return Error::from_syscall("setgroups"sv, -errno); + return {}; +} #endif ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action) diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index f942c51c40..b552db968b 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -26,6 +26,7 @@ ErrorOr<Array<int, 2>> pipe2(int flags); ErrorOr<void> sendfd(int sockfd, int fd); ErrorOr<int> recvfd(int sockfd, int options); ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf); +ErrorOr<void> setgroups(Span<gid_t const>); #endif ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action); |