Doh - slow brain day - thanks for the correction.  That nullifies my
concern when user is not root, for part of the rename() issue.

I think the return values of rename() should be checked, and it
history_do_write() should not try to rename(bakname, output) unless it
actually did rename(output, bakname) successfully.  And with both rename()
calls, ERRNO should be reported to the user if they fail.

As far as open() on HISTFILE for append or truncate, when user is root (or
when user has owner or group write to the file), I think bash (readline?)
shouldn't overwrite, append to or rename non-regular files.

I also think the handling of the case where HISTFILE is a symlink may
misbehave (it would read the history in from the file the link refers to,
but on overwrite, replace the symlink, instead of the file it refers to.)

-Jonathan Hankins

On Fri, Jan 30, 2015 at 3:27 PM, Andreas Schwab <sch...@linux-m68k.org>
wrote:

> Jonathan Hankins <jhank...@homewood.k12.al.us> writes:
>
> > Aside from the case where the user running bash is root, I think it's not
> > uncommon for users to have group write access to a variety of things in
> > /dev.
>
> Rename or delete requires write access to the containing directory.
>
> Andreas.
>
> --
> Andreas Schwab, sch...@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>
>


-- 
------------------------------------------------------------------------
Jonathan Hankins    Homewood City Schools

The simplest thought, like the concept of the number one,
has an elaborate logical underpinning. - Carl Sagan

jhank...@homewood.k12.al.us
------------------------------------------------------------------------

Reply via email to