emacs-devel
[Top][All Lists]
Advanced

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

Re: Race-condition ? (was: "Preserve owner and group" on MSDOS/Windows)


From: Eli Zaretskii
Subject: Re: Race-condition ? (was: "Preserve owner and group" on MSDOS/Windows)
Date: Fri, 24 Jun 2005 22:07:35 +0200

> From: address@hidden (=?iso-8859-1?Q?Ga=EBtan?= LEURENT)
> Date: Fri, 24 Jun 2005 17:07:57 +0200
> 
> >     * fileio.c (Frename_file): Preserve owner and group, if possible,
> >     when copying.
> 
> This is done with a call to chown, and I think this is a source of
> race-conditions, like the one that was recently discovered in bzip2
> (someone could have replaced the file by a link to another file between
> Fcopy_file and chown).

So?  What problems would that cause, except defeating the call to
chown itself?  Previous versions of Emacs didn't call chown at all, so
how is the current version worse?

It's possible that this race condition is harmful in the context of
bzip2, but that doesn't necessarily mean it's as harmful in Emacs.

> I believe we should use fchown instead.

Only if the danger is real, IMHO: fchown requires that we open the
file, which is expensive.  If we go that way, we might as well check
if we are root, and only open the file and call fchown if we are: no
need to punish mere mortals if we know in advance the call will fail
for them anyway.

> In fileio.c there is also a call to chmod in copy-file which seem to
> suffer the same problem. This one is also in emacs 21.4.

Yeah, and many versions before that.

Anyway, how portable are fchown and fchmod?  If not all platforms
support them, we shouldn't introduce them without an Autoconf test.




reply via email to

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