From: Jeremy Allison Date: Fri, 13 Feb 2009 22:59:48 +0000 (-0800) Subject: Noted by Vericode analysis. Correctly use chroot(). X-Git-Tag: samba-3.0.36~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=767f2dd0eb73f616351d54ea350b8b6de97334b9;p=thirdparty%2Fsamba.git Noted by Vericode analysis. Correctly use chroot(). Jeremy. (cherry picked from commit 3086400b61ee3dda639c5520b539d4ff76e4d9c5) --- diff --git a/source/smbd/server.c b/source/smbd/server.c index 2ed6792c4a9..9f13c32b78e 100644 --- a/source/smbd/server.c +++ b/source/smbd/server.c @@ -1101,8 +1101,15 @@ extern void build_options(BOOL screen); } if (*lp_rootdir()) { - if (sys_chroot(lp_rootdir()) == 0) - DEBUG(2,("Changed root to %s\n", lp_rootdir())); + if (sys_chroot(lp_rootdir()) != 0) { + DEBUG(0,("Failed to change root to %s\n", lp_rootdir())); + exit(1); + } + if (chdir("/") == -1) { + DEBUG(0,("Failed to chdir to / on chroot to %s\n", lp_rootdir())); + exit(1); + } + DEBUG(0,("Changed root to %s\n", lp_rootdir())); } /* Setup oplocks */