Making a read only window to a directory in a different tree
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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).
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?
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.
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).
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...
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...
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.