Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to setup some users to access our server. I thought the most secure way to allow them access was to setup a chroot'ed jail for them to log into.

But I need them to access a few select directories that are outside the chroot'ed environment. Apparently I can't use symlinks for this. What is the best approach? Can a chroot'ed environment not be used for this purpose?

share|improve this question
3  
Isn't the whole point of a chroot'ed environment to prevent access to files outside of the chroot? So, any way around that would be a bug? –  Andrew Barber Nov 15 '10 at 23:46
    
Maybe you could suggest a better way for me to set this up then? –  Jakobud Nov 15 '10 at 23:51

2 Answers 2

up vote 8 down vote accepted

This is a place where a bind mount will do what you want.

share|improve this answer
2  
A bind mount would likely be the best way out of this hole. "mount -o bind /dir/outside/chroot /dir/inside/chroot" To survive a reboot add "/dir/inside/chroot /dir/outside/chroot none bind 0 0" to your /etc/fstab file. –  Rik Schneider Nov 16 '10 at 3:18
    
Brilliant. Thanks! –  Jakobud Nov 17 '10 at 4:01

If it's on the same filesystem and it's individual files, hardlinks will work.

Softlinks will not work: the main purpose of a chroot'ed jail is that users can't get out to access files that aren't inside there.

You can use cp -lr to duplicate a directory tree with each file being a hardlink to the same underlying file, but that won't immediately pick up renames/moves, new files or deletes.

I think @SvenW has the best idea: move the directory into the chroot area and make the current location a symlink to the version inside the chroot.

share|improve this answer
    
I get "Invalid cross-device link". The files are on a different internal hdd. Guess that's not gonna work. –  Jakobud Nov 15 '10 at 23:52
1  
Maybe you could move the files into the required file system and then maybe use symlinks for other non-chrooted users? –  SvW Nov 16 '10 at 0:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.