From 0c078e6645ab644f979b367c1d8ee24f6e796822 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Wed, 17 Apr 2019 10:51:36 +0200 Subject: [PATCH 1/1] Tools: add setresuid syscall See `man 2 setresuid`. The code was tested with small UIDs (109) and one which does not fit into 16 bit (100000000), since I wasn't too sure about the workings of setresuid vs. setresuid32 (see NOTES of the manpage) - it worked with both. Linux on amd64 has only a single setresuid, as it the 64 bit arch came after the setresuid32 syscall, and thus it started with the later one as single common one Signed-off-by: Stoiko Ivanov Signed-off-by: Thomas Lamprecht --- src/PVE/Syscall.pm | 1 + src/PVE/Tools.pm | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/PVE/Syscall.pm b/src/PVE/Syscall.pm index 0f50c63..a2903b7 100644 --- a/src/PVE/Syscall.pm +++ b/src/PVE/Syscall.pm @@ -13,6 +13,7 @@ BEGIN { close => &SYS_close, mkdirat => &SYS_mkdirat, faccessat => &SYS_faccessat, + setresuid => &SYS_setresuid, ); }; diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 189b552..4dd073f 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -1384,6 +1384,11 @@ sub parse_host_and_port { return; # nothing } +sub setresuid($$$) { + my ($ruid, $euid, $suid) = @_; + return 0 == syscall(PVE::Syscall::setresuid, $ruid, $euid, $suid); +} + sub unshare($) { my ($flags) = @_; return 0 == syscall(PVE::Syscall::unshare, $flags); -- 2.39.2