ftpd: do not use root_fd if we are not in chroot
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 27 Jun 2014 11:53:35 +0000 (13:53 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 27 Jun 2014 11:53:35 +0000 (13:53 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/ftpd.c

index e7cf5f43158a8ef15e65bd6ec457689a1bcb278d..2d2a3a44cfe2dc3732ffd7e8860b5630981e4aaf 100644 (file)
@@ -1173,11 +1173,14 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
                applet_name = xasprintf("%s[%u]", applet_name, (int)getpid());
 
 #if !BB_MMU
-       G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY);
-       close_on_exec_on(G.root_fd);
+       G.root_fd = -1;
 #endif
        argv += optind;
        if (argv[0]) {
+#if !BB_MMU
+               G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY);
+               close_on_exec_on(G.root_fd);
+#endif
                xchroot(argv[0]);
        }