summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-02-13 14:59:48 -0800
committerJeremy Allison <jra@samba.org>2009-02-13 14:59:48 -0800
commit3086400b61ee3dda639c5520b539d4ff76e4d9c5 (patch)
treead2f5f2305edcaa631e142804a749f4920229d74
parent58331a118dd6a7fb56e70afe6cf93ef7cfff7e81 (diff)
downloadsamba-3086400b61ee3dda639c5520b539d4ff76e4d9c5.tar.gz
Noted by Vericode analysis. Correctly use chroot().
Jeremy.
-rw-r--r--source/smbd/server.c11
1 files changed, 9 insertions, 2 deletions
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 */