Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Make a file uneditable
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
wokick
Tux's lil' helper
Tux's lil' helper


Joined: 27 Sep 2004
Posts: 97

PostPosted: Fri Feb 15, 2008 7:20 pm    Post subject: Make a file uneditable Reply with quote

Hi,

Is there a way to make a text file uneditable even by root?

Read permission is ok.

BTW: I have the root access to the system.
Back to top
View user's profile Send private message
eXt
n00b
n00b


Joined: 09 Oct 2005
Posts: 66
Location: Sweden

PostPosted: Fri Feb 15, 2008 7:35 pm    Post subject: Reply with quote

I don't believe it is possible to set some magic attribute but you could place the file on a separate partition and mount it read-only and then create a symlink. Now, why you would want a file to be read-only to root?
Back to top
View user's profile Send private message
linuxtuxhellsinki
l33t
l33t


Joined: 15 Nov 2004
Posts: 700
Location: Hellsinki

PostPosted: Fri Feb 15, 2008 7:50 pm    Post subject: Reply with quote

If you use ext2/3 filesystem then you can add immutable-flag with "chattr"-command as you can see from this example...
Code:
hellsinki ~ # touch file
hellsinki ~ # chattr +i file
hellsinki ~ # echo blaa >> file
-su: file: Permission denied
hellsinki ~ # rm -f file
rm: cannot remove `file': Operation not permitted

_________________
1st use 'Search' & lastly add [Solved] to
the subject of your first post in the thread.
Back to top
View user's profile Send private message
MostAwesomeDude
Guru
Guru


Joined: 12 Aug 2007
Posts: 373

PostPosted: Sat Feb 16, 2008 2:32 am    Post subject: Reply with quote

One of the most important things about root is that you are not forbidden from any part of the system. What is this for?
_________________
Don't believe the "n00b" under my name.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23070

PostPosted: Sat Feb 16, 2008 3:12 am    Post subject: Reply with quote

The superuser can also remove the immutable attribute. Marking a file as immutable is fine if you just want to stop a program from accidentally overwriting the file, but it will not prevent an informed superuser from modifying the file. If you need that, look into using SELinux or GRsecurity to restrict the permissions available to processes running as root.
Back to top
View user's profile Send private message
padoor
Advocate
Advocate


Joined: 30 Dec 2005
Posts: 4185
Location: india

PostPosted: Sat Feb 16, 2008 5:21 am    Post subject: Reply with quote

the surest way is to put the file in cd. so no one can overwrite. you can mount it and use as root /user .
_________________
reach out a little bit more to catch it (DON'T BELIEVE the advocate part under my user name)
Back to top
View user's profile Send private message
linuxtuxhellsinki
l33t
l33t


Joined: 15 Nov 2004
Posts: 700
Location: Hellsinki

PostPosted: Sat Feb 16, 2008 9:36 am    Post subject: Reply with quote

Hu wrote:
The superuser can also remove the immutable attribute. Marking a file as immutable is fine if you just want to stop a program from accidentally overwriting the file, but it will not prevent an informed superuser from modifying the file. If you need that, look into using SELinux or GRsecurity to restrict the permissions available to processes running as root.


& superuser cannot turn 'em off :?:
_________________
1st use 'Search' & lastly add [Solved] to
the subject of your first post in the thread.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23070

PostPosted: Sat Feb 16, 2008 4:13 pm    Post subject: Reply with quote

linuxtuxhellsinki wrote:
Hu wrote:
The superuser can also remove the immutable attribute. Marking a file as immutable is fine if you just want to stop a program from accidentally overwriting the file, but it will not prevent an informed superuser from modifying the file. If you need that, look into using SELinux or GRsecurity to restrict the permissions available to processes running as root.


& superuser cannot turn 'em off :?:


That depends on exactly how super a superuser you mean. The goal of the various RBAC projects is that having a user id of root does not automatically give you permission to do every privileged operation on the system. For instance, the NTP daemon needs root access to change the system time, but does not need permission to rewrite /etc/passwd. An RBAC system would allow you to write a policy that enforces that separation of permission.

Even under an RBAC system, there can be an all-powerful superuser with the ability to change policy or disable the RBAC system entirely. However, it is traditional that the all-powerful superuser is used only for these tasks. No daemon should ever run in that context, and even most other system administration should not be done in that context. In such a configuration, attaining the all-powerful superuser role would require that an attacker obtain the password which protects that role, or find a privilege escalation bug in the kernel. If the right protection measures are employed, it should be possible to require that the attacker be at the system console to obtain full access. Also, it should be possible to configure an RBAC system in such a way that it is impossible to turn it off without rebooting, but this is not a common configuration.
Back to top
View user's profile Send private message
linuxtuxhellsinki
l33t
l33t


Joined: 15 Nov 2004
Posts: 700
Location: Hellsinki

PostPosted: Sat Feb 16, 2008 4:58 pm    Post subject: Re: Make a file uneditable Reply with quote

wokick wrote:
BTW: I have the root access to the system.


Yeah, I know the principles of GRsecurity and SELinux etc. but I think that those are little bit overkill for him. And the only way to restrict root from writing to the file is what padoor suggested, burn the file in CD and make a symbolic link to it :wink:
_________________
1st use 'Search' & lastly add [Solved] to
the subject of your first post in the thread.
Back to top
View user's profile Send private message
MostAwesomeDude
Guru
Guru


Joined: 12 Aug 2007
Posts: 373

PostPosted: Sat Feb 16, 2008 6:24 pm    Post subject: Reply with quote

We still haven't heard back from the TC. Exactly why does he need this?
_________________
Don't believe the "n00b" under my name.
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