Make a file as difficult to change as possible, even for root.
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
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.
Make a file as difficult to change as possible, even for root.
Hello
This is a strange one. I want to make a file as difficult to change as possible, even for myself. Why? Because I keep changing it even though I know I shouldn't and the result is always bad.
The appropriate place to apply this bugfix is between the keyboard and the chair but that code is so broken generating a patch file would be a nightmare.
What can I do beyond
Code:
chattr +i /the/file
and mounting it on a separate read-only partition that will make it as hard for me change it as possible? It doesn't matter if it's possible to change it with huge effort, but it would be nice if it could be made to take at least 30 minutes effort to undo all the restrictions. All suggestions welcome
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
You could write a daemon that monitors that file and triggers a cattle prod if any attempt to change it is made; hook the cattle prod to the chair seat and there you go...
Other than that, nope, not much else you can do -- just remember that if you head hurts, stop banging it against the wall, eh?
Distribution: BeOS, BSD, Caldera, CTOS, Debian, LFS, Mac, Mandrake, Red Hat, Slackware, Solaris, SuSE
Posts: 1,761
Rep:
Not knowing what the file is, copy it to a CDFS, delete the original on the hard drive, and mount the read-only CDFS. Of course this dosen't prevent the PEBKAC from abusing the CDFS.
Why don't you just turn on version control for this file? May be you can use git or similar tool. This way, you will always get back your original file.
And, here is a weird way to make it read-only. Write a kernel module which will create a /proc entry. Make the read function return the contents of the file and do not provide write support. Compile and insert module. Edit your init scripts to bind the /proc folder to the folder where your file is currently present or create appropriate sym links.
And, here is a weird way to make it read-only. Write a kernel module which will create a /proc entry. Make the read function return the contents of the file and do not provide write support. Compile and insert module. Edit your init scripts to bind the /proc folder to the folder where your file is currently present or create appropriate sym links.
Genius Compile it statically into the kernel! That should do it so long as I clean up after the build. Very cool solution.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.