-const char jcc_rcs[] = "$Id: jcc.c,v 1.92.2.5 2003/03/10 23:45:32 oes Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.92.2.6 2003/03/11 11:55:00 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/Attic/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.92.2.6 2003/03/11 11:55:00 oes
+ * Clean-up and extension of improvements for forked mode:
+ * - Child's return code now consists of flags RC_FLAG_*
+ * - Reporting toggle to parent now properly #ifdef'ed
+ * - Children now report blocking to parent. This enables
+ * statistics in forked mode
+ *
* Revision 1.92.2.5 2003/03/10 23:45:32 oes
* Fixed bug #700381: Non-Threaded version now capable of being toggled.
* Children now report having been toggled through _exit(17), parents
struct passwd *pw = NULL;
struct group *grp = NULL;
char *p;
+ int do_chroot = 0;
#endif
Argc = argc;
if (p != NULL) *--p = '\0';
}
+
+ else if (strcmp(argv[argc_pos], "--chroot" ) == 0)
+ {
+ do_chroot = 1;
+ }
#endif /* defined(unix) */
else
#endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
{
log_error(LOG_LEVEL_FATAL, "Cannot setgid(): Insufficient permissions.");
}
+ if (do_chroot)
+ {
+ if (!pw->pw_dir)
+ {
+ log_error(LOG_LEVEL_FATAL, "Home directory for %s undefined", pw->pw_name);
+ }
+ if (chroot(pw->pw_dir) < 0)
+ {
+ log_error(LOG_LEVEL_FATAL, "Cannot chroot to %s", pw->pw_dir);
+ }
+ if (chdir ("/"))
+ {
+ log_error(LOG_LEVEL_FATAL, "Cannot chdir /");
+ }
+ }
if (setuid(pw->pw_uid))
{
log_error(LOG_LEVEL_FATAL, "Cannot setuid(): Insufficient permissions.");
}
+ if (do_chroot)
+ {
+ if (setenv ("HOME", "/", 1) < 0)
+ {
+ log_error(LOG_LEVEL_FATAL, "Cannot setenv(): HOME");
+ }
+ if (setenv ("USER", pw->pw_name, 1) < 0)
+ {
+ log_error(LOG_LEVEL_FATAL, "Cannot setenv(): USER");
+ }
+ }
+ }
+ else if (do_chroot)
+ {
+ log_error(LOG_LEVEL_FATAL, "Cannot chroot without --user argument.");
}
}
#endif /* defined unix */