+ log_init();
+
+ if (use_chroot) {
+ /*
+ * XXX: The 'use chroot' flag is a fairly reliable
+ * source of confusion, because it fails under two
+ * important circumstances: running as non-root,
+ * running on Win32 (or possibly others). On the
+ * other hand, if you are running as root, then it
+ * might be better to always use chroot.
+ *
+ * So, perhaps if we can't chroot we should just issue
+ * a warning, unless a "require chroot" flag is set,
+ * in which case we fail.
+ */
+ if (chroot(lp_path(i))) {
+ rsyserr(FERROR, errno, "chroot %s failed", lp_path(i));
+ io_printf(fd,"@ERROR: chroot failed\n");
+ return -1;
+ }
+
+ if (!push_dir("/", 0)) {
+ rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
+ io_printf(fd,"@ERROR: chdir failed\n");
+ return -1;
+ }