LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-27-2009, 12:43 PM   #1
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Rep: Reputation: 15
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

Last edited by anirvana; 08-27-2009 at 12:44 PM.
 
Old 08-27-2009, 01:09 PM   #2
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
Quote:
home directory /home/user2 to something like /home/user1/buffer/home/user2
How about doing a usermod -d on that particular user??

usermod -d /home/user1/buffer/home/user2 <user2>
usermod -d /home/user1 <user1>

Try this.
 
Old 08-27-2009, 01:29 PM   #3
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,087

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
Quote:
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... [SNIP] ...
and when user2 does ls /usr/bin he should see contents of /home/user1/extra/usr/bin/
If you explained to us exactly why you want to do this, we might be able to offer a simple solution.
 
Old 08-27-2009, 01:49 PM   #4
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Original Poster
Rep: Reputation: 15
@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 :-)
 
Old 08-27-2009, 01:55 PM   #5
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
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.

Last edited by kdelover; 08-27-2009 at 01:58 PM.
 
Old 08-27-2009, 03:52 PM   #6
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Original Poster
Rep: Reputation: 15
@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 :-)
 
Old 08-27-2009, 03:59 PM   #7
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
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
 
Old 08-27-2009, 04:07 PM   #8
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Original Poster
Rep: Reputation: 15
@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..
 
Old 08-27-2009, 04:17 PM   #9
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
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.
 
Old 08-27-2009, 05:01 PM   #10
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Original Poster
Rep: Reputation: 15
@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

Last edited by anirvana; 08-27-2009 at 05:26 PM.
 
Old 08-27-2009, 05:25 PM   #11
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Original Poster
Rep: Reputation: 15
@kdelover

I get setfacl: /: Operation not supported

even though I made entries in /etc/fstab to mount / as using acl
 
Old 08-27-2009, 05:36 PM   #12
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
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.

Last edited by kdelover; 08-27-2009 at 05:38 PM.
 
Old 08-27-2009, 05:50 PM   #13
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Original Poster
Rep: Reputation: 15
@kdelover

sorry, but I got

mount: special device remount does not exist
 
Old 08-27-2009, 05:59 PM   #14
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
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

Last edited by kdelover; 08-27-2009 at 06:02 PM.
 
Old 08-27-2009, 06:05 PM   #15
anirvana
Member
 
Registered: Mar 2007
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by kdelover View Post
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
Yes I see this

Quote:
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
/etc/fstab has
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
System gets hanged when i enter into /home directory [FC3] scandalouskk Linux - General 9 05-05-2009 10:40 PM
fopen a file in home directory Four Programming 2 04-07-2007 05:52 PM
need to link a home directory to an apache directory Melsync Linux - Server 3 09-30-2006 06:08 AM
How to protect a file/directory in your home login directory (RH Linux) jitsenho Linux - Security 9 07-04-2006 12:08 AM
how to locate file in home directory learnfast Linux - Newbie 3 03-14-2005 08:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration