LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 10-20-2011, 08:23 AM   #1
njmeyer8
LQ Newbie
 
Registered: Oct 2011
Distribution: Ubuntu 10.04
Posts: 6

Rep: Reputation: Disabled
Making a read only window to a directory in a different tree


So I have a question about binding directories to other directories.....

I have a folder where I keep my movies and music. My buddies want to be able to sftp in and rip my media. I made them a folder /bin/ftp where when they login they are bound to this directory and can only access their own directory inside /bin/ftp. But inside of /bin/ftp I want to make a "tunnel" to my media folder. I want this tunnel to be a read only tunnel so they can view my media and use the "get" commands but cant screw anything up....

Im trying to learn as much about ubuntu as possible so command line solutions would be appreciated, and please explain what each line does. I need to learn! haha
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 10-20-2011, 08:51 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

You will want to create a symbolic link to your media directory using the "ln" command, using the -s argument. Look at the following:
Code:
cd /bin/ftp
ln -s /path/to/media/directory
Cheers,

Josh
 
1 members found this post helpful.
Old 10-20-2011, 09:02 AM   #3
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
First thought - a subdirectory of /bin feels like a bad idea to me. /bin is for essential binaries ... in fact see Filesystem Hierarchy Standard:
Quote:
Requirements

There must be no subdirectories in /bin.
Presumably each user has their own account and home directory on your system? You could just create a symlink, as corp679 suggests, within their home:
Code:
ln -s /path/to/mediafolder /home/buddy1/yournamegoodies
Or you could put a central ftp directory in /var

Second thought - by default the files in your home directory are readable but not writeable by another user. You can check the situation with ls -l and you can (probably should) set your other directories not to be readable by other users (with chmod).
 
2 members found this post helpful.
Old 10-20-2011, 11:01 AM   #4
njmeyer8
LQ Newbie
 
Registered: Oct 2011
Distribution: Ubuntu 10.04
Posts: 6

Original Poster
Rep: Reputation: Disabled
thanks for the input, I moved my /bin/ftp directory to just /ftp. That a better location?

Question about ln -s.....I did some googling and it looks like ln does not perform as well as other options. They compared it to mouth --bind. How would I do it using mount --bind? or is there an even better way?

Also, it looks like neither of these would survive a reboot. How do I make it survive a reboot?
 
Old 10-20-2011, 12:20 PM   #5
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
afaik /ftp is fine.

Odd, I have not heard that a symlink would not perform as well - under what circumstances? Once the user has navigated to the right directory I would have thought it was identical. mount --bind should be an option but I haven't worked with it.

Creating a symlink creates a point on the file system and will definitely survive a reboot (imho). A mount would need to be rerun each time, via /etc/fstab (possibly) or an init script.
 
1 members found this post helpful.
Old 10-20-2011, 12:47 PM   #6
njmeyer8
LQ Newbie
 
Registered: Oct 2011
Distribution: Ubuntu 10.04
Posts: 6

Original Poster
Rep: Reputation: Disabled
Well I tried it out and everything worked great! Except for one thing....haha. Theres always a kicker.

I want to make the permissions 755, but symlinks are only 777. How can I get around this?
 
Old 10-20-2011, 02:18 PM   #7
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
I think ... symlinks themselves don't need permissions, but the linked file/directory will control it.

Try creating or deleting a file in your media folder when logged in (or using su) as one of the sftp users. (Not the symlink itself, they will still be able to delete that).
 
Old 10-20-2011, 03:10 PM   #8
njmeyer8
LQ Newbie
 
Registered: Oct 2011
Distribution: Ubuntu 10.04
Posts: 6

Original Poster
Rep: Reputation: Disabled
Well normally I would be able to just change the permissions on the linked directory, but its on a partition and the data type of the partition does not allow permissions..... so the default is 777. So sadly that doesn't work...
 
Old 10-20-2011, 03:12 PM   #9
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by SecretCode View Post
I think ... symlinks themselves don't need permissions, but the linked file/directory will control it.

Try creating or deleting a file in your media folder when logged in (or using su) as one of the sftp users. (Not the symlink itself, they will still be able to delete that).
Yup, that's correct. On a side note, create a hard link, and then look at the permissions...
 
Old 10-20-2011, 03:19 PM   #10
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by njmeyer8 View Post
Well normally I would be able to just change the permissions on the linked directory, but its on a partition and the data type of the partition does not allow permissions..... so the default is 777. So sadly that doesn't work...
Ah. Not good news. Now you might need to consider mount --bind.
Quote:
Note that the filesystem mount options will remain the same as those on the original mount point, and cannot be
changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount
command, for example:

mount --bind olddir newdir
mount -o remount,ro newdir
 
Old 10-20-2011, 03:24 PM   #11
njmeyer8
LQ Newbie
 
Registered: Oct 2011
Distribution: Ubuntu 10.04
Posts: 6

Original Poster
Rep: Reputation: Disabled
Awesome. That works perfectly. Now that does not survive a reboot...so how would I make that happen?
 
Old 10-20-2011, 03:38 PM   #12
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
I think someone else will need to advise on that! ...
 
Old 10-20-2011, 03:39 PM   #13
njmeyer8
LQ Newbie
 
Registered: Oct 2011
Distribution: Ubuntu 10.04
Posts: 6

Original Poster
Rep: Reputation: Disabled
haha alright. thanks so much of your help!
 
  


Reply



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
ftp whole directory tree vinaytp Linux - Newbie 1 02-11-2010 04:27 AM
Copying a single file into each directory of a directory tree mlapl1 Linux - Newbie 2 06-27-2007 10:18 PM
permissions for directory tree adamwenner Linux - Security 3 10-23-2004 07:39 AM
Help! How do you delete a directory tree? johnmcollier Linux - Security 0 10-24-2003 02:29 AM
Directory Tree Question GreatMilenko Linux - Security 3 06-02-2002 01:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 11:46 AM.

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
Open Source Consulting | Domain Registration