Undoing chroot?
Hello,
I have a linux bootable CD which executes a custom init. The job of init is to figure out on which device the CD is located. After finding the CD, init mounts the device and executes a CHROOT to set the root directory to the CD.
After I'm done I'd like to umount the CD and then eject it by sending an IOCTL eject command. But since I executed a CHROOT I can't umount the CD, umount complains that the device is busy.
So how do you reverse a CHROOT?
BTW, I use an initrd image and init is a C program, not a script.
Thanks
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 6 lines · Paul Powell
I have a linux bootable CD which executes a custom init. The job of init is to figure out on which device the CD is located. After finding the CD, init mounts the device and executes a CHROOT to set the root directory to the CD.
Quoted 6 lines
After I'm done I'd like to umount the CD and then eject it by sending an IOCTL eject command. But since I executed a CHROOT I can't umount the CD, umount complains that the device is busy.
So how do you reverse a CHROOT?
By definition, a chroot() is not undoable. There are strong security reasons for this (chroot() is often used to create protected "jails" for untrusted code. If the code could just undo the chroot() it wouldn't be very useful). However, chroot() is per-process, therefore what you probably want to do is fork(), then do a chroot() in the child and do whatever you want to do there, when you're done with the CD, exit the child, and have the parent eject it.
-alex
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
On Fri, Jan 26, 2001 at 10:31:40AM -0800, Paul Powell wrote:
So how do you reverse a CHROOT?
move the prison walls inside of your cell then walk away:
as root:
mkdir("blah");
chroot("blah");
chdir("../../../../../../");sort of thing
--cw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/