Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-10-2010, 01:48 PM
|
#1
|
|
Senior Member
Registered: Dec 2007
Distribution: Mepis, Centos
Posts: 4,728
|
How to make a chroot non jail?
I want to know how to prepare (before issuing the chroot command) directory links out of a chroot environment.
I have done a bunch of reading, but not yet experimenting, about chroot.
I mostly understand its main purpose of creating an environment in which it is safer to run untrusted software. But I want to use it for some other things, involving trusted software.
I want to create a directory tree in which the various top level directories are links to various directories in the main directory tree. For example, when running on a Debian based 64 bit system (where /lib has 64 bit .so files) I might want to create a root in which /lib links to the directory containing 32 bit .so files (same as /lib32 normally links to).
IIUC, chroot blocks soft links from getting outside. So I could create a directory containing lib as the desired soft link, but if I did chroot to that directory, the link would no longer point where I wanted. Is that correct?
IIUC, I can't do a hard link to a directory. Is that correct?
How would you create a directory link that would point out of a chroot "jail"? (Yes I do understand that is contrary to the common purpose for a chroot).
From reading, again not yet experimenting, I think mounting an aufs might do it. It looks like aufs might be used to mount a directory into another directory. Is that correct? Am I missing some easier way to mount a directory into a directory? Would such an aufs mount link out of the chroot? Or suffer the same fate as a soft link?
|
|
|
|
05-11-2010, 07:20 AM
|
#2
|
|
Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,644
|
You can not create links to outside a jail from within a jail. The whole point in chroot is that the user or process that is jailed sees the directory path you specified as if it is "/" (root). In UNIX/Linux there is nothing above root in the filesystem heirarchy so you can't link to anything above it from within the jail as there ISN'T anything above it from its perspective.
You can however make links FROM outside to within a jail. That is to say sometimes one has a process they want users to login to but jail them so that no matter what they do they can't get outside the jail. This however does not prevent users already on the system (e.g. root) via conventional logins or processes from accessing the root.
So for example you might setup a path /root/jails/billybob and setup user, billybob, so that when he logs in he is using that in a chroot jail fashion and put files in it. So if you were to create /root/jails/billybob/bin then put in say the cp command there then as root user logged into the system you would see that file as /root/jails/billybob/bin/cp. When billybob logs in though he'll see it simply as /bin/cp. He won't know that he is in /root/jails/billybob at all.
As the root user you could make a directory in /root/jails/billybob called transfers then you could make a link called say /mysql/transferfiles to /root/jails/billybob/transfers with:
ln -s /root/jails/billybob/transfers /mysql/transferfiles
You could then allow processes on the server to write to or read from /mysql/transferfiles and billybob on login to the jail would see those files as if they were in /transfers. Note that in this scenario /mysql/transferfiles is the symbolic link.
You can NOT however make the the opposite work:
ln -s /mysql/transferfiles /root/jails/billybob/transfers
That is because even though the chroot'ed user, billybob, will see the symbolic link as /transfers pointing to /mysql/transferfiles he won't see /mysql directory so the link won't be pointing to anything from his perspective.
|
|
|
|
05-11-2010, 07:39 AM
|
#3
|
|
Senior Member
Registered: Dec 2007
Distribution: Mepis, Centos
Posts: 4,728
Original Poster
|
Thankyou for confirming my understanding that I can't do what I want using soft links.
Any comment on the important parts of my question? Other methods getting the desired effect? AUFS or other ways of mounting a directory into a directory (maybe NFS)?
|
|
|
|
05-11-2010, 08:41 AM
|
#4
|
|
Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,644
|
Haven't worked with aufs or unionfs it mentions but on a quick perusal of those pages it appears they might do what you want.
Once you created your filesystem with the directories you want you'd probably still want to chroot yourself to that. If the filesystem exists BEFORE the chroot then the user/process isn't "linking" but rather using something that is "local" within the filesystem. Since I haven't done this I can't be sure but it seems a reasonable supposition.
You might want to post a new thread specifically asking about aufs/unionfs to see if anyone that knows them can give better guidance.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:18 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|