]> git.proxmox.com Git - pve-lxc-syscalld.git/commitdiff
rework AT_FDCWD handling
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 7 Jan 2022 13:37:48 +0000 (14:37 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 7 Jan 2022 13:37:50 +0000 (14:37 +0100)
this one's negative, actually

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/lxcseccomp.rs

index 273f3c988b2eb4d7fedd10bbe84d52ba0420e286..7ba4f32afc2089fec0f6012acc5bcdcdd44490b9 100644 (file)
@@ -398,13 +398,13 @@ impl ProxyMessageBuffer {
     #[inline]
     pub fn arg_fd(&self, arg: u32, flags: c_int) -> Result<Fd, Error> {
         let fd = self.arg(arg)? as RawFd;
-        if fd < 0 {
-            // we pass those "as-is' to syscalls.
-            return Ok(Fd(fd));
-        }
-        // otherwise we'll open them from the process:
+        // we pass negative ones 'as-is', others get opened via the pidfd
         if fd == libc::AT_FDCWD {
+            // NOTE: we could pass this one through, but let's be explicit here, in the future we
+            // might want to reuse this one?
             Ok(self.pid_fd().fd_cwd()?)
+        } else if fd < 0 {
+            return Ok(Fd(fd));
         } else {
             Ok(self.pid_fd().fd_num(fd, flags)?)
         }