GNU bug report logs - #25342
ln: avoid race condition with "ln -f src dst"

Previous Next

Package: coreutils;

Reported by: Mirsad Goran Todorovac <mtodorov3_69 <at> yahoo.com>

Date: Mon, 2 Jan 2017 23:12:01 UTC

Severity: wishlist

Full log


Message #14 received at 25342 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Mirsad Goran Todorovac <mtodorov3_69 <at> yahoo.com>,
 "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org>
Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest"
Date: Mon, 2 Jan 2017 21:37:58 -0800
Mirsad Goran Todorovac wrote:
> It would suffice that:
> linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) == 0 || unlink (dest) == 0 && linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) == 0;
> be replaced with:
> linkat (AT_CWDFD, source, AT_CWDFD, dest_tmp, 0) == 0 && renameat (AT_CWDFD, dest_tmp, AT_CWDFD, dest) == 0;

It isn't that simple, since renameat is a no-op if the source and destination 
are already hard links. So the patch you sent in would not work.

Anyway, I'm not disagreeing with the basic idea, I'm merely saying I don't see 
why we should have an option to keep the old behavior. Anybody who really wants 
the old behavior can do 'rm -f new && ln old new' instead.




This bug report was last modified 6 years and 261 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.