How to link home directory to different file-system
Hello all,
I'm looking for some advice about how to implement the following functionality in my pet project. There are two users on my system, user1 and user2. When user1 logs in he can do what he wants etc.. when user2 logs in I want to somehow link the entire file system to another place. In more detail when user2 logs in and does something like ls ~, he should see contents of /home/user1/extra/home/user2/ instead of /home/user2/ and when user2 does ls /usr/bin he should see contents of /home/user1/extra/usr/bin/ Is there a simple way to do this kind of operation. I have looked up the ln command, but I am a little unsure about how to show a completely different file structure to a particular user. I did play around with ln and found that you can make "soft links" to directories. The problem being how can I link the user2 home directory /home/user2 to something like /home/user1/buffer/home/user2 . can I use something like ln -s /home/user1/buffer/home/user2 /home/user2 .. I guess not. I didn't want to try it as I wasn't sure so as to not hose my system. Thanks in advance for any advice/pointers |
Quote:
usermod -d /home/user1/buffer/home/user2 <user2> usermod -d /home/user1 <user1> Try this. |
Quote:
|
@kdelover
You are right about using usermod, however it will only be useful in the case where I want to change the home directory of user2 to some other location. Useful, nonetheless. The problem being can I somehow point user2 to a completely different file structure @tredegar I want to do this because I want to maintain a file structure on a USB stick (just as an example). I do not want the file structure and the files in it to be known to every programmer on my system. Thereby if I can figure out a way to let user2, who is a special programmer and can get access to the file-system on the USB disk I should be able to give it to him. The point being I want user2 to feel as if he is working on the main computer itself. Thereby the question about "Can I link the entire filesystem for a particular user to somewhere else" I want user2 to seamlessly log in to my computer, I will decide if user2 is a special person, based on the username..etc.. and then somehow hive off user2 to a different file system where he feels as if he is on the main computer but entries in (say) the /usr/bin on the USB stick will be different than the entries in /usr/bin on my machine but user2 ned not be bothered as he will only see file system on usb stick. Any pointers :-) |
how about mounting that usb drive to /home? what i do on my server is create a parition called /fs and NFS export it and mount it as /home on client remote systems :) It just looks like /home is locally present where as its actually nfs mounted.
|
@kdelover
that a very decent idea, I will definitely explore it with the usermod option. However the problem in this case still remains that if user2 types in ls /usr/bin he is still going to see the setup on my computer instead of the one on the usb disk..correct me if I am wrong :-) |
you want to restrict your users to just he usb pen drive that is they shouldn't be able to browse outside their home directories? is that what you are inferring? If thats the case i can only think of setting up acl on per user basis :)
|
@kdelover
Yes you are right, that user2 should be able to only be in the pen drive based file structure. With ACLs I can cut off access to my machines /usr/bin etc.. However if user2 does type in ls /usr/bin it still won't let him see the USB drive's file system. he has to explicitly type ls /mnt/pendrive/usr/bin/.... etc. I want to make this transparent such that user2 types in /usr/bin and I can show him /mnt/pendrive/usr/bin/. I'm thinking of a hammer and tongs approach: what if I modify the ls command, basically wrap a script around it and add /mnt/pendrive to all locations user2 types in. So ls /usr/bin would become ls /mnt/pendrive/usr/bin . The complication being thre are just so many possibilities, such as ls ~, the cd command, ln command etc.. |
I'm not sure if you can set up an acl on /
setfacl -m user:<username>:--- / Test it yourself and let me know i cannot test it as of now. |
@kdelover
I get setfacl: /: Operation not supported even though I modified /etc/fstab to contain LABEL=/ / ext3 defaults,acl 0 2 so that / itself now uses acls |
@kdelover
I get setfacl: /: Operation not supported even though I made entries in /etc/fstab to mount / as using acl |
Try remounting the / after you edit the fstab file .
mount -o acl remount / then do mount and grep for acl,as far as i know it must work. |
@kdelover
sorry, but I got mount: special device remount does not exist |
try this out,
there should be a config file in /boot grep for acl from that and see if the acl option is enabled or not you should see a Y what you see,you should se something like grep ACL /boot/config-<your kernel version> CONFIG_EXT2_FS_POSIX_ACL=y CONFIG_EXT3_FS_POSIX_ACL=y CONFIG_JFS_POSIX_ACL=y CONFIG_FS_POSIX_ACL=y CONFIG_XFS_POSIX_ACL=y after you have edited the fstab file just remount your parition mount -o remount / then do mount | grep -i acl or may be then do a getfacl on / and see what it shows |
Quote:
Quote:
LABEL=/ / ext3 defaults,acl 0 2 I see # file: . # owner: root # group: root user::rwx group::r-x other::r-x Thanks for the awesome responses! |
All times are GMT -5. The time now is 06:36 AM. |