From 6cf6b40469e5cbd63c04f075ce1399f3a1ad3574 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 24 Jul 2019 13:37:14 +0200 Subject: [PATCH 1/1] tools: add fchownat syscall MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/PVE/Syscall.pm | 1 + src/PVE/Tools.pm | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/PVE/Syscall.pm b/src/PVE/Syscall.pm index a2903b7..99e43e7 100644 --- a/src/PVE/Syscall.pm +++ b/src/PVE/Syscall.pm @@ -14,6 +14,7 @@ BEGIN { mkdirat => &SYS_mkdirat, faccessat => &SYS_faccessat, setresuid => &SYS_setresuid, + fchownat => &SYS_fchownat, ); }; diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 676647e..550da09 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -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 { -- 2.39.2