d7fdbd
From 315f9720db94af3319c9550feaf473b9cf09aeac Mon Sep 17 00:00:00 2001
d7fdbd
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
d7fdbd
Date: Thu, 3 May 2018 13:20:28 +0200
d7fdbd
Subject: [PATCH 53/59] Always do chdir("/") after chroot()
d7fdbd
d7fdbd
Always do chdir("/") after chroot() to be more sure we'll never get out
d7fdbd
of it. This will not affect the working directory after calling
d7fdbd
vsf_sysutil_chroot(), because in the current state vsftpd always calls
d7fdbd
vsf_sysutil_chroot(".").
d7fdbd
---
d7fdbd
 sysutil.c | 5 +++++
d7fdbd
 1 file changed, 5 insertions(+)
d7fdbd
d7fdbd
diff --git a/sysutil.c b/sysutil.c
d7fdbd
index b68583b..3014c05 100644
d7fdbd
--- a/sysutil.c
d7fdbd
+++ b/sysutil.c
d7fdbd
@@ -2588,6 +2588,11 @@ vsf_sysutil_chroot(const char* p_root_path)
d7fdbd
   {
d7fdbd
     die("chroot");
d7fdbd
   }
d7fdbd
+  retval = chdir("/");
d7fdbd
+  if (retval != 0)
d7fdbd
+  {
d7fdbd
+    die("chdir");
d7fdbd
+  }
d7fdbd
 }
d7fdbd
 
d7fdbd
 unsigned int
d7fdbd
-- 
d7fdbd
2.14.4
d7fdbd