Re: [PATCH] chroot= as a new kernel parameter



Hi!

hi *real* hackers,

:-).

it is a my first post to lkml and I hope that you will have not been
ignored me if I have done some incorrect thing.

In the short this patch has added a new chroot= kernel parameter which can be used
to changing a chroot of an init process before it will has been runed.
I use that for testing variouses distroes without making a separate partition but
by copied a new root-fs to a new subdirectory on the my *base* filesystem.

Yes please. I was thinking about doing this long ago, but never got to
coding it.


diff -urp linux-2.6.24-orig/Documentation/kernel-parameters.txt linux-2.6.24/Documentation/kernel-parameters.txt
--- linux-2.6.24-orig/Documentation/kernel-parameters.txt 2008-02-25 20:53:26.000000000 -0500
+++ linux-2.6.24/Documentation/kernel-parameters.txt 2008-02-25 20:51:21.000000000 -0500
@@ -381,6 +381,8 @@ and is between 256 and 4096 characters.
Value can be changed at runtime via
/selinux/checkreqprot.

+ chroot= [KNL] call chroot() for init proccess.
+
clock= [BUGS=X86-32, HW] gettimeofday clocksource override.
[Deprecated]
Forces specified clocksource (if available) to be used
diff -urp linux-2.6.24-orig/init/main.c linux-2.6.24/init/main.c
--- linux-2.6.24-orig/init/main.c 2008-03-01 12:58:37.000000000 -0500
+++ linux-2.6.24/init/main.c 2008-02-25 20:36:06.000000000 -0500
@@ -755,8 +755,22 @@ static void __init do_pre_smp_initcalls(
spawn_softlockup_task();
}

+static void *chroot_str;
+static int __init chroot_setup(char *str)
+{
+ chroot_str = str;
+ return 1;
+}
+__setup("chroot=", chroot_setup);
+
static void run_init_process(char *init_filename)
{
+ if(chroot_str) {

'if ('

+ if(sys_chroot(chroot_str) < 0)

here too.

+ printk("chroot=%s failed\n", chroot_str);
+ else
+ printk("chroot=%s successed\n",chroot_str);

And I do not think we want to printk in the success case.

Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: chroot, scp and security on RedHat 8.0
    ... > chroot jail if a key file exists in the home directory of the login ... instead of the chroot openssh patch to several people, ...
    (Focus-Linux)
  • Re: CHROOT patch openssh3.4p1
    ... There's a 3.1p1 compatible patch, ... >> to the configure.ac script and has a widget for building new chroot ... target directories, it's entirely incompatible in its current release with a ... adding another new user (for the sshd root cage) requires co-evolution ...
    (comp.security.ssh)
  • Re: Init.c, making it chroot
    ... Since FreeBSD has kenv, the patch is ... There's code in init to mount devfs, ... Once we chroot, we need to have a sane environment inside the chroot. ...
    (freebsd-hackers)
  • Re: CHROOT patch openssh3.4p1
    ... wasn't sure if running patch would correctly update the new version. ... seems to work OK with the chroot patch code from v3.1 and v3.02. ... Tried compiling with the latest chroot ...
    (comp.security.ssh)
  • Re: [PATCH 12/18] shared mount handling: bind and rbind
    ... >> would consider a root. ... There didn't seem much interest in the patch ... on every chroot). ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)