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 <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Stoiko Ivanov 2019-04-17 10:51:36 +02:00 committed by Thomas Lamprecht
parent 096b5f5c06
commit 0c078e6645
2 changed files with 6 additions and 0 deletions

View File

@ -13,6 +13,7 @@ BEGIN {
close => &SYS_close, close => &SYS_close,
mkdirat => &SYS_mkdirat, mkdirat => &SYS_mkdirat,
faccessat => &SYS_faccessat, faccessat => &SYS_faccessat,
setresuid => &SYS_setresuid,
); );
}; };

View File

@ -1384,6 +1384,11 @@ sub parse_host_and_port {
return; # nothing return; # nothing
} }
sub setresuid($$$) {
my ($ruid, $euid, $suid) = @_;
return 0 == syscall(PVE::Syscall::setresuid, $ruid, $euid, $suid);
}
sub unshare($) { sub unshare($) {
my ($flags) = @_; my ($flags) = @_;
return 0 == syscall(PVE::Syscall::unshare, $flags); return 0 == syscall(PVE::Syscall::unshare, $flags);