bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files


From: Bob Proulx
Subject: bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files
Date: Fri, 7 Sep 2012 14:42:44 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Paul Eggert wrote:
> Paolo Bonzini wrote:
> > Atomic file replacement is what matters for security.
> 
> Unfortunately, 'sed's use of atomic file replacement does not
> suffice for security.
> 
> For example, suppose sysadmins (mistakenly) followed the practice of
> using 'sed -i' to remove users from /etc/passwd.  And suppose there
> are two misbehaving users moe and larry, and two sysadmins bonzini and
> eggert.  bonzini discovers that moe's misbehaving, and types:
> 
>   sed -i '/^moe:/d' /etc/passwd

Using /etc/passwd isn't a good example because system convention
dictates that a /etc/passwd.lock must be observed for any edits there
specifically for the problem you are illustrating.  The above would
not be correct even if sed were fully atomic overall.

> Of course one could wrap 'sed -i' inside a larger script, that
> arranges for atomicity at the end-user level.

Right.  The 'vipw' script for example.  :-)

[I have abused the EDITOR variable for that purpose many times.  Set it
to either an inline script or to a real script and use it to safely
edit these types of files.  More with 'visudo' though.]

Bob





reply via email to

[Prev in Thread] Current Thread [Next in Thread]