Re: Init.c, making it chroot



BTW, here's a patch to test. Since FreeBSD has kenv(2), the patch is
actually very small.

Warner

Index: init.c
===================================================================
RCS file: /cache/ncvs/src/sbin/init/init.c,v
retrieving revision 1.62
diff -u -r1.62 init.c
--- init.c 8 Jun 2006 14:04:36 -0000 1.62
+++ init.c 28 Dec 2006 20:39:33 -0000
@@ -55,6 +55,7 @@
#include <db.h>
#include <errno.h>
#include <fcntl.h>
+#include <kenv.h>
#include <libutil.h>
#include <paths.h>
#include <signal.h>
@@ -187,6 +188,7 @@
int
main(int argc, char *argv[])
{
+ char init_chroot[PATH_MAX];
int c;
struct sigaction sa;
sigset_t mask;
@@ -239,6 +241,12 @@
*/
openlog("init", LOG_CONS|LOG_ODELAY, LOG_AUTH);

+ *init_chroot = '\0';
+ kenv(KENV_GET, "init_chroot", init_chroot, sizeof(init_chroot));
+ if (*init_chroot)
+ if (chdir(init_chroot) != 0 || chroot(".") != 0)
+ warning("Can't chroot to %s: %m", init_chroot);
+
/*
* Create an initial session.
*/
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"

Relevant Pages

  • Re: Whats the point of __KERNEL_SYSCALLS__?
    ... retrieving revision 1.4 ... diff -u -p -r1.4 process.c ... -static int errno; ... * calls - which means inline code for fork too, ...
    (Linux-Kernel)
  • Re: Sequence of packet processing with ipfw, pf, ipfilter ?
    ... retrieving revision 1.21 ... diff -u -r1.93.2.1 bridge.c ... -static __inline int ... pfil_run_hooksruns the specified packet filter hooks. ...
    (freebsd-stable)
  • Linux compatible setaffinity.
    ... int sched_setaffinity; ... diff -u -r1.2.10.2 kern_resource.c ... retrieving revision 1.1 ... Please copy any additions and changes to the following compatability tables: ...
    (freebsd-arch)
  • Re: VPD in sysfs
    ... - Write code for devices with PCI 2.1 VPD ... retrieving revision 1.7 ... diff -N vpd-2.6/drivers/pci/vpd.c ... +static int vpd_create_name ...
    (Linux-Kernel)
  • [PATCH][CFT] mm swapping improvements
    ... Nikita's patches and one of my own, and backs out the RSS limit patch ... diff -puN include/linux/mmzone.h~rollup include/linux/mmzone.h ... -int FASTCALL); ...
    (Linux-Kernel)