Explorar o código

LibCore: Add syscall wrapper for setgroups()

Andreas Kling %!s(int64=3) %!d(string=hai) anos
pai
achega
ad37ca4815

+ 7 - 0
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, &params);
     int rc = syscall(SC_ptrace, &params);
     HANDLE_SYSCALL_RETURN_VALUE("ptrace_peekbuf", rc, {});
     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
 #endif
 
 
 ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action)
 ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action)

+ 1 - 0
Userland/Libraries/LibCore/System.h

@@ -26,6 +26,7 @@ ErrorOr<Array<int, 2>> pipe2(int flags);
 ErrorOr<void> sendfd(int sockfd, int fd);
 ErrorOr<void> sendfd(int sockfd, int fd);
 ErrorOr<int> recvfd(int sockfd, int options);
 ErrorOr<int> recvfd(int sockfd, int options);
 ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf);
 ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf);
+ErrorOr<void> setgroups(Span<gid_t const>);
 #endif
 #endif
 
 
 ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);
 ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);