LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-29-2005, 12:48 AM   #1
chibi
Member
 
Registered: Aug 2004
Location: Canada
Distribution: Debian
Posts: 62

Rep: Reputation: 15
prevent directories from being renamed


Hello,

Ill ask my question first and explain it more below..

I have a folder with 5 files in it. The folder is called testfolder. What I want to ensure is that, even though users have access to the folder they cannot rename it.

But they can still go into the testfolder, and rename and modify the files inside it. All I want is just to make sure the folder cannot be renamed without taking away their access to the contents inside. Is there a way to do this?

The users trying to rename of course wont be root. Is there a chown or chmod setup to do this?

I dont want them to lose their access to the folder's contents. I just dont want the folder renamed.

Please help me Thanks!

-Chibi
 
Old 04-29-2005, 01:33 AM   #2
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
well, I can give you a limited solution, but it disables also renaming and creating of new files.. /:
Code:
chattr +i testdir
Heres a man grab:
Quote:
A file with the `i' attribute cannot be modified: it can_
not be deleted or renamed, no link can be created to this
file and no data can be written to the file. Only the
superuser or a process possessing the CAP_LINUX_IMMUTABLE
capability can set or clear this attribute.
For some reason, some of those properties are inherited by the files inside the dir. It would be perfect if it worked correctly. Note, even root doesnt have any more access to them under the i. So, youll have to remove the attribute first with chattr -i testdir.

Modifying the files under the dir worked when I tried it, but not much else.. /:

edit:
just figured why it doesnt work as its supposed to. Seems like the i parameter cannot be used on directories, so it applies it to the files also or sumthing.. d:

Last edited by Artanicus; 04-29-2005 at 01:35 AM.
 
Old 04-29-2005, 01:51 AM   #3
chibi
Member
 
Registered: Aug 2004
Location: Canada
Distribution: Debian
Posts: 62

Original Poster
Rep: Reputation: 15
I've never seen that command before.

The reason I need this is, I dont want to give some people access to the box, but I have setup a page made in php that detects certain directories to change their options.. but if they rename the directories the script goes to crap :P

and i cant just, tell them not to rename because these arent close friends, they are practical strangers im helping out

Thanks.
 
Old 04-29-2005, 02:02 AM   #4
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
Did quite a heap of testing and came up with a solution:

If you create a dir with the chmod +t set, and another dir under that with +t also, but also chmod 777, the second dir cannot be moved, but stuff under it functions normally to the ones owning them. MAke any sense? (; example:
Code:
mkdir -p foodir/testdir
chmod 777 foodir/
chmod +t foodir/
chmod 777 foodir/testdir
chmod +t foodir/testdir
Now, that gets testdir protected the wya you weant it, but leaves foodir vunerable.. *sigh* Not an easy problem..
 
Old 04-29-2005, 03:28 AM   #5
chibi
Member
 
Registered: Aug 2004
Location: Canada
Distribution: Debian
Posts: 62

Original Poster
Rep: Reputation: 15
Ah great job Didnt know about the +t either x_x.

Yeah leaving the above directory completely vulnerable is not a good idea :\ . But that directory would probably be empty besides the protected folder(s).. so maybe it might be okay. Could someone -r delete foodir and thus testfir inside?

777 means ugo all have rwx right?

Thanks for the continued help
 
Old 04-29-2005, 03:56 AM   #6
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
Don't worry about using the sticky bit (chmod +t), making any dir that you don't want to let anyone edit chmod 777 is not a good idea. All you need to do is make the directory (folder) that testfolder is located in, say "above", not writable by those that you don't want to write to it. Like this:

||| above --> this is not writable - chmod 755 - owned by root
|||
||| -- testfolder --> this is writable - chmod 777 - owned by anybody you like, even root
||||||
|||||| -- user_dirs_&_files


This way, users wont be able to edit anything, including the name of dirs, in the "above" dir, but will be able to create & edit in "testfolder".
 
Old 04-29-2005, 07:45 AM   #7
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
lol.. why didnt I think of that.. alot easier indeed. Guess I just missed the obvious, sorry for that.. (:

If you want so that the lowest folder can contain files by many users but they can only edit files they own themselves (while still preserving the chmod 777), then use the stickbit for the dir, but otherwise it goes un-needed with the above structure.
 
Old 04-29-2005, 12:24 PM   #8
chibi
Member
 
Registered: Aug 2004
Location: Canada
Distribution: Debian
Posts: 62

Original Poster
Rep: Reputation: 15
Ah, thanks both of you. I am definately going to give it a try later today.

I am grateful for the help

-Chibi
 
  


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
FTP users prevent browsing to other directories mephesto Linux - Software 2 05-07-2005 11:03 AM
Renamed a mount point mbeach SUSE / openSUSE 1 04-08-2005 06:09 PM
Problems renamed after copy!! trlhoyos Red Hat 0 09-17-2004 03:54 PM
Is /etc/X11/XF86Config renamed satimis Fedora 2 08-17-2004 12:04 AM
Linux - General should be renamed... LinuxSeeker LQ Suggestions & Feedback 7 07-13-2004 07:42 AM


All times are GMT -5. The time now is 04:54 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