Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.os.linux.development.apps Subject: Re: fopen() of a read-only file for writing? Date: Thu, 19 Apr 2012 14:18:33 +0100 Lines: 15 Message-ID: <87aa27n9li.fsf@sapphire.mobileactivedefense.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net +OvkIYL3uoM21Bncb96RLQK0Mq/3UNgJfkueuDZjpWlXyzPFY= Cancel-Lock: sha1:LblTctCo55CKIvyCdhSXDFDFu08= sha1:f1NNAyZj1EhpCBNwWvDqIATfzlg= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: csiph.com comp.os.linux.development.apps:465 "Joe Shead" writes: > I tested it, and it works. With a new non-root user, I got the EACCES that I > expected. > > I'll just say, for anyone out there who wants to read my humble opinion, > that sometimes root wants to set things (like relatively stable C++ code, or > an initialization script) to read-only, so he knows that if he opens those > files to take a look, he can't easily accidentally modify them. If he wants > to change the file, he would actually like to be forced to do a chmod, make > the deliberate changes, and then chmod it back to read-only. I do that all > the time. The most reliable solution would 'ensure that you have up-to-date backups'. Apart from that, if on ext?, you might want to have a look at chattr(1), specifically, the 'i' ('immutable') attribute.