]> git.proxmox.com Git - pve-common.git/commitdiff
tools: add fchownat syscall
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 24 Jul 2019 11:37:14 +0000 (13:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Aug 2019 13:33:19 +0000 (15:33 +0200)
and constant AT_EMPTY_PATH for chowning a directory/file opened via
openat(2), for example when walking/creating a directory tree without
following symlinks.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/Syscall.pm
src/PVE/Tools.pm

index a2903b72cd2212cd00c33037479f35c4e6da62e6..99e43e77667dd432ba611585251ccba14c4bb44d 100644 (file)
@@ -14,6 +14,7 @@ BEGIN {
        mkdirat => &SYS_mkdirat,
        faccessat => &SYS_faccessat,
        setresuid => &SYS_setresuid,
+       fchownat => &SYS_fchownat,
     );
 };
 
index 676647eefb375d8d1ad00e9d06ab404baab9c906..550da09a609ddcf39f7999cc384bb312515192ed 100644 (file)
@@ -85,6 +85,8 @@ use constant {CLONE_NEWNS   => 0x00020000,
 use constant {O_PATH    => 0x00200000,
               O_TMPFILE => 0x00410000}; # This includes O_DIRECTORY
 
+use constant {AT_EMPTY_PATH => 0x1000};
+
 sub run_with_timeout {
     my ($timeout, $code, @param) = @_;
 
@@ -1556,6 +1558,11 @@ sub mkdirat($$$) {
     return syscall(PVE::Syscall::mkdirat, $dirfd, $name, $mode) == 0;
 }
 
+sub fchownat($$$$$) {
+    my ($dirfd, $pathname, $owner, $group, $flags) = @_;
+    return syscall(PVE::Syscall::fchownat, $dirfd, $pathname, $owner, $group, $flags) == 0;
+}
+
 my $salt_starter = time();
 
 sub encrypt_pw {