Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Reset file Permissions to sensible defaults?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Jords
n00b
n00b


Joined: 08 Aug 2005
Posts: 18

PostPosted: Wed Jan 03, 2007 5:11 am    Post subject: Reset file Permissions to sensible defaults? Reply with quote

Is there some program or script to reset the permissions on most of the files on my system to something reasonably safe?

I've been setting important things to 777 for convienence and forgetting about them for FAR to long! :oops: (I'm left in terror that somebody types rm -rf / - even if they're not root, it would still do loads of damage! :twisted:


Or Can someone tell me what the permissions for the most critical directories should be, and give me some commands to set them to that?


Thanks,

Jords
Back to top
View user's profile Send private message
asiB4
Guru
Guru


Joined: 16 Jan 2006
Posts: 370
Location: Inside the electric circus

PostPosted: Wed Jan 03, 2007 5:30 am    Post subject: Reply with quote

something like...

Code:
#chmod -R 755 /


...should set everything in the root directory to rwxr-xr-x permissions.
_________________
Registered Linux User #332738

Back to top
View user's profile Send private message
kenai
n00b
n00b


Joined: 27 Aug 2006
Posts: 10

PostPosted: Wed Jan 03, 2007 5:39 am    Post subject: permissions Reply with quote

maybe with find...

First of all you have localize files that need +x permissions...

For example:
Code:

find / -type d -name bin -exec chmod -R 755 {}/ \;


Next:
Code:

find / -type d -exec chmod 755 {} \;
find /bin -type f -exec chmod 755 {} \;
find /sbin -type f -exec chmod 755 {} \;
find /etc -type f -exec chmod 644 {} \;
find /var-type f -exec chmod 644 {} \;
... etc etc


It will take a little of your time, but it'll works =P
There are not too many directories in "/"
It can be improved in a bash script with an "if" sentence, but i'm too lazy to make a script right now.

Anyway, the easiest solution (but not the best) is doing a "chmod -R 755", just like asiB4 said :P
Back to top
View user's profile Send private message
Jords
n00b
n00b


Joined: 08 Aug 2005
Posts: 18

PostPosted: Wed Jan 03, 2007 5:42 am    Post subject: Reply with quote

I just ran that but caught it quickly - Setting everything in /dev to read only for non-root users is Not good...

I think it'll take something much more 'smart' to fix my system...

P.S: I'll try your solution, kenai, when I have a little more time...


Last edited by Jords on Wed Jan 03, 2007 7:39 am; edited 1 time in total
Back to top
View user's profile Send private message
harrisonmetz
Tux's lil' helper
Tux's lil' helper


Joined: 24 Apr 2006
Posts: 93
Location: Chicago, IL

PostPosted: Wed Jan 03, 2007 6:59 am    Post subject: Reply with quote

Its important to note that some files like shadow should be only readable by the root and the tmp directory must have the stickey bit on it set. su should have the suid bit set. etc.
Back to top
View user's profile Send private message
asiB4
Guru
Guru


Joined: 16 Jan 2006
Posts: 370
Location: Inside the electric circus

PostPosted: Wed Jan 03, 2007 7:38 am    Post subject: Reply with quote

Jords wrote:
I think it'll take something much more 'smart' to fix my system...


...sorry if my way wasn't smart enough...but then again, I don't have everything of mine set to rwx by anyone and everyone, either. That just wouldn't be "smart". Good Luck! :lol:
_________________
Registered Linux User #332738

Back to top
View user's profile Send private message
Jords
n00b
n00b


Joined: 08 Aug 2005
Posts: 18

PostPosted: Wed Jan 03, 2007 7:43 am    Post subject: Reply with quote

Did I imply I could fix my system? :oops:

Yeah I know It's extremely dumb having so much stuff writable by anyone... Hence this topic :<
Back to top
View user's profile Send private message
Xoalin
n00b
n00b


Joined: 11 Jun 2004
Posts: 40
Location: North Pole

PostPosted: Wed Jan 03, 2007 8:10 pm    Post subject: Reply with quote

Gentoo Security Handbook

Specifically the chapter on file permissions could probably be worth reading.

Also check out the man page on find, dull read but should give you the info you need to search for such files and or understanding what people are suggesting.
_________________
Pollution is here to stay. Corporations will sell us the oil to destroy the environment, and soon they will sell us clean air. You don't believe me? Then why are they already selling us clean water?
Back to top
View user's profile Send private message
Jords
n00b
n00b


Joined: 08 Aug 2005
Posts: 18

PostPosted: Thu Jan 04, 2007 12:13 am    Post subject: Reply with quote

Ok, I'll go RTFM :<

Thanks for the help people!

Uh, A problem seems to have come out of running chmod -R 755 /, even for just a little while - su has stopped working, just giving Authentication Failure errors. Sudo still works. Maybe something has the wrong permissions now causing this?
Back to top
View user's profile Send private message
asiB4
Guru
Guru


Joined: 16 Jan 2006
Posts: 370
Location: Inside the electric circus

PostPosted: Thu Jan 04, 2007 2:30 am    Post subject: Reply with quote

what is the output of

Code:
$stat /bin/su


should look something like the example below...the parts in red are probably an issue. Since you ran #chmod -R 755 /, I would bet it is now 0755/-rwxr-xr-x or something of that nature. Running #chmod 4711 /bin/su should put it back to the original state like the example below.
Quote:
File: `/bin/su'
Size: 26948 Blocks: 56 IO Block: 4096 regular file
Device: 806h/2054d Inode: 31348 Links: 1
Access: (4711/-rws--x--x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2006-12-31 17:54:43.000000000 -0800
Modify: 2006-08-31 11:47:26.000000000 -0700
Change: 2006-12-31 17:54:43.000000000 -0800

_________________
Registered Linux User #332738

Back to top
View user's profile Send private message
Jords
n00b
n00b


Joined: 08 Aug 2005
Posts: 18

PostPosted: Thu Jan 04, 2007 9:37 am    Post subject: Reply with quote

Yeah su lost its' SUID permission so I just did a chmod +s /bin/su - working fine now.

Well I've gone through that guide and changed a lot of permissions... It's a lot better now.

Thanks again people, only wish I had found that Piece of Documentation before starting a topic :oops:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum