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 11-01-2012, 09:26 AM   #1
Slyfox696
LQ Newbie
 
Registered: Nov 2012
Posts: 3

Rep: Reputation: Disabled
Directory ownership or permissions inside another directory


First, some background knowledge to give perspective on my question:

Here's the situation. I'm running Joomla content manager for a school, and I let the teachers work on their own pages. I installed an add-on to allow teachers to upload files (pictures, documents, etc.) to a place on the server which resides at /srv/www/htdocs/files/teachers/teacheruploads/"teachers name"/

However, and I did not see this happening, teachers are using the built in media uploader (instead of my add-on) and the files are being stored (messily) on the default media directory, which is /srv/www/htdocs/files


Here's the Linux based question, and I THINK I already know the answer, but I'm hoping for a miracle.

Question:

Is it possible to restrict file upload to a directory by user(s), while allowing the same user(s) to upload files to a directory inside the directory I'm wishing to restrict? Whether it be through file permissions or file ownership?
 
Old 11-01-2012, 11:02 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,401

Rep: Reputation: 1488Reputation: 1488Reputation: 1488Reputation: 1488Reputation: 1488Reputation: 1488Reputation: 1488Reputation: 1488Reputation: 1488Reputation: 1488
Yes, you can remove write permission from a directory while allowing writes to subdirectories within it. It's done all the time. Consider that you don't have write permission in /home but do have write permission in /home/slyfox (or whatever your actual home directory might be).
 
Old 11-01-2012, 11:55 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Is it possible to restrict file upload to a directory by user(s), while allowing the same user(s) to upload files to a directory inside the directory I'm wishing to restrict? Whether it be through file permissions or file ownership?
Yes, it's possible. Simply remove write permission (for group and others) for the all the parant directories, using command:
Quote:
chmod 755 <directory__name>
In addition, you can set sticky bit permission on those directories, so in that case, files inside dir. can be deleted by the owner of the file, the owner of the directory or root. This prevents a user from deleting other users files from public directories. To do this:
Quote:
chmod a+t <directory__name>
Or do both above things in one step:
Quote:
chmod 1755 <directory__name>
 
Old 11-02-2012, 02:14 PM   #4
Slyfox696
LQ Newbie
 
Registered: Nov 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you for the responses. The example regarding /home/"user" makes so much sense I'm a little bothered I didn't think of it. I suppose that's why I post in the newbie section.

Thank you again.
 
  


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
Automatically change permissions/ownership of files in a directory Shimdidly Linux - Newbie 3 04-08-2012 08:22 PM
Directory Ownership and Permission Changes Not Staying kaplan71 Debian 4 10-13-2009 10:34 AM
mount directory ownership shakezilla Slackware 3 01-23-2007 11:39 PM
ownership of directory lsu420luv Linux - General 1 06-09-2005 04:36 PM
write permissions for directory - not accidently move/deleted the directory linuxgamer Linux - Newbie 10 12-02-2003 03:04 AM


All times are GMT -5. The time now is 12:35 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration