diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-10-24 11:23:02 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-25 10:13:03 +0100 |
commit | b1d36243e5026f9e8dcff4f19b18181311a639b2 (patch) | |
tree | 800d588726c1fbc5544f6484af2a352c28142342 /DevTools/UserspaceEmulator | |
parent | 457e00f319e324db6bee6a3c4491439e46455ac2 (diff) | |
download | serenity-b1d36243e5026f9e8dcff4f19b18181311a639b2.zip |
UserspaceEmulator: Add support for setgroups
Diffstat (limited to 'DevTools/UserspaceEmulator')
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.cpp | 11 | ||||
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index 61df845f1a..ce88544dae 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -335,6 +335,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) return virt$fcntl(arg1, arg2, arg3); case SC_getgroups: return virt$getgroups(arg1, arg2); + case SC_setgroups: + return virt$setgroups(arg1, arg2); case SC_lseek: return virt$lseek(arg1, arg2, arg3); case SC_socket: @@ -742,6 +744,15 @@ int Emulator::virt$getgroups(ssize_t count, FlatPtr groups) return 0; } +int Emulator::virt$setgroups(ssize_t count, FlatPtr groups) +{ + if (!count) + return syscall(SC_setgroups, 0, nullptr); + + auto buffer = mmu().copy_buffer_from_vm(groups, count * sizeof(gid_t)); + return syscall(SC_setgroups, count, buffer.data()); +} + u32 Emulator::virt$fcntl(int fd, int cmd, u32 arg) { switch (cmd) { diff --git a/DevTools/UserspaceEmulator/Emulator.h b/DevTools/UserspaceEmulator/Emulator.h index a74f648d30..19e3a52054 100644 --- a/DevTools/UserspaceEmulator/Emulator.h +++ b/DevTools/UserspaceEmulator/Emulator.h @@ -126,6 +126,7 @@ private: int virt$fstat(int, FlatPtr); u32 virt$fcntl(int fd, int, u32); int virt$getgroups(ssize_t count, FlatPtr); + int virt$setgroups(ssize_t count, FlatPtr); int virt$lseek(int fd, off_t offset, int whence); int virt$socket(int, int, int); int virt$getsockopt(FlatPtr); |