]> git.proxmox.com Git - pve-common.git/commitdiff
Tools: add setresuid syscall
authorStoiko Ivanov <s.ivanov@proxmox.com>
Wed, 17 Apr 2019 08:51:36 +0000 (10:51 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 17 Apr 2019 10:00:24 +0000 (10:00 +0000)
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>
src/PVE/Syscall.pm
src/PVE/Tools.pm

index 0f50c631b85d1e05b2cea9f5fd7dd923c75659a8..a2903b72cd2212cd00c33037479f35c4e6da62e6 100644 (file)
@@ -13,6 +13,7 @@ BEGIN {
        close => &SYS_close,
        mkdirat => &SYS_mkdirat,
        faccessat => &SYS_faccessat,
+       setresuid => &SYS_setresuid,
     );
 };
 
index 189b55264ea8796728798c255ccc0cebf79c0998..4dd073f8cf6a07b02055fc0bb6a97b9145b2b1db 100644 (file)
@@ -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);